schmittjoh / JMSTranslationBundle

Puts the Symfony2 Translation Component on steroids
http://jmsyst.com/bundles/JMSTranslationBundle
426 stars 292 forks source link

PHP error with Twig 2.0 #425

Closed secit-pl closed 7 years ago

secit-pl commented 7 years ago
Q A
Bundle version dev-master 06da85e
Symfony version 3.2.1
Twig version 2.0
PHP version 7.1

This bundle is not compatible with Twig 2.0.

PHP Fatal error: Declaration of JMS\TranslationBundle\Twig\NormalizingNodeVisitor::enterNode(Twig_NodeInterface $node, Twig_Environment $env) must be compatible with Twig_NodeVisitorInterface::enterNode(Twig_Node $node, Twig_Environment $env) in /home/devsyssim/src/vendor/jms/translation-bundle/JMS/TranslationBundle/Twig/NormalizingNodeVisitor.php on #line 29 [2017-01-09 13:56:12] php.CRITICAL: Fatal Compile Error: Declaration of JMS\TranslationBundle\Twig\NormalizingNodeVisitor::enterNode(Twig_NodeInterface $node, Twig_Environment $env) must be compatible with Twig_NodeVisitorInterface::enterNode(Twig_Node $node, Twig_Environment $env) {"exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 0): Compile Error: Declaration of JMS\TranslationBundle\Twig\NormalizingNodeVisitor::enterNode(Twig_NodeInterface $node, Twig_Environment $env) must be compatible with Twig_NodeVisitorInterface::enterNode(Twig_Node $node, Twig_Environment $env) at /home/devsyssim/src/vendor/jms/translation-bundle/JMS/TranslationBundle/Twig/NormalizingNodeVisitor.php:29)"}

[Symfony\Component\Debug\Exception\FatalErrorException]
Compile Error: Declaration of JMS\TranslationBundle\Twig\NormalizingNodeVis
itor::enterNode(Twig_NodeInterface $node, Twig_Environment $env) must be co
mpatible with Twig_NodeVisitorInterface::enterNode(Twig_Node $node, Twig_En
vironment $env)

Nyholm commented 7 years ago

To make the bundle compatible with Twig 2.0 one need to copy the current TwigFileVisitor and create a new Twig20FileVisitor with "pretty much" the same logic but using the new updated interface. One would also need a function to determine what TwigFileVistor to use.

If one could make a PR that I can merge in a minor release I would happily review that PR.

FYI @andrerom

andrerom commented 7 years ago

Thanks for the heads up, this is somewhat duplicate of #422 right?

Nyholm commented 7 years ago

422 make sure we only require twig 1.28 and up. But it has nothing todo with Twig 2.0

bdunogier commented 7 years ago

Well, it prevents the fatal error while Twig 2.0 ain't usable, @Nyholm. It has to do with it, but doesn't fix 2.0, that's right.

Nyholm commented 7 years ago

Okey, you are correct. Thanks

mvrhov commented 7 years ago

@Nyholm: But with fixes in #422 it might be enough to run with twig 2.0 as 2.0 has the same functionality as latest 1.x versions just with deprecated functionality removed and AFAIR it is forward compatible.

Nyholm commented 7 years ago

Most things, yes. But not all. The interface for the file visitor has changed.

mvrhov commented 7 years ago

I don't get it. Apart from the tests that the author of #422 said are already falling on master and the comment I left there everything seems to pass

bdunogier commented 7 years ago

I'm on it. The extractor is running here. I'll open a PR momentarily.

skonsoft commented 7 years ago

Hello,

any news for this ?

Thanks !

andrerom commented 7 years ago

any news for this ?

@skonsoft PR is stalled and could get some help on solving it differently.

mogilvie commented 7 years ago

Had a crack at updating for Twig 2.0 here #432:

Its working on local machine, (Symfony3.2.4, PHP 7.1.1) but I can't figure out how to resolve the build errors originating from BC problems around the use Twig_Node instead of expected Twig_NodeInterface.

Best of luck.

Mark

secit-pl commented 7 years ago

Hi,

any update on this?

fabienchn-zz commented 7 years ago

Hi, It worked fine on local, but I ran into this error once on my production server.

Unfortunately, I can't downgrade twig since I need it's latest version...

How far are you in fixing this issue ?

Thank you

rodrigoterminus commented 7 years ago

I'm also looking forward to this fix, guys.

Thank you in advance.

skonsoft commented 7 years ago

Hello again,

I think it become difficult to continue using this bundle. I hope that we have a new version that can fix this serious problem.

Thanks.

Nyholm commented 7 years ago

Like I said, Im happy to merge a Twig 2.0 PR. But it has to be properly made and pass the tests.

I can also let you know that php-translation supports twig 2.0.

skonsoft commented 7 years ago

@Nyholm Thank you. I hope that it will be fixed soon. I used your commit until we have a new release fixing this issue.

Thanx

Aerendir commented 7 years ago

Any news on this?

andrerom commented 7 years ago

Status: Waiting for someone to contribute a clean fix that works on both Twig 1 and Twig 2.

Please don't comment on this issue unless it's a status update, or if you want to contribute fix on it and want to coordinate.