Support » Plugin: 2FAS Light - Google Authenticator » Conflict with other plugins that use twig

  • Doug

    (@stopdesign)


    Requesting that 2FAS Light be updated with the latest version of the twig library. Conflicts causing fatal errors can be created when “two plugins both include Twig library, but a different version of it”. (a paraphrased quote from the GitHub thread included in the URL above)

    I think I’m seeing this now as an Uncaught TypeError with 2FAS Light (which uses twig 1.33.2, from April 2017) and Meta Box Builder (which uses the latest version of twig 1.42.2, from June 2019). When I have both enabled, I immediately get a fatal error, and need to enter recovery mode to disable one of the plugins. Using one without the other is fine, either way. But this will be a larger issue with other plugins that may make use of twig.

    An error of type E_ERROR was caused in line 56 of the file /home/user/site.com/wp-content/plugins/meta-box-aio/vendor/meta-box/meta-box-builder/vendor/twig/twig/src/Lexer.php. Error message: Uncaught TypeError: Argument 1 passed to Twig\Lexer::__construct() must be an instance of Twig\Environment, instance of Twig_Environment given, called in /home/user/site.com/wp-content/plugins/2fas-light/vendor/twig/twig/lib/Twig/Environment.php on line 650 and defined in /home/user/site.com/wp-content/plugins/meta-box-aio/vendor/meta-box/meta-box-builder/vendor/twig/twig/src/Lexer.php:56 Stack trace: #0 /home/user/site.com/wp-content/plugins/2fas-light/vendor/twig/twig/lib/Twig/Environment.php(650): Twig\Lexer->__construct(Object(Twig_Environment)) #1 /home/user/site.com/wp-content/plugins/2fas-light/vendor/twig/twig/lib/Twig/Environment.php(750): Twig_Environment->tokenize(Object(Twig\Source)) #2 /home/user/site.com/wp-content/plugins/2fas-light/vendor/twig/twig/lib/Twig/Environment.php(447): Twig_Environment->compileSource(Object(Twig\Source)) #3 /home/user/site.com/wp-content/plugins/2fas-light/vendor/twig/twig/lib/Twig/Environment.ph

    Manually updating 2FAS Light myself with the latest version of twig didn’t fix the conflict, as something in 2FAS Light may be making use of code that is now deprecated in the latest version of twig.

    If any other plugins get installed that use a newer version of twig, the newer version supersedes the old, causing the fatal error. Seems to be related to the older version of twig 2FAS Light is using. But this is just a guess.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author 2FAS

    (@2fas)

    We know about this, and this global problem with plugins which using external packages because wordpress do not support package manager (in PHP is the Composer) for now, so every plugin can use another version which causes conflict problems.
    We using Twig 1.33.2 because our plugin support PHP 5.3 and there are still users who use it. In feature we will abandon this version and we will update packages but there will still be a problem with the other plugins, so there is no good solution at this time.

    Hi @2fas,

    It’s Anh from MetaBox.io, which has a plugin in the conflict as @stopdesign reported.

    I notice that we use different versions of Twig. But both are 1.x. At the moment, I’m using the latest version 1.x of Twig which requires the same PHP version.

    Would you mind upgrading Twig to the latest 1.x version in your plugin?

    The only change in Twig is that it switched from PSR-0 to PSR-4 to use namespace. I looked at your plugin code and it affects only a very small part of the code (here is the screenshot: https://i.imgur.com/pnVJzrO.png).

    If you need any help, please let me know.

    Thanks,
    Anh

    Plugin Author 2FAS

    (@2fas)

    Yes but we had another problem with that version of twig with ‘class_alias’ function on version 1.34 and upper on servers using one of PHP 5.3.
    After discussion we decided to drop support for this version of PHP (but not so quickly) and upgrade version of twig in one of our next releases.
    But as we mentioned before this is not resolve the problem because if someone use another plugin which use Twig in 2.x version conflict appear again.

    I understand that. Twig 2.x requires PHP >= 7.0 which is not supported by WP yet. I think it’s safe to use Twig 1.x at the moment.

    Please let me know when you update your plugin.

    Thanks!

    @2fas @stopdesign I probably will downgrade Twig version in our plugin to 1.33.2 to keep the compatibility. Just found that WPML also uses version 1.32 of Twig. So, change in Meta Box Builder will work for both cases.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.