Comments (10)
@ssigwart is it correct that the error only occurs if you register preg_match
as a plugin, i.e. something like $smarty->registerPlugin('modifier', 'preg_match', 'preg_match');
?
from smarty.
@wisskid, yes, we call registerPlugin
for preg_match
. If I remove that, the line code properly, but then something like {'/and/'|preg_match:'a and b'}
give an Using unregistered function "preg_match" in a template is deprecated and will be removed in a future release
error.
from smarty.
@ssigwart OK. I'm working on a solution for the "argument must be passed by reference" error. For now, you can continue without registering the preg_match
as a plugin. The deprecation notice you are seeing is harmless and should not be triggered if you have your error settings configured properly in production.
from smarty.
Thanks, @wisskid. At my company, we log deprecation warnings and getting flooded with them is not an option as it will make it very difficult to upgrade other packages or PHP itself. At the moment, we'd decided that we won't upgrade above version 4.4.1 and will likely fork from there if we need to make updates to support future PHP versions or security fixes. See #967 (reply in thread) for more context. I did want to report this issue though so it doesn't impact others because I was fortunate to stumble upon this before moving from 4.4.1 to 4.5.1.
from smarty.
@ssigwart can you please confirm that dev-support/4
fixes your problem? You can run composer require smarty/smarty:dev-support/4
in your dev environment to test.
from smarty.
@wisskid, yep, that works. Thanks! When you merge that, would you mind if I submit a PR to add disableVersion5UpgradeDeprecations()
that disables the errors?
from smarty.
@ssigwart why? Deprecations have been invented for a reason. Instead of calling a disableVersion5UpgradeDeprecations, one can also just lower error reporting level. In fact, that's easier as it is probably already the default for production.
from smarty.
I don't want to lower the error reporting level. One place I use them extensively is with PHP version updates. My company tries to clean up all deprecation notices we see. We have a very large code base, when we go from say PHP 8.1 to 8.2, we run it locally for a little while and clean up deprecations as we come across them. Then when we go to production with it, we check the logs and clean up the ones that we didn't find. Typically, there's a big influx and we clean them up, but over the next months we get handfuls of them for things that are rarely used features or really edge cases. For Smarty, at least at the moment, I can't see us upgrading to version 5 and trying to clean up all these deprecation warnings will take a significant amount of time. So my options are to stick with version 4.4.1 and hope that there's no security patches required or deal with deprecation warnings that I know won't have an impact unless we move to version 5 at some point. When we do that, then I'd deal with all the places that truly need updating versus now where we'd be updating a bunch of code just because there's a deprecation warning about a future version we don't have plans for.
from smarty.
Well, that sounds great, as this is indeed exactly what the notices are for. What I fail to understand however is why you are happy to handle the PHP deprecation notices, but not with the (few) ones Smarty generates. How are they different?
from smarty.
why you are happy to handle the PHP deprecation notices
Ha. I wouldn't say happy about it, but it's something we need to do in order to keep PHP up to date.
but not with the (few) ones Smarty generates. How are they different?
If we were moving to Smarty 5, we would handle the deprecations. In general, handling deprecations isn't what we want to be doing. We want to be adding new features to our website. What makes this different is that Smarty 4.5.0 seems like it should be a minor version update from 4.4.1, but it adds deprecation warnings. So the only reason to spend time now trying to find and clean up the deprecations is to quiet the library. I totally get cleaning up the code if/when we move to version 5, but we can plan that.
Given the size of our codebase, I don't think this will be just a "few" warnings and any bulk changes seem risky.
Another difference is that PHP is a really core piece of technology we use. Smarty is pretty core too, but less so and it's hard to convince my company that we're going to need to spend development time upgrading when there's no visible impact to them versus new features. At least with a PHP upgrade, we can point to the typical performance enhancements.
Not sure if it means anything, but we were in the unfortunate situation of launching on Smarty 2 in 2009, which happens to be just before Smarty 3 was released. Smarty 3 was a big change from Smarty 2. We used a slightly self patched version of Smarty 2 until last fall, when we finally finished a many years' long project to update and test all pages in our application to work with Smarty 3 and 4 (fun note... we were midway through working towards Smarty 3 when 4 came out, but at least that was a smaller delta).
from smarty.
Related Issues (20)
- PHP Deprecated: Using Smarty::loadFilter() to load filters is deprecated and will be removed in a future release.
- Smarty v5 $smarty.template behavior doesn't match v5 documentation (it now includes a type and directory part)
- Smarty v5 built-in json_encode modifier doesn't take Smarty $_CHARSET encoding into account, and can't be overridden using registerPlugin() HOT 18
- value and name of backed enums
- use a trailing comma in arrays HOT 1
- Smarty_Internal_Template::render(): Cannot use output buffering in output buffering display handlers HOT 7
- Support nullsafe operator HOT 2
- Fatal error: Uncaught --> Smarty: Unable to write file [file_path] thrown in C:\[project_path]\vendor\smarty\smarty\src\Smarty.php on line 1732 HOT 7
- Request for `prependTemplateDir()` or more options with `addTemplateDir()` - weight, duplicate handling HOT 9
- undefined extension class 'Smarty_Internal_Method_Get_Template_Vars' HOT 1
- Is it possible patch v2 for PHP8 instead of migrating to v4+? HOT 1
- default modifier ignores nocache on variables
- Smarty registered classes check prevents use of class constants to avoid typo bugs in templates HOT 2
- 4.5.3: Function whitelist via Smarty_Security is being ignored
- Misleading error messages with {capture}
- Smarty v5 Error: {section} Tag First Argument Type Mismatch when opening and closing tag on NoCache HOT 3
- Help with Smarty dateformat modifier - change to dd/mm/yyyy HOT 5
- Error: For loop not working when using extends resource type HOT 1
- Smarty Not Working HOT 3
- XAXOKPIMUE
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smarty.