From a9438aea01b74aa8ec958b3fadd375f88d3550bb Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Sat, 10 Jan 2026 10:46:27 +0100 Subject: [PATCH 1/4] Fix typo in `dbal.connections.default_dbname` configuration --- src/DependencyInjection/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 196c8e942..10c9f5404 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -357,7 +357,7 @@ private function configureDbalDriverNode(ArrayNodeDefinition $node): void ->end() ->scalarNode('default_dbname') ->info( - 'Override the default database (postgres) to connect to for PostgreSQL connexion.', + 'Override the default database (postgres) to connect to for PostgreSQL connection.', ) ->end() ->scalarNode('sslmode') From 30e0f7336faf922f4f7adc0a91ff01d2c6dcb176 Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Fri, 23 Jan 2026 16:27:37 +0100 Subject: [PATCH 2/4] Fix attribute driver mapping pass compatibility with ORM 3 (#2120) --- .../Compiler/DoctrineOrmMappingsPass.php | 11 ++++++- .../Compiler/DoctrineOrmMappingsPassTest.php | 32 +++++++++++++++++++ tests/TestCase.php | 7 +++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php b/src/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php index 4ec6bd378..2ec6cb7ad 100644 --- a/src/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php +++ b/src/DependencyInjection/Compiler/DoctrineOrmMappingsPass.php @@ -16,6 +16,8 @@ use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; +use function method_exists; + /** * Class for Symfony bundles to configure mappings for model classes not in the * auto-mapped folder. @@ -177,7 +179,14 @@ public static function createAnnotationMappingDriver(array $namespaces, array $d */ public static function createAttributeMappingDriver(array $namespaces, array $directories, array $managerParameters = [], $enabledParameter = false, array $aliasMap = [], bool $reportFieldsWhereDeclared = false) { - $driver = new Definition(AttributeDriver::class, [$directories, $reportFieldsWhereDeclared]); + $driverArgs = [$directories]; + + // Add additional args for ORM <3.0 + if (method_exists(AttributeDriver::class, 'getReader')) { + $driverArgs[] = $reportFieldsWhereDeclared; + } + + $driver = new Definition(AttributeDriver::class, $driverArgs); return new DoctrineOrmMappingsPass($driver, $namespaces, $managerParameters, $enabledParameter, $aliasMap); } diff --git a/tests/DependencyInjection/Compiler/DoctrineOrmMappingsPassTest.php b/tests/DependencyInjection/Compiler/DoctrineOrmMappingsPassTest.php index 1736cef2a..ae992a50b 100644 --- a/tests/DependencyInjection/Compiler/DoctrineOrmMappingsPassTest.php +++ b/tests/DependencyInjection/Compiler/DoctrineOrmMappingsPassTest.php @@ -7,7 +7,15 @@ use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass; use Doctrine\Bundle\DoctrineBundle\Tests\TestCase; use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\Driver\AttributeDriver; +use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use PHPUnit\Framework\Attributes\IgnoreDeprecations; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +use function assert; +use function interface_exists; +use function realpath; class DoctrineOrmMappingsPassTest extends TestCase { @@ -31,4 +39,28 @@ public function testCreateAnnotationMappingDriverIsDeprecated(): void ['/path/to/entities'], ); } + + public function testAttributeDriverIsRegistered(): void + { + if (! interface_exists(EntityManagerInterface::class)) { + self::markTestSkipped('This test requires ORM'); + } + + $driverNamespace = 'DoctrineBundle\Entity'; + $container = $this->createXmlBundleTestContainer( + static function (ContainerBuilder $containerBuilder) use ($driverNamespace): void { + $containerBuilder->addCompilerPass(DoctrineOrmMappingsPass::createAttributeMappingDriver( + [$driverNamespace], + [realpath(__DIR__ . '/Entity')], + reportFieldsWhereDeclared: true, + )); + }, + ); + + $metadataDriver = $container->get('doctrine.orm.default_metadata_driver'); + assert($metadataDriver instanceof MappingDriverChain); + + $driver = $metadataDriver->getDrivers()[$driverNamespace]; + $this->assertTrue($driver instanceof AttributeDriver); + } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 137460c26..962e05730 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -22,7 +22,7 @@ class TestCase extends BaseTestCase { - public function createXmlBundleTestContainer(): ContainerBuilder + public function createXmlBundleTestContainer(callable|null $func = null): ContainerBuilder { $container = new ContainerBuilder(new ParameterBag([ 'kernel.debug' => false, @@ -90,6 +90,11 @@ public function createXmlBundleTestContainer(): ContainerBuilder $compilerPassConfig->addPass(new CacheCompatibilityPass()); // make all Doctrine services public, so we can fetch them in the test $compilerPassConfig->addPass(new TestCaseAllPublicCompilerPass()); + + if ($func !== null) { + $func($container); + } + $container->compile(); return $container; From 00f7a51136518abc53c1e5d617de849e38732e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 11 Feb 2026 20:28:26 +0100 Subject: [PATCH 3/4] Address PHPUnit deprecation Using with() on a stub is deprecated. We don't want to check that we call this object with 'doctrine', we just want to only return $mockDoctrine when it is called with 'doctrine' and nothing else. --- tests/Command/CreateDatabaseDoctrineTest.php | 2 +- tests/Command/DropDatabaseDoctrineTest.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/Command/CreateDatabaseDoctrineTest.php b/tests/Command/CreateDatabaseDoctrineTest.php index 113ee347e..700d935e5 100644 --- a/tests/Command/CreateDatabaseDoctrineTest.php +++ b/tests/Command/CreateDatabaseDoctrineTest.php @@ -77,7 +77,7 @@ private function getMockContainer(string $connectionName, array|null $params = n $mockContainer = $this->createStub(Container::class); - $mockContainer->method('get')->with('doctrine')->willReturn($mockDoctrine); + $mockContainer->method('get')->willReturnMap([['doctrine', $mockDoctrine]]); return $mockContainer; } diff --git a/tests/Command/DropDatabaseDoctrineTest.php b/tests/Command/DropDatabaseDoctrineTest.php index c691867ef..aa706c31f 100644 --- a/tests/Command/DropDatabaseDoctrineTest.php +++ b/tests/Command/DropDatabaseDoctrineTest.php @@ -156,8 +156,7 @@ private function getMockContainer(string $connectionName, array $params): Stub $mockContainer = $this->createStub(Container::class); $mockContainer->method('get') - ->with('doctrine') - ->willReturn($mockDoctrine); + ->willReturnMap([['doctrine', $mockDoctrine]]); return $mockContainer; } From 4f222e03bf170da679d9402c31da27453ca2e530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 11 Feb 2026 20:29:17 +0100 Subject: [PATCH 4/4] Add dev dependency on symfony/http-kernel Not having a version constraint for this package causes deprecations because it expects the framework bundle to define its extension by extending a non deprecated class, and that is not the case with v7 of that bundle. --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 4a0309ff0..a2688cbda 100644 --- a/composer.json +++ b/composer.json @@ -55,6 +55,7 @@ "psr/log": "^1.1.4 || ^2.0 || ^3.0", "symfony/doctrine-messenger": "^6.4 || ^7.0", "symfony/expression-language": "^6.4 || ^7.0", + "symfony/http-kernel": "^6.4 || ^7.0", "symfony/messenger": "^6.4 || ^7.0", "symfony/property-info": "^6.4 || ^7.0", "symfony/security-bundle": "^6.4 || ^7.0",