smarty-php / smarty-php/smarty
Smarty::setExtensions() killing registered filters
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.3k
- Forks
- 709
- PR merge metrics
- No merged PRs in 30d
Description
Instructions to add output filters are:
$smarty->registerFilter("output", "protect_email");
Instructions to add custom extensions (overriding the defaults) are:
$smarty->setExtensions([
new Smarty\Extension\CoreExtension(),
new MyCustomExtension(),
new Smarty\Extension\DefaultExtension(),
]);
Unfortunately the latter kills $smarty->BCPluginsAdapter thus disabling any filters. I solved the problem by using:
$extensions = $smarty->getExtensions();
array_splice($extensions, 1, 0, [new MyCustomExtension]);
$this->setExtensions($extensions);
I don't like the style, but at least it is working. But something must be done here, either in the API, or at least the documentation should be updated.
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
Start with Smarty::setExtensions(), getExtensions(), and BCPluginsAdapter, then reproduce the reported interaction between custom extensions and registered output filters. Done means the filter remains usable after extensions are configured, or the API documentation clearly explains the required behavior and workaround.
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
- Mostly clear
- Newbie friendliness
- 35/100