Files
Nicolas Grekas bd939c8c3a Fix wrapping the Twig cache pool in a second tag aware adapter
The ".twig.cache.inner" pool is a child of "cache.app". When the application
configures a natively tag aware adapter for it (redis, valkey, pdo or mongodb),
the child pool is already tag aware and decorating it with a TagAwareAdapter
turns every read into a miss.

Alias "twig.cache" to the pool in that case, the way Symfony aliases
"cache.app.taggable" to "cache.app" instead of decorating it. The pool keeps
its own namespace, so it does not start sharing the application pool's one, and
the decorator stays in place for the plain adapters that need it.
2026-09-11 10:59:50 +02:00

47 lines
1.6 KiB
PHP

<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Twig\Extra\TwigExtraBundle;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\HttpKernel\KernelInterface;
use Twig\Extra\TwigExtraBundle\DependencyInjection\Compiler\MissingExtensionSuggestorPass;
use Twig\Extra\TwigExtraBundle\DependencyInjection\Compiler\TwigCachePoolPass;
if (method_exists(KernelInterface::class, 'getShareDir')) {
class TwigExtraBundle extends Bundle
{
public function build(ContainerBuilder $container): void
{
parent::build($container);
$container->addCompilerPass(new MissingExtensionSuggestorPass());
// priority 64 so that it runs before Symfony's CachePoolPass (priority 32)
$container->addCompilerPass(new TwigCachePoolPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 64);
}
}
} else {
class TwigExtraBundle extends Bundle
{
/** @return void */
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new MissingExtensionSuggestorPass());
// priority 64 so that it runs before Symfony's CachePoolPass (priority 32)
$container->addCompilerPass(new TwigCachePoolPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 64);
}
}
}