From 1ceb9199a736ce2416de1ca7d7eea0d590149ddb Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Mon, 19 Jun 2023 13:33:23 +0200 Subject: [PATCH 1/7] Revert "fix: Implement `createDatabasePlatformForVersion()` method in `TracingDriverForV32` class (#731)" This reverts commit 58ec9630deeb98a6be9c728d25fc9be22cdf63f5. --- .../Doctrine/DBAL/TracingDriverForV32.php | 16 --------- .../Doctrine/DBAL/TracingDriverForV32Test.php | 36 ------------------- 2 files changed, 52 deletions(-) diff --git a/src/Tracing/Doctrine/DBAL/TracingDriverForV32.php b/src/Tracing/Doctrine/DBAL/TracingDriverForV32.php index e7e5516d..769d5476 100644 --- a/src/Tracing/Doctrine/DBAL/TracingDriverForV32.php +++ b/src/Tracing/Doctrine/DBAL/TracingDriverForV32.php @@ -86,20 +86,4 @@ public function getExceptionConverter(): ExceptionConverter { return $this->decoratedDriver->getExceptionConverter(); } - - /** - * {@inheritdoc} - * - * @phpstan-param string $version - * - * @phpstan-return AbstractPlatform - */ - public function createDatabasePlatformForVersion($version): AbstractPlatform - { - if (method_exists($this->decoratedDriver, 'createDatabasePlatformForVersion')) { - return $this->decoratedDriver->createDatabasePlatformForVersion($version); - } - - return $this->getDatabasePlatform(); - } } diff --git a/tests/Tracing/Doctrine/DBAL/TracingDriverForV32Test.php b/tests/Tracing/Doctrine/DBAL/TracingDriverForV32Test.php index 76a1da24..c04ab171 100644 --- a/tests/Tracing/Doctrine/DBAL/TracingDriverForV32Test.php +++ b/tests/Tracing/Doctrine/DBAL/TracingDriverForV32Test.php @@ -109,40 +109,4 @@ public function testGetExceptionConverter(): void $this->assertSame($exceptionConverter, $driver->getExceptionConverter()); } - - public function testCreateDatabasePlatform(): void - { - $databasePlatform = $this->createMock(AbstractPlatform::class); - - $decoratedDriver = $this->createMock(DriverInterface::class); - $decoratedDriver->expects($this->once()) - ->method('getDatabasePlatform') - ->willReturn($databasePlatform); - - $driver = new TracingDriverForV32($this->connectionFactory, $decoratedDriver); - - $this->assertSame($databasePlatform, $driver->createDatabasePlatformForVersion('5.7')); - } - - public function testCreateDatabasePlatformForVersionWhenDriverDefinedCreateDatabasePlatformForVersion(): void - { - $databasePlatform = $this->createMock(AbstractPlatform::class); - - $decoratedDriver = $this->createMock(StubCreateDatabasePlatformForVersionDriver::class); - $decoratedDriver->expects($this->once()) - ->method('createDatabasePlatformForVersion') - ->with('5.7') - ->willReturn($databasePlatform); - - $driver = new TracingDriverForV32($this->connectionFactory, $decoratedDriver); - - $this->assertSame($databasePlatform, $driver->createDatabasePlatformForVersion('5.7')); - } -} - -if (interface_exists(DriverInterface::class)) { - interface StubCreateDatabasePlatformForVersionDriver extends DriverInterface - { - public function createDatabasePlatformForVersion(string $version): AbstractPlatform; - } } From f24234033851af11967e1bb0b96c429f03852b96 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Mon, 19 Jun 2023 13:33:31 +0200 Subject: [PATCH 2/7] Revert "Introduce TracingDriverForV32 for DBAL `>= 3.2` (#723)" This reverts commit 7d73be0e6f2ef65d1cf7a6595940bb3bbe2c233b. --- .github/workflows/tests.yaml | 12 -- composer.json | 2 +- phpstan-baseline.neon | 2 +- psalm-baseline.xml | 11 -- .../Doctrine/DBAL/TracingDriverForV32.php | 89 -------------- src/aliases.php | 9 +- tests/DoctrineTestCase.php | 7 -- tests/End2End/App/Command/MainCommand.php | 2 +- .../Doctrine/DBAL/TracingDriverForV32Test.php | 112 ------------------ .../Doctrine/DBAL/TracingDriverForV3Test.php | 4 +- .../DBAL/TracingStatementForV3Test.php | 3 - 11 files changed, 6 insertions(+), 247 deletions(-) delete mode 100644 src/Tracing/Doctrine/DBAL/TracingDriverForV32.php delete mode 100644 tests/Tracing/Doctrine/DBAL/TracingDriverForV32Test.php diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 4ca224fb..16c124ff 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -30,8 +30,6 @@ jobs: - 6.* dependencies: - highest - doctrine-dbal: - - highest exclude: - php: '7.2' symfony-version: 6.* @@ -43,18 +41,12 @@ jobs: - php: '7.2' symfony-version: 4.4.* dependencies: lowest - doctrine-dbal: '^2.13' - php: '7.2' symfony-version: 5.* dependencies: lowest - doctrine-dbal: '^2.13' - php: '8.0' symfony-version: 6.* dependencies: lowest - doctrine-dbal: '^2.13' - - php: '8.0' - symfony-version: 6.* - doctrine-dbal: '<3.2' steps: - name: Checkout @@ -76,10 +68,6 @@ jobs: run: composer require --dev phpunit/phpunit ^9.3.9 --no-update if: matrix.php == '8.0' && matrix.dependencies == 'lowest' - - name: Update Doctrine DBAL - run: composer require --dev doctrine/dbal "${{ matrix.doctrine-dbal }}" --no-update - if: matrix.doctrine-dbal != 'highest' - - name: Install dependencies uses: ramsey/composer-install@v1 with: diff --git a/composer.json b/composer.json index 7a1dfde3..d3d00beb 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "require-dev": { "doctrine/dbal": "^2.13||^3.0", "doctrine/doctrine-bundle": "^1.12||^2.5", - "friendsofphp/php-cs-fixer": "^2.19||<=3.16.0", + "friendsofphp/php-cs-fixer": "^2.19||^3.6", "jangregor/phpstan-prophecy": "^1.0", "monolog/monolog": "^1.3||^2.0", "phpspec/prophecy": "!=1.11.0", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2b4858f5..ee3ce335 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -231,7 +231,7 @@ parameters: path: src/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnection.php - - message: "#^Parameter \\#2 \\$callback of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\AbstractTracingStatement\\:\\:traceFunction\\(\\) expects callable\\(mixed \\.\\.\\.\\)\\: Doctrine\\\\DBAL\\\\Driver\\\\Result, array\\{Doctrine\\\\DBAL\\\\Driver\\\\Statement, 'execute'\\} given\\.$#" + message: "#^Parameter \\#2 \\$callback of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\AbstractTracingStatement\\:\\:traceFunction\\(\\) expects callable\\(\\.\\.\\.mixed\\)\\: Doctrine\\\\DBAL\\\\Driver\\\\Result, array\\{Doctrine\\\\DBAL\\\\Driver\\\\Statement, 'execute'\\} given\\.$#" count: 1 path: src/Tracing/Doctrine/DBAL/TracingStatementForV3.php diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 702f2f01..32016223 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -50,17 +50,6 @@ $params - - - $this->decoratedDriver->getSchemaManager($conn, $platform) - - - AbstractSchemaManager<T> - - - $params - - toStream diff --git a/src/Tracing/Doctrine/DBAL/TracingDriverForV32.php b/src/Tracing/Doctrine/DBAL/TracingDriverForV32.php deleted file mode 100644 index 769d5476..00000000 --- a/src/Tracing/Doctrine/DBAL/TracingDriverForV32.php +++ /dev/null @@ -1,89 +0,0 @@ -= 3.2. - * - * @internal - * - * @phpstan-import-type Params from \Doctrine\DBAL\DriverManager as ConnectionParams - */ -final class TracingDriverForV32 implements Driver -{ - /** - * @var TracingDriverConnectionFactoryInterface The connection factory - */ - private $connectionFactory; - - /** - * @var Driver The instance of the decorated driver - */ - private $decoratedDriver; - - /** - * Constructor. - * - * @param TracingDriverConnectionFactoryInterface $connectionFactory The connection factory - * @param Driver $decoratedDriver The instance of the driver to decorate - */ - public function __construct(TracingDriverConnectionFactoryInterface $connectionFactory, Driver $decoratedDriver) - { - $this->connectionFactory = $connectionFactory; - $this->decoratedDriver = $decoratedDriver; - } - - /** - * {@inheritdoc} - * - * @phpstan-param ConnectionParams $params - */ - public function connect(array $params): TracingDriverConnectionInterface - { - return $this->connectionFactory->create( - $this->decoratedDriver->connect($params), - $this->decoratedDriver->getDatabasePlatform(), - $params - ); - } - - /** - * {@inheritdoc} - */ - public function getDatabasePlatform(): AbstractPlatform - { - return $this->decoratedDriver->getDatabasePlatform(); - } - - /** - * {@inheritdoc} - * - * @phpstan-template T of AbstractPlatform - * - * @phpstan-param T $platform - * - * @phpstan-return AbstractSchemaManager - */ - public function getSchemaManager(Connection $conn, AbstractPlatform $platform): AbstractSchemaManager - { - return $this->decoratedDriver->getSchemaManager($conn, $platform); - } - - /** - * {@inheritdoc} - */ - public function getExceptionConverter(): ExceptionConverter - { - return $this->decoratedDriver->getExceptionConverter(); - } -} diff --git a/src/aliases.php b/src/aliases.php index 4f2ede6f..839a55c9 100644 --- a/src/aliases.php +++ b/src/aliases.php @@ -4,7 +4,6 @@ namespace Sentry\SentryBundle; -use Doctrine\DBAL\Exception\SchemaDoesNotExist; use Doctrine\DBAL\Result; use Sentry\SentryBundle\Tracing\Cache\TraceableCacheAdapter; use Sentry\SentryBundle\Tracing\Cache\TraceableCacheAdapterForV2; @@ -15,7 +14,6 @@ use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriver; use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverForV2; use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverForV3; -use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingDriverForV32; use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatement; use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatementForV2; use Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingStatementForV3; @@ -55,12 +53,7 @@ class_alias(TraceableTagAwareCacheAdapterForV2::class, TraceableTagAwareCacheAda if (!class_exists(TracingStatement::class)) { if (class_exists(Result::class)) { class_alias(TracingStatementForV3::class, TracingStatement::class); - - if (class_exists(SchemaDoesNotExist::class)) { - class_alias(TracingDriverForV32::class, TracingDriver::class); - } else { - class_alias(TracingDriverForV3::class, TracingDriver::class); - } + class_alias(TracingDriverForV3::class, TracingDriver::class); } elseif (interface_exists(Result::class)) { class_alias(TracingStatementForV2::class, TracingStatement::class); class_alias(TracingDriverForV2::class, TracingDriver::class); diff --git a/tests/DoctrineTestCase.php b/tests/DoctrineTestCase.php index 5d581cda..6d4c7626 100644 --- a/tests/DoctrineTestCase.php +++ b/tests/DoctrineTestCase.php @@ -7,7 +7,6 @@ use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\ResultStatement; -use Doctrine\DBAL\Exception\SchemaDoesNotExist; use PHPUnit\Framework\TestCase; abstract class DoctrineTestCase extends TestCase @@ -29,12 +28,6 @@ protected static function isDoctrineDBALVersion3Installed(): bool && !self::isDoctrineDBALVersion2Installed(); } - protected static function isDoctrineDBALVersion32Installed(): bool - { - return self::isDoctrineDBALInstalled() - && class_exists(SchemaDoesNotExist::class); - } - protected static function isDoctrineBundlePackageInstalled(): bool { return class_exists(DoctrineBundle::class); diff --git a/tests/End2End/App/Command/MainCommand.php b/tests/End2End/App/Command/MainCommand.php index 0196438e..5f5ad4fe 100644 --- a/tests/End2End/App/Command/MainCommand.php +++ b/tests/End2End/App/Command/MainCommand.php @@ -11,7 +11,7 @@ class MainCommand extends Command { - protected function configure(): void + protected function configure() { $this ->addOption('option1', null, InputOption::VALUE_NONE) diff --git a/tests/Tracing/Doctrine/DBAL/TracingDriverForV32Test.php b/tests/Tracing/Doctrine/DBAL/TracingDriverForV32Test.php deleted file mode 100644 index c04ab171..00000000 --- a/tests/Tracing/Doctrine/DBAL/TracingDriverForV32Test.php +++ /dev/null @@ -1,112 +0,0 @@ -= 3.2.'); - } - } - - protected function setUp(): void - { - $this->connectionFactory = $this->createMock(TracingDriverConnectionFactoryInterface::class); - } - - public function testConnect(): void - { - $params = ['host' => 'localhost']; - $databasePlatform = $this->createMock(AbstractPlatform::class); - $driverConnection = $this->createMock(DriverConnectionInterface::class); - $tracingDriverConnection = $this->createMock(TracingDriverConnectionInterface::class); - $decoratedDriver = $this->createMock(DriverInterface::class); - - $decoratedDriver->expects($this->once()) - ->method('connect') - ->with($params) - ->willReturn($driverConnection); - - $decoratedDriver->expects($this->once()) - ->method('getDatabasePlatform') - ->willReturn($databasePlatform); - - $this->connectionFactory->expects($this->once()) - ->method('create') - ->with($driverConnection, $databasePlatform, $params) - ->willReturn($tracingDriverConnection); - - $driver = new TracingDriverForV32($this->connectionFactory, $decoratedDriver); - - $this->assertSame($tracingDriverConnection, $driver->connect($params)); - } - - public function testGetDatabasePlatform(): void - { - $databasePlatform = $this->createMock(AbstractPlatform::class); - - $decoratedDriver = $this->createMock(DriverInterface::class); - $decoratedDriver->expects($this->once()) - ->method('getDatabasePlatform') - ->willReturn($databasePlatform); - - $driver = new TracingDriverForV32($this->connectionFactory, $decoratedDriver); - - $this->assertSame($databasePlatform, $driver->getDatabasePlatform()); - } - - /** - * @group legacy - */ - public function testGetSchemaManager(): void - { - $connection = $this->createMock(Connection::class); - $databasePlatform = $this->createMock(AbstractPlatform::class); - $schemaManager = $this->createMock(AbstractSchemaManager::class); - - $decoratedDriver = $this->createMock(DriverInterface::class); - $decoratedDriver->expects($this->once()) - ->method('getSchemaManager') - ->with($connection, $databasePlatform) - ->willReturn($schemaManager); - - $driver = new TracingDriverForV32($this->connectionFactory, $decoratedDriver); - - $this->assertSame($schemaManager, $driver->getSchemaManager($connection, $databasePlatform)); - } - - public function testGetExceptionConverter(): void - { - $exceptionConverter = $this->createMock(ExceptionConverter::class); - - $decoratedDriver = $this->createMock(DriverInterface::class); - $decoratedDriver->expects($this->once()) - ->method('getExceptionConverter') - ->willReturn($exceptionConverter); - - $driver = new TracingDriverForV32($this->connectionFactory, $decoratedDriver); - - $this->assertSame($exceptionConverter, $driver->getExceptionConverter()); - } -} diff --git a/tests/Tracing/Doctrine/DBAL/TracingDriverForV3Test.php b/tests/Tracing/Doctrine/DBAL/TracingDriverForV3Test.php index 68291e55..af3a857b 100644 --- a/tests/Tracing/Doctrine/DBAL/TracingDriverForV3Test.php +++ b/tests/Tracing/Doctrine/DBAL/TracingDriverForV3Test.php @@ -26,8 +26,8 @@ final class TracingDriverForV3Test extends DoctrineTestCase public static function setUpBeforeClass(): void { - if (!self::isDoctrineDBALVersion3Installed() || self::isDoctrineDBALVersion32Installed()) { - self::markTestSkipped('This test requires the version of the "doctrine/dbal" Composer package to be >= 3.0 <= 3.2.'); + if (!self::isDoctrineDBALVersion3Installed()) { + self::markTestSkipped('This test requires the version of the "doctrine/dbal" Composer package to be >= 3.0.'); } } diff --git a/tests/Tracing/Doctrine/DBAL/TracingStatementForV3Test.php b/tests/Tracing/Doctrine/DBAL/TracingStatementForV3Test.php index 653b7d87..566b178a 100644 --- a/tests/Tracing/Doctrine/DBAL/TracingStatementForV3Test.php +++ b/tests/Tracing/Doctrine/DBAL/TracingStatementForV3Test.php @@ -55,9 +55,6 @@ public function testBindValue(): void $this->assertTrue($this->statement->bindValue('foo', 'bar', ParameterType::INTEGER)); } - /** - * @group legacy - */ public function testBindParam(): void { $variable = 'bar'; From 2ac9e1f49281185b39b163a7d58c407506a1e71e Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Mon, 19 Jun 2023 13:37:27 +0200 Subject: [PATCH 3/7] Update phpstan-baseline.neon --- phpstan-baseline.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ee3ce335..2b4858f5 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -231,7 +231,7 @@ parameters: path: src/Tracing/Doctrine/DBAL/TracingServerInfoAwareDriverConnection.php - - message: "#^Parameter \\#2 \\$callback of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\AbstractTracingStatement\\:\\:traceFunction\\(\\) expects callable\\(\\.\\.\\.mixed\\)\\: Doctrine\\\\DBAL\\\\Driver\\\\Result, array\\{Doctrine\\\\DBAL\\\\Driver\\\\Statement, 'execute'\\} given\\.$#" + message: "#^Parameter \\#2 \\$callback of method Sentry\\\\SentryBundle\\\\Tracing\\\\Doctrine\\\\DBAL\\\\AbstractTracingStatement\\:\\:traceFunction\\(\\) expects callable\\(mixed \\.\\.\\.\\)\\: Doctrine\\\\DBAL\\\\Driver\\\\Result, array\\{Doctrine\\\\DBAL\\\\Driver\\\\Statement, 'execute'\\} given\\.$#" count: 1 path: src/Tracing/Doctrine/DBAL/TracingStatementForV3.php From 86751f197683d90f1b3eec4c60b7ba3f3c477cb2 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Mon, 19 Jun 2023 13:40:38 +0200 Subject: [PATCH 4/7] Update CHANGELOG.md --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17ec04ba..40e4c688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 4.9.2 + +The Sentry SDK team is happy to announce the immediate availability of Sentry Symfony SDK v4.9.2. + +### Bug Fixes + +- We decided to revert two previous PRs that aimed to remove deprecation warnings during test runs [(#736)](https://github.com/getsentry/sentry-symfony/pull/736) + + - Revert: Add a new Doctrine DBAL tracing driver that does not implement the deprecated `VersionAwarePlatformDriver` [(#723)](https://github.com/getsentry/sentry-symfony/pull/723) + - Revert: Fix a regression in `TracingDriverForV32` by adding `VersionAwarePlatformDriver::createDatabasePlatformForVersion` [(#731)](https://github.com/getsentry/sentry-symfony/pull/731) + +We are sorry for the inconvenience caused by these changes. + ## 4.9.1 The Sentry SDK team is happy to announce the immediate availability of Sentry Symfony SDK v4.9.1. From acc26efa63656d2c47f80fc6e5669362efe2c2a9 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Mon, 19 Jun 2023 13:42:29 +0200 Subject: [PATCH 5/7] Pin friendsofphp/php-cs-fixer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d3d00beb..29d06414 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "require-dev": { "doctrine/dbal": "^2.13||^3.0", "doctrine/doctrine-bundle": "^1.12||^2.5", - "friendsofphp/php-cs-fixer": "^2.19||^3.6", + "friendsofphp/php-cs-fixer": "^2.19||<=3.16", "jangregor/phpstan-prophecy": "^1.0", "monolog/monolog": "^1.3||^2.0", "phpspec/prophecy": "!=1.11.0", From a31973089679f3199746ad1ab3f9a6fd83081268 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Mon, 19 Jun 2023 13:47:55 +0200 Subject: [PATCH 6/7] Add return type --- tests/End2End/App/Command/MainCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/End2End/App/Command/MainCommand.php b/tests/End2End/App/Command/MainCommand.php index 5f5ad4fe..0196438e 100644 --- a/tests/End2End/App/Command/MainCommand.php +++ b/tests/End2End/App/Command/MainCommand.php @@ -11,7 +11,7 @@ class MainCommand extends Command { - protected function configure() + protected function configure(): void { $this ->addOption('option1', null, InputOption::VALUE_NONE) From 43cfa13c9c6233c34d4863e08ef20d53425f29d5 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Mon, 19 Jun 2023 13:52:41 +0200 Subject: [PATCH 7/7] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 29d06414..7a1dfde3 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "require-dev": { "doctrine/dbal": "^2.13||^3.0", "doctrine/doctrine-bundle": "^1.12||^2.5", - "friendsofphp/php-cs-fixer": "^2.19||<=3.16", + "friendsofphp/php-cs-fixer": "^2.19||<=3.16.0", "jangregor/phpstan-prophecy": "^1.0", "monolog/monolog": "^1.3||^2.0", "phpspec/prophecy": "!=1.11.0",