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

'Twig_SimpleFunction' has been removed from Twig #18

Open
dipohl opened this issue Dec 3, 2023 · 2 comments
Open

'Twig_SimpleFunction' has been removed from Twig #18

dipohl opened this issue Dec 3, 2023 · 2 comments

Comments

@dipohl
Copy link

dipohl commented Dec 3, 2023

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?

@PontusHorn
Copy link
Owner

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.

@dipohl
Copy link
Author

dipohl commented Dec 3, 2023

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!

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

No branches or pull requests

2 participants