Closed
Description
Symfony version(s) affected: 4.4.1 (probably also 3.4 and 5.0)
Description
When using a cache adapter with tags: true
, and typehinting this adapter with TagAwareCacheInterface
instead of the CacheItemPoolInterface
(PSR-6), and running on env=dev or env=test, the TraceableAdapter
is not used, but instead the Symfony\Component\Cache\Adapter\TagAwareAdapter
is injected.
Because of this, the subsequent cache changes are not profiled.
How to reproduce
framework:
cache:
pools:
app.cache_pool:
adapters:
- cache.adapter.array
- cache.adapter.apcu
- cache.adapter.redis
tags: true
use Symfony\Contracts\Cache\TagAwareCacheInterface;
class TestController
{
/** @var TagAwareAdapterInterface */
private $appCachePool;
public function __construct(TagAwareCacheInterface $appCachePool)
{
echo get_class($appCachePool); // outputs Symfony\Component\Cache\Adapter\TagAwareAdapter
$this->cache = $appCachePool;
}
/** @Route("/test") */
public function test()
{
// works, but not in profiler
$this->cache->get('somkey', function (ItemInterface $item) {
$item->tag('sometag');
return true;
});
$this->cache->invalidateTags('sometag');
}
}
Possible Solution
Additional context
See also #34800