Skip to content

Conversation

@2Vince
Copy link

@2Vince 2Vince commented Jul 31, 2024

A proposition to fix #1048 (and may be a part of #1011 too)

This is to prevent modifiers added by registerPlugin function from beeing silently ignored by DefaultExtension.
More details in #1048

@wisskid
Copy link
Member

wisskid commented Jul 31, 2024

Sorry, but I don't like this approach. The registerplugin methods are the "old" way to register plugins. I'm in favor of creating new Extensions.

Wouldn't it be easier to switch the default loading order of the Extensions? It is now: core, default, BC. We could change it to core, BC, default.

@2Vince
Copy link
Author

2Vince commented Jul 31, 2024

Thanks for your quick reply.

You're right, it would have been be easier to switch the default loading order of the Extensions : Core, BC, then Default.
But it does not handle the case where we want to register a "Smarty::PLUGIN_MODIFIER" (not a compiler one), wich has an equivalent in DefaultExtension->getModifierCompiler(). For example :

//This modifier will be silently ignored, even if DefaultExtension is set at the end.
$smarty->registerPlugin(Smarty::PLUGIN_MODIFIER,"json_encode",[$this,"myJsonEncodeModifier"])

In that case DefaultExtension->getModifierCompiler() is going to take the lead anyway.

Side question :
I understand you consider "registerPlugin" method as old way to register Plugins.
Does this mean that it could be deprecated in a near future ?

@wisskid
Copy link
Member

wisskid commented Nov 21, 2024

I understand you consider "registerPlugin" method as old way to register Plugins. Does this mean that it could be deprecated in a near future ?

Yes, it might.

@hron84
Copy link

hron84 commented Jan 14, 2026

Sorry, but I don't like this approach. The registerplugin methods are the "old" way to register plugins. I'm in favor of creating new Extensions.

Is there any documentation about creating Extensions? In the official smarty.net docs I found none and I also found nothing in the GitHub repo. If we need to create Extensions we need documentation for it. As long as I know, the only "official" way to extend capabilities is the "old" way.

And this PR would fix an issue regarding to the "old" way. Would it possible to take an account to fix an "old" behavior until we get the "new" way get properly documented?

@wisskid
Copy link
Member

wisskid commented Jan 14, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to override built-in modifiers.

3 participants