Skip to content

Fix CacheItem detection #501

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

Merged
merged 2 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/SentryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testProcessConfigurationWithDefaultConfiguration(): void
'enabled' => class_exists(TwigBundle::class),
],
'cache' => [
'enabled' => interface_exists(CacheItem::class),
'enabled' => class_exists(CacheItem::class),
],
],
];
Expand Down