diff --git a/CHANGELOG.md b/CHANGELOG.md index 75f2ba77..2de1b0e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Fix the CacheItem detection for tracing (#501) + ## 4.1.1 (2021-05-10) - Fix the conditions to automatically enable the cache instrumentation when possible (#487) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 09197422..259e4eb5 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -165,7 +165,7 @@ private function addDistributedTracingSection(ArrayNodeDefinition $rootNode): vo ->{class_exists(TwigBundle::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->end() ->arrayNode('cache') - ->{interface_exists(CacheItem::class) ? 'canBeDisabled' : 'canBeEnabled'}() + ->{class_exists(CacheItem::class) ? 'canBeDisabled' : 'canBeEnabled'}() ->end() ->end() ->end() diff --git a/src/DependencyInjection/SentryExtension.php b/src/DependencyInjection/SentryExtension.php index 3b496980..76a0dc52 100644 --- a/src/DependencyInjection/SentryExtension.php +++ b/src/DependencyInjection/SentryExtension.php @@ -224,7 +224,7 @@ private function registerCacheTracingConfiguration(ContainerBuilder $container, $isConfigEnabled = $this->isConfigEnabled($container, $config) && $this->isConfigEnabled($container, $config['cache']); - if ($isConfigEnabled && !interface_exists(CacheItem::class)) { + if ($isConfigEnabled && !class_exists(CacheItem::class)) { throw new LogicException('Cache tracing support cannot be enabled because the symfony/cache Composer package is not installed.'); } diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 07448565..26428d4a 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -48,7 +48,7 @@ public function testProcessConfigurationWithDefaultConfiguration(): void 'enabled' => class_exists(TwigBundle::class), ], 'cache' => [ - 'enabled' => interface_exists(CacheItem::class), + 'enabled' => class_exists(CacheItem::class), ], ], ];