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

Upgraded to version 1.26.0. Now templates aren't rendering #2165

Closed
andycorm opened this issue Oct 5, 2016 · 20 comments
Closed

Upgraded to version 1.26.0. Now templates aren't rendering #2165

andycorm opened this issue Oct 5, 2016 · 20 comments

Comments

@andycorm
Copy link

andycorm commented Oct 5, 2016

Every time I try to render a template in version 1.26.0 I keep getting an exception with the message "The "Twig_Extension_Sandbox" extension is not enabled in "Email/Reminder.twig" at line 1."

I've double and triple checked that I HAVE loaded the sandbox extension, yet for some reason, upon rendering it seems positive that it doesn't have it. My code works fine in version 1.25.0.

Does anyone have any ideas as to what might have started causing this hiccup in the new version?

@Tersoal
Copy link

Tersoal commented Oct 6, 2016

I've problems also.

I've done composer update and symfony was updated to 2.8.12 and twig to 1.26.1. It throws this error:

Twig_Error_Runtime in classes.php line 3445:
The "Twig_Extension_Core" extension is not enabled.
in classes.php line 3445
at Twig_Environment->getExtension('Twig_Extension_Core') in EnvironmentConfigurator.php line 40
at EnvironmentConfigurator->configure(object(Twig_Environment))
at call_user_func(array(object(EnvironmentConfigurator), 'configure'), object(Twig_Environment)) in appDevDebugProjectContainer.php line 6857
at appDevDebugProjectContainer->getTwigService() in Container.php line 314
at Container->get('twig') in appDevDebugProjectContainer.php line 687
at appDevDebugProjectContainer->getAssetic_AssetManagerService() in Container.php line 314
at Container->get('assetic.asset_manager') in appDevDebugProjectContainer.php line 3805
at appDevDebugProjectContainer->getRouting_LoaderService() in Container.php line 314
at Container->get('routing.loader') in classes.php line 1589
at Router->getRouteCollection() in classes.php line 16260
at I18nRouter->getRouteCollection() in classes.php line 1370
at Router->getMatcherDumperInstance() in classes.php line 1320
at Router->Symfony\Component\Routing\{closure}(object(ResourceCheckerConfigCache))
at call_user_func(object(Closure), object(ResourceCheckerConfigCache)) in ResourceCheckerConfigCacheFactory.php line 46
at ResourceCheckerConfigCacheFactory->cache('/var/www/taptapper.localhost/app/cache/dev/appDevUrlMatcher.php', object(Closure)) in classes.php line 1330
at Router->getMatcher() in classes.php line 16269
at I18nRouter->matchRequest(object(Request)) in classes.php line 2086
at RouterListener->onKernelRequest(object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher))
at call_user_func(array(object(RouterListener), 'onKernelRequest'), object(GetResponseEvent), 'kernel.request', object(TraceableEventDispatcher)) in WrappedListener.php line 61
at WrappedListener->__invoke(object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher))
at call_user_func(object(WrappedListener), object(GetResponseEvent), 'kernel.request', object(ContainerAwareEventDispatcher)) in classes.php line 1858
at EventDispatcher->doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(GetResponseEvent)) in classes.php line 1773
at EventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in TraceableEventDispatcher.php line 140
at TraceableEventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in HttpKernel.php line 125
at HttpKernel->handleRaw(object(Request), '1') in HttpKernel.php line 64
at HttpKernel->handle(object(Request), '1', true) in ContainerAwareHttpKernel.php line 69
at ContainerAwareHttpKernel->handle(object(Request), '1', true) in Kernel.php line 185
at Kernel->handle(object(Request)) in app_dev.php line 28

Symfony 2.8.12 requires twig 1.26, thus I've to downgrade symfony to 2.8.11 for use twig 1.25.

@xabbuh
Copy link
Contributor

xabbuh commented Oct 7, 2016

@andycorm @Tersoal Could you fork the Symfony Standard Edition and make changes that are necessary to reproduce your issue?

@andycorm andycorm closed this as completed Oct 7, 2016
@andycorm andycorm reopened this Oct 7, 2016
@andycorm
Copy link
Author

andycorm commented Oct 7, 2016

@Tersoal, any chance you could handle this? I'm afraid I have never used Symfony ☹️

@xabbuh
Copy link
Contributor

xabbuh commented Oct 7, 2016

@andycorm If you can show some steps to reproduce your issue, that will be fine too. I was just referring to Symfony as @Tersoal posted a stack trace containing calls made by Symfony.

@Tersoal
Copy link

Tersoal commented Oct 7, 2016

I'll do ASAP, perhaps on monday, sorry. But I have done composer update
only, and symfony and twig were upgraded. And then error appeared. I think
whatever install can replicate the error...

El 7 oct. 2016 8:50 p. m., "Christian Flothmann" [email protected]
escribió:

@andycorm https://github.com/andycorm If you can show some steps to
reproduce your issue, that will be fine too. I was just referring to
Symfony as @Tersoal https://github.com/Tersoal posted a stack trace
containing calls made by Symfony.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2165 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AGC5Dg-2lpj3Y87OArx-UHIrgT7t_3acks5qxpSCgaJpZM4KPZEh
.

@sstok
Copy link

sstok commented Oct 8, 2016

Did you both the clear the Cache? As in Twig 1.26.0 the extension loading changed a little, and old caches are not compatible (shouldn't be a problem, but still 😄 ).

@Tersoal
Copy link

Tersoal commented Oct 8, 2016

Yes. I cleared caché by command and manually with rm.

El 8 oct. 2016 16:10, "Sebastiaan Stok" [email protected] escribió:

Did you both the clear the Cache? As in Twig 1.26.0 the extension loading
changed a little, and old caches are not compatible (shouldn't be a
problem, but still 😄 ).


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2165 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AGC5DpEIkrVA1-wa_Bvwfn2zprApcpy_ks5qx6Q3gaJpZM4KPZEh
.

@JarJak
Copy link

JarJak commented Oct 10, 2016

Same problem here, downgrading Twig from 1.26.0 to 1.25.0 (and automatically Symfony from 2.8.12 to 2.8.11) solves the problem. I've tried to clear cache in all possible ways.

@fabpot
Copy link
Contributor

fabpot commented Oct 10, 2016

Can you list the bundles you are using that interact with Twig. I can see Assetic in the stack trace. Any other ones? It probably comes from a bundle, not Twig or Symfony.

@Tersoal
Copy link

Tersoal commented Oct 10, 2016

Here my composer.json:

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/Tersoal/ComurImageBundle"
        }
    ],
    "require": {
        "php": ">=5.3.9",
        "symfony/symfony": "2.8.*",
        "doctrine/orm": "^2.4.8",
        "doctrine/doctrine-bundle": "~1.4",
        "doctrine/dbal": "dev-master",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "symfony/assetic-bundle": "~2.3",
        "sensio/distribution-bundle": "~5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "~2.0",
        "twig/twig": "~1.22",
        "twig/extensions": "~1.3",

        "sonata-project/admin-bundle": "2.3.*@dev",
        "sonata-project/doctrine-orm-admin-bundle": "2.3.*@dev",
        "sonata-project/user-bundle": "2.x-dev",
        "sonata-project/datagrid-bundle": "2.2.*@dev",

        "friendsofsymfony/rest-bundle": "^1.8",
        "friendsofsymfony/oauth-server-bundle": "dev-master",
        "friendsofsymfony/http-cache-bundle": "^1.0",
        "nelmio/api-doc-bundle": "^2.4",

        "knplabs/doctrine-behaviors": "1.1.*@dev",
        "jms/translation-bundle": "dev-master",
        "jms/i18n-routing-bundle": "1.1.*@dev",
        "jms/security-extra-bundle": "dev-master",
        "stof/doctrine-extensions-bundle": "1.1.*",
        "beberlei/DoctrineExtensions": "dev-master",
        "dabsquared/dabsquared-push-notifications-bundle": "~1.2",
        "a2lix/translation-form-bundle": "2.*@dev",
        "stfalcon/tinymce-bundle": "1.x-dev",
        "comur/image-bundle": "1.0.x-dev",
        "liip/imagine-bundle": "1.*"
    },
    "require-dev": {
        "sensio/generator-bundle": "~3.0",
        "symfony/phpunit-bridge": "~2.7"
    },

@PatrykOstrzolek
Copy link

That issue occure after upgrading Twig to 1.26.0 - NavigationTwigExtension extension is not enabled

{
    "name": "sulu/sulu-standard",
    "license": "MIT",
    "type": "project",
    "description": "The sulu content management framework",
    "version": "1.3.0",
    "autoload": {
        "psr-0": {
            "": "src/"
        },
        "classmap": [
            "app/AbstractKernel.php",
            "app/WebsiteKernel.php",
            "app/WebsiteCache.php",
            "app/AdminKernel.php"
        ]
    },
    "require": {
        "php": ">=5.5",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "~2.0",
        "sulu/sulu": "1.3.*",
        "twig/twig": "1.25.0",
        "sulu/theme-bundle": "1.0.*",
        "symfony-cmf/core-bundle": "1.2.*",
        "dantleech/phpcr-migrations-bundle": "0.1.*",

        "nelmio/alice": "~1.7",
        "doctrine/doctrine-fixtures-bundle": "2.2.*",

        "zendframework/zend-stdlib": "~2.3",
        "zendframework/zendsearch": "@dev",

        "massive/build-bundle": "0.2.*",

        "jackalope/jackalope-doctrine-dbal": "~1.2.5",
        "jackalope/jackalope-jackrabbit": "~1.2.0",
        "doctrine/doctrine-cache-bundle": "~1.0",
        "oro/doctrine-extensions": "^1.0",
        "hiccup/sulu-blog-bundle": "@dev"
    },
    "require-dev": {
        "sensio/generator-bundle": "~3.0",
        "symfony/phpunit-bridge": "~2.7",
        "phpcr/phpcr-shell": "@beta",
        "behat/behat": "~3.0.0",
        "behat/mink-extension": "~2.0@dev",
        "behat/mink-selenium2-driver": "~1.2@dev",
        "behat/symfony2-extension": "~2.0@dev"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget",
            "Sulu\\Bundle\\TranslateBundle\\Composer\\TranslateScriptHandler::installTranslations",
            "Sulu\\Bundle\\MediaBundle\\Composer\\MediaScriptHandler::initBundle",
            "Massive\\Bundle\\SearchBundle\\Composer\\SearchScriptHandler::initBundle"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget",
            "Sulu\\Bundle\\TranslateBundle\\Composer\\TranslateScriptHandler::installTranslations",
            "Sulu\\Bundle\\MediaBundle\\Composer\\MediaScriptHandler::initBundle",
            "Massive\\Bundle\\SearchBundle\\Composer\\SearchScriptHandler::initBundle"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "symfony-assets-install": "relative",
        "incenteev-parameters": [
            {"file": "app/config/parameters.yml"},
            {"file": "app/config/phpcr.yml"}
        ]
    }
}

@SpacePossum
Copy link
Contributor

I've seen/heard the following problems:

  • updated 3rd party Twig extensions (/filters/tests) that already use something like $env->getExtension('Twig_Extension_Core'); while Twig is still @ 1.25.0
  • updated 1.26.x but not cleared the cache
  • updated Twig to 1.26.x but using a class that extends the Twig_Extension_Core (either directly or 'compiled' by some mechanism). For example:
        $env = new Twig_Environment(new Twig_Loader_Filesystem(__DIR__));
        $env->addExtension(
            new class extends \Twig_Extension_Core {
            }
        );

(Note. this also triggers a deprecation note about registering an extension with the same name core. While an anti-pattern it is not uncommon )

@makoru-hikage
Copy link

Aw, still not solved?

@fabpot
Copy link
Contributor

fabpot commented Oct 21, 2016

@makoru-hikage Were still not sure if there is something to fix, but more importantly, where. Is probably comes from a bundle. Can you list your deps to see which ones are in common with the other reporters?

@bobdenotter
Copy link

For the record, in Bolt we've had to lock the version at 1.25 too, as all Bolt extensions that would add Twig functions or filters would break.

More information here: bolt/bolt#5868

@fabpot
Copy link
Contributor

fabpot commented Oct 22, 2016

@bobdenotter Thanks for the link. This is indeed a BC break. I will see how to mitigate this issue.

Out of curiosity, why do you create extensions on the fly vs registering the filters/functions directly on the Twig environment?

@GwendolenLynch
Copy link

@fabpot We do it to keep a BC going ourselves … we plan to remove that for Bolt v4 (which should be Silex 2 & SF 3.x as well)

@fabpot
Copy link
Contributor

fabpot commented Oct 22, 2016

Can you have a look at #2200 and confirm it solves the issue?

fabpot added a commit that referenced this issue Oct 23, 2016
…ame class (fabpot)

This PR was merged into the 1.x branch.

Discussion
----------

fixed regression when registering two extensions with the same class

fixed #2165

Commits
-------

47432f3 fixed regression when registering two extensions having the same class name
@Tersoal
Copy link

Tersoal commented Oct 25, 2016

Now i can't replicate error. There are many commits after the error. I need
more time to check a fresh install of standard repo.

El 22 oct. 2016 12:30, "Bob den Otter" [email protected] escribió:

For the record, in Bolt we've had to lock the version at 1.25 too, as all
Bolt extensions that would add Twig functions or filters would break.

More information here: bolt/bolt#5868
bolt/bolt#5868


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#2165 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AGC5DjCBqvABfs3We8hHvWVh2XciwNEtks5q2eWtgaJpZM4KPZEh
.

@barryvdh
Copy link
Contributor

For reference; I also encountered problems when extendings extensions. Not directly related to Twig itself, but more to the twig-bridge. Until 1.24, it was possible to extend an Extension and use the same name. This worked fine when the nodes etc just referenced then name (eg. getExtension('form')) but now the full class name is used. So Barry\FormExtension extends Symfony..\FormExtension will register just my own classname, but the underlying class will call for Symfony..\FormExtension which isn't registered (by that name).

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

No branches or pull requests