• Resolved iisisrael

    (@iisisrael)


    When other plugins autoload Twig, it causes SocialSharing_Core_Module::registerTwigFunctions() to be hit in a recursive fashion. Wrapping each of the calls to $twig->addFunction() in that method with a try / catch resolves the \LogicException that would otherwise result on the outer recursion.

    try {
        $twig->addFunction(
            new Twig_SimpleFunction(
                'plugin_directory_url',
                array($this, 'getPluginDirectoryUrl')
            )
        );
    }
    catch(\LogicException $e) {
        // Do nothing - function has already been added
    }

    Rinse and repeat for “get_posts“, “ucfirst“, and “wp_get_attachment_image_url“.

    Tangentially, your extension functions should really be namespaced, like “ssbbs_plugin_directory_url“, or you might bump heads with someone else who shares your preference for generic function names.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter iisisrael

    (@iisisrael)

    Actually, this is a result of the other plugin depending on a newer version of Twig (2.4.4), which has many classes extending base classes (after checking if the class has already been loaded), such as Twig_SimpleFunction extending Twig_Function. I disabled the other plugin, then copied the latest version of the Twig lib into this plugin, and the same exception was encountered.

    Please play nicely with other plugins that use Twig and update!

    Plugin Author supsystic

    (@supsysticcom)

    Hello, @iisisrael
    Thank you for your feedback.
    It is extremely important for us that the plugins work correctly.
    We will definitely check this section of the code.
    Tell me which plugins you checked our plugin for conflict?

    Thread Starter iisisrael

    (@iisisrael)

    Hey @supsysticcom! The other plugin is a proprietary one, so nothing in the WP repository. But like I said in my follow-up comment, if you update Twig, you’ll see the same exceptions without any other plugin installed. Once updated and working, it will not conflict with any other plugin using the latest Twig.

    • This reply was modified 6 years ago by iisisrael.
    Plugin Author supsystic

    (@supsysticcom)

    Hello, @iisisrael
    We will try to update the version of Twig, if at the time of development there are no critical conflicts.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exception when multiple plugins use Twig’ is closed to new replies.