asm89 / twig-cache-extension

The missing cache extension for Twig. Caching template fragments with Twig.
MIT License
388 stars 27 forks source link

Fixed bug: Invalid recognition of extension name on Twig >= 1.26 #46

Closed blackandred closed 4 years ago

blackandred commented 7 years ago

The "Asm89\Twig\CacheExtension\Extension" extension is not enabled.

I just did a composer update and spent a lot of time on figuring out why the application is not working. Then next day in the morning I just got an idea and it worked. Here is the patch.

The problem occurs when I'm using the emanueleminotto/twig-cache-bundle, it has a class that extends this one, and then probably the child class is registered as service.

blackandred commented 7 years ago

I now understood that this may be also fixed in the emanueleminotto/twig-cache-bundle. I don't know what solution would you preffer.

The second solution:

Put a method to the ProfilerExtension.php:

/**
     * @return string
     */
    public function getName()
    {
        return parent::class;
    }

https://github.com/EmanueleMinotto/TwigCacheBundle/blob/master/Twig/ProfilerExtension.php

buffcode commented 7 years ago

I fixed this by adding the following to config.yml:

services:
    asm89_cache:
      class: Asm89\Twig\CacheExtension\Extension
      arguments: ["@twig_cache.strategy.lifetime"]
      tags:
         - { name: twig.extension }
jamyouss commented 7 years ago

Have the same issue. Any news on this PR ?

itinance commented 7 years ago

I can confirm that this PR fixes the issue. I would appreciate it to merge this commit.

itinance commented 7 years ago

Any chances to get this merged in?

lenar commented 7 years ago

No?

trsteel88 commented 7 years ago

Using __CLASS__ resolves the issue. Can we get this merged?

mikemix commented 5 years ago

It's 2019 already lol.

asm89 commented 4 years ago

Seems this was worked around in various places in the meantime. I did just release 1.4.0 with the fix. :)