Skip to content

Commit f8ce15d

Browse files
authored
Avoid declaring the TracingStatement class alias if it already exists (#552)
1 parent 64b03f6 commit f8ce15d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix: Test if `TracingStatement` exists before attempting to create the class alias, otherwise it breaks when opcache is enabled. (#552)
6+
57
## 4.2.2 (2021-08-30)
68

79
- Fix missing instrumentation of the `Statement::execute()` method of Doctrine DBAL (#548)

src/aliases.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ class_alias(MiddlewareInterface::class, DoctrineMiddlewareInterface::class);
8787
class_alias(ExceptionConverterDriverInterface::class, LegacyExceptionConverterDriverInterface::class);
8888
}
8989

90-
if (class_exists(Result::class)) {
91-
class_alias(TracingStatementForV3::class, 'Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatement');
92-
} elseif (interface_exists(Result::class)) {
93-
class_alias(TracingStatementForV2::class, 'Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatement');
90+
if (!class_exists('Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatement')) {
91+
if (class_exists(Result::class)) {
92+
class_alias(TracingStatementForV3::class, 'Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatement');
93+
} elseif (interface_exists(Result::class)) {
94+
class_alias(TracingStatementForV2::class, 'Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatement');
95+
}
9496
}

0 commit comments

Comments
 (0)