smarty-php / smarty-php/smarty
smarty v4.5.5 with force_compile=true and deprecation notices
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.3k
- Forks
- 709
- PR merge metrics
- No merged PRs in 30d
Description
I was updating smarty v4.3.4 to v4.5.5 and this deprecation notice started popping up:
Deprecated: Using unregistered function "strpos" in a template is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. in smarty4/sysplugins/smarty_internal_templatecompilerbase.php on line 665
When updating from v3 to v4, I've created bunch of modifier functions in custom plugins folder, eg
myplugins/modifier.strpos.php:
function smarty_modifier_strpos($haystack, $needle, $offset = 0)
{
return (strpos($haystack, $needle, $offset));
}
I registered myplugins folder with addPluginsDir and everything worked.
Now on v4.5.5, if $smarty->force_compile = true; then notices pop up.
They go away if I:
a) set $smarty->force_compile = false
or
b) register manually those modifiers like this
$smarty->registerPlugin('modifier', 'strpos', 'strpos');
I tried to wrap my head around https://github.com/smarty-php/smarty/issues/813 and https://github.com/smarty-php/smarty/discussions/967 but cannot find what is "new proper way" of dealing with custom modifiers.
Why are custom modifier ignored if force_compile is set to true?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the notice with Smarty 4.5.5, force_compile enabled, and the custom modifier setup described in the issue. Start at smarty_internal_templatecompilerbase.php line 665 and compare plugin discovery through addPluginsDir with explicit registerPlugin calls; use issues #813 and discussion #967 for the intended behavior. Done means explaining or correcting why the modifier is ignored during forced compilation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100