Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Twig Filters being added too late on latest Pico #19

Merged
merged 2 commits into from
May 10, 2019
Merged

Fixing Twig Filters being added too late on latest Pico #19

merged 2 commits into from
May 10, 2019

Conversation

matschundbrei
Copy link
Contributor

On my current Pico installation (2.0.4) I was not able to load this plugin, because apparently 'onPageRendering' is too late to $twig->addFilter(new Twig_Simplefilter( ... )); it has to be done 'onTwigRegistered'.

I've tested this in my demo installation and it works as expected.

Copy link

@nicola-zanardi nicola-zanardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this change, it fixed an issue that I was experiencing when loading the plugin

2019/05/08 16:16:22 [error] 24548#24548: *2818 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught LogicException: Unable to add filter "navigation" as extensions have already been initialized. in /var/www/html/pico/vendor/twig/twig/src/Environment.php:1127
Stack trace:
#0 /var/www/html/pico/plugins/PicoPagesList.php(88): Twig\Environment->addFilter('navigation')
#1 /var/www/html/pico/vendor/picocms/pico/lib/AbstractPicoPlugin.php(117): PicoPagesList->onPageRendering('index.twig', Array)
#2 /var/www/html/pico/vendor/picocms/pico/lib/Pico.php(2476): AbstractPicoPlugin->handleEvent('onPageRendering', Array)
#3 /var/www/html/pico/vendor/picocms/pico/lib/Pico.php(478): Pico->triggerEvent('onPageRendering', Array)
#4 /var/www/html/pico/index.php(33): Pico->run()
#5 {main}
  thrown in /var/www/html/pico/vendor/twig/twig/src/Environment.php on line 1127" while reading response header from upstream, client: 37.153.198.217, server: , request: "GET /pico/ HTTP/2.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "hopsu.ddns.net"
r

The issue is now gone.

Thanks @matschundbrei and @nliautaud!!

Copy link
Owner

@nliautaud nliautaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ! Added two comments.

PicoPagesList.php Outdated Show resolved Hide resolved
PicoPagesList.php Outdated Show resolved Hide resolved
Co-Authored-By: Nicolas Liautaud <[email protected]>
@matschundbrei
Copy link
Contributor Author

Thank you for your suggestions!
I have accepted them and tested the Plugin. It works with no errors.

@nliautaud nliautaud merged commit ead799a into nliautaud:master May 10, 2019
@nliautaud
Copy link
Owner

Perfect, good job 👍

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.

3 participants