Pico-Tags
Pico-Tags copied to clipboard
'Twig_SimpleFunction' has been removed from Twig
I am testing the new version of PicoCMS-dev 3.0 and found that the plugin is not working anymore with the new twig version included there:
PHP Fatal error: Uncaught Error: Class 'Twig_SimpleFunction' not found in /usr/share/nginx/html/pico30/plugins/PicoTags.php:103
In Twig Docs I found the older hint to replace 'Twig_SimpleFunction' with 'Twig_Function' but this method has also been removed in recent Twig version :-(
Found this instruction for Twig 3 but don't understand what I should do in concrete here for the Pico-Tags plugin https://twig.symfony.com/doc/3.x/advanced.html#functions-1
Can you help?
Hi @dipohl, sorry to say I'm not sure either from a quick glance. I'm not using Pico myself anymore and I don't foresee myself having time to update my plugins anytime soon. Happy to accept help on this if you or someone else figures something out.
Thanks for your immediate reaction! :-)
I was lucky and found how I could fix it:
# diff ../../pico/plugins/PicoTags.php PicoTags.php
103c103
< $twig->addFunction(new Twig_SimpleFunction('get_all_tags', array($this, 'getAllTags')));
---
> $twig->addFunction(new \Twig\TwigFunction('get_all_tags', array($this, 'getAllTags')));
Fortunately the new version also works on my old Pico CMS instance.
So it seems, we don't need two versions of the plugin.
fyi & cheers!