diff --git a/UPGRADE.md b/UPGRADE.md index 5f204be31be..a583a83fffc 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,18 @@ +# Upgrade to 2.16 + +## Changing the way how reflection-based mapping drivers report fields, deprecated the "old" mode + +In ORM 3.0, a change will be made regarding how the `AttributeDriver` reports field mappings. +This change is necessary to be able to detect (and reject) some invalid mapping configurations. + +To avoid surprises during 2.x upgrades, the new mode is opt-in. It can be activated on the +`AttributeDriver` and `AnnotationDriver` by setting the `$reportFieldsWhereDeclared` +constructor parameter to `true`. It will cause `MappingException`s to be thrown when invalid +configurations are detected. + +Not enabling the new mode will cause a deprecation notice to be raised. In ORM 3.0, +only the new mode will be available. + # Upgrade to 2.15 ## Deprecated configuring `JoinColumn` on the inverse side of one-to-one associations diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index aebd182d774..a9a637b8d80 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -164,7 +164,7 @@ public function setMetadataDriverImpl(MappingDriver $driverImpl) * * @return AnnotationDriver */ - public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationReader = true) + public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationReader = true, bool $reportFieldsWhereDeclared = false) { Deprecation::trigger( 'doctrine/orm', @@ -203,7 +203,8 @@ public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationRead return new AnnotationDriver( $reader, - (array) $paths + (array) $paths, + $reportFieldsWhereDeclared ); } diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index f7aec6e3bab..a8994f411ca 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -110,7 +110,7 @@ protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonS if ($parent) { $class->setInheritanceType($parent->inheritanceType); $class->setDiscriminatorColumn($parent->discriminatorColumn); - $class->setIdGeneratorType($parent->generatorType); + $this->inheritIdGeneratorMapping($class, $parent); $this->addInheritedFields($class, $parent); $this->addInheritedRelations($class, $parent); $this->addInheritedEmbeddedClasses($class, $parent); @@ -138,12 +138,8 @@ protected function doLoadMetadata($class, $parent, $rootEntityFound, array $nonS throw MappingException::reflectionFailure($class->getName(), $e); } - // If this class has a parent the id generator strategy is inherited. - // However this is only true if the hierarchy of parents contains the root entity, - // if it consists of mapped superclasses these don't necessarily include the id field. - if ($parent && $rootEntityFound) { - $this->inheritIdGeneratorMapping($class, $parent); - } else { + // Complete id generator mapping when the generator was declared/added in this class + if ($class->identifier && (! $parent || ! $parent->identifier)) { $this->completeIdGeneratorMapping($class); } diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index 9453db24ed7..8fdb4495b0f 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -34,6 +34,7 @@ class AnnotationDriver extends CompatibilityAnnotationDriver { use ColocatedMappingDriver; + use ReflectionBasedDriver; /** * The annotation reader. @@ -60,7 +61,7 @@ class AnnotationDriver extends CompatibilityAnnotationDriver * @param Reader $reader The AnnotationReader to use * @param string|string[]|null $paths One or multiple paths where mapping classes can be found. */ - public function __construct($reader, $paths = null) + public function __construct($reader, $paths = null, bool $reportFieldsWhereDeclared = false) { Deprecation::trigger( 'doctrine/orm', @@ -70,6 +71,17 @@ public function __construct($reader, $paths = null) $this->reader = $reader; $this->addPaths((array) $paths); + + if (! $reportFieldsWhereDeclared) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/10455', + 'In ORM 3.0, the AttributeDriver will report fields for the classes where they are declared. This may uncover invalid mapping configurations. To opt into the new mode also with the AnnotationDriver today, set the "reportFieldsWhereDeclared" constructor parameter to true.', + self::class + ); + } + + $this->reportFieldsWhereDeclared = $reportFieldsWhereDeclared; } /** @@ -348,15 +360,7 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad // Evaluate annotations on properties/fields foreach ($class->getProperties() as $property) { - if ( - $metadata->isMappedSuperclass && ! $property->isPrivate() - || - $metadata->isInheritedField($property->name) - || - $metadata->isInheritedAssociation($property->name) - || - $metadata->isInheritedEmbeddedClass($property->name) - ) { + if ($this->isRepeatedPropertyDeclaration($property, $metadata)) { continue; } diff --git a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php index 4b5d2a20f8d..d63e7b40edb 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AttributeDriver.php @@ -30,6 +30,7 @@ class AttributeDriver extends CompatibilityAnnotationDriver { use ColocatedMappingDriver; + use ReflectionBasedDriver; private const ENTITY_ATTRIBUTE_CLASSES = [ Mapping\Entity::class => 1, @@ -53,7 +54,7 @@ class AttributeDriver extends CompatibilityAnnotationDriver protected $reader; /** @param array $paths */ - public function __construct(array $paths) + public function __construct(array $paths, bool $reportFieldsWhereDeclared = false) { if (PHP_VERSION_ID < 80000) { throw new LogicException(sprintf( @@ -73,6 +74,17 @@ public function __construct(array $paths) self::class ); } + + if (! $reportFieldsWhereDeclared) { + Deprecation::trigger( + 'doctrine/orm', + 'https://github.com/doctrine/orm/pull/10455', + 'In ORM 3.0, the AttributeDriver will report fields for the classes where they are declared. This may uncover invalid mapping configurations. To opt into the new mode today, set the "reportFieldsWhereDeclared" constructor parameter to true.', + self::class + ); + } + + $this->reportFieldsWhereDeclared = $reportFieldsWhereDeclared; } /** @@ -298,15 +310,8 @@ public function loadMetadataForClass($className, PersistenceClassMetadata $metad foreach ($reflectionClass->getProperties() as $property) { assert($property instanceof ReflectionProperty); - if ( - $metadata->isMappedSuperclass && ! $property->isPrivate() - || - $metadata->isInheritedField($property->name) - || - $metadata->isInheritedAssociation($property->name) - || - $metadata->isInheritedEmbeddedClass($property->name) - ) { + + if ($this->isRepeatedPropertyDeclaration($property, $metadata)) { continue; } diff --git a/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php b/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php new file mode 100644 index 00000000000..e42aab7b9cc --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/Driver/ReflectionBasedDriver.php @@ -0,0 +1,54 @@ +reportFieldsWhereDeclared) { + return $metadata->isMappedSuperclass && ! $property->isPrivate() + || $metadata->isInheritedField($property->name) + || $metadata->isInheritedAssociation($property->name) + || $metadata->isInheritedEmbeddedClass($property->name); + } + + $declaringClass = $property->getDeclaringClass()->getName(); + + if ( + isset($metadata->fieldMappings[$property->name]['declared']) + && $metadata->fieldMappings[$property->name]['declared'] === $declaringClass + ) { + return true; + } + + if ( + isset($metadata->associationMappings[$property->name]['declared']) + && $metadata->associationMappings[$property->name]['declared'] === $declaringClass + ) { + return true; + } + + return isset($metadata->embeddedClasses[$property->name]['declared']) + && $metadata->embeddedClasses[$property->name]['declared'] === $declaringClass; + } +} diff --git a/lib/Doctrine/ORM/ORMSetup.php b/lib/Doctrine/ORM/ORMSetup.php index 88a5dbddee7..1039ce82004 100644 --- a/lib/Doctrine/ORM/ORMSetup.php +++ b/lib/Doctrine/ORM/ORMSetup.php @@ -63,7 +63,8 @@ public static function createAnnotationMetadataConfiguration( */ public static function createDefaultAnnotationDriver( array $paths = [], - ?CacheItemPoolInterface $cache = null + ?CacheItemPoolInterface $cache = null, + bool $reportFieldsWhereDeclared = false ): AnnotationDriver { Deprecation::trigger( 'doctrine/orm', @@ -89,7 +90,7 @@ public static function createDefaultAnnotationDriver( $reader = new PsrCachedReader($reader, $cache); } - return new AnnotationDriver($reader, $paths); + return new AnnotationDriver($reader, $paths, $reportFieldsWhereDeclared); } /** diff --git a/tests/Doctrine/Tests/DoctrineTestCase.php b/tests/Doctrine/Tests/DoctrineTestCase.php index 3c286b7e6bd..89a852f1573 100644 --- a/tests/Doctrine/Tests/DoctrineTestCase.php +++ b/tests/Doctrine/Tests/DoctrineTestCase.php @@ -21,6 +21,7 @@ abstract class DoctrineTestCase extends TestCase 'assertMatchesRegularExpression' => 'assertRegExp', // can be removed when PHPUnit 9 is minimum 'assertDoesNotMatchRegularExpression' => 'assertNotRegExp', // can be removed when PHPUnit 9 is minimum 'assertFileDoesNotExist' => 'assertFileNotExists', // can be removed PHPUnit 9 is minimum + 'expectExceptionMessageMatches' => 'expectExceptionMessageRegExp', // can be removed when PHPUnit 8 is minimum ]; /** diff --git a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php index 7c13d50700b..82fb0f5fdd7 100644 --- a/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php +++ b/tests/Doctrine/Tests/Models/Company/CompanyFlexContract.php @@ -11,8 +11,6 @@ use Doctrine\ORM\Mapping\Entity; use Doctrine\ORM\Mapping\EntityResult; use Doctrine\ORM\Mapping\FieldResult; -use Doctrine\ORM\Mapping\GeneratedValue; -use Doctrine\ORM\Mapping\Id; use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; use Doctrine\ORM\Mapping\ManyToMany; @@ -67,14 +65,6 @@ #[ORM\Entity] class CompanyFlexContract extends CompanyContract { - /** - * @Id - * @GeneratedValue - * @Column(type="integer") - * @var int - */ - public $id; - /** * @Column(type="integer") * @var int diff --git a/tests/Doctrine/Tests/ORM/ConfigurationTest.php b/tests/Doctrine/Tests/ORM/ConfigurationTest.php index 2482d785bc2..397666e3e52 100644 --- a/tests/Doctrine/Tests/ORM/ConfigurationTest.php +++ b/tests/Doctrine/Tests/ORM/ConfigurationTest.php @@ -101,7 +101,7 @@ public function testNewDefaultAnnotationDriver(): void $paths = [__DIR__]; $reflectionClass = new ReflectionClass(ConfigurationTestAnnotationReaderChecker::class); - $annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths, false); + $annotationDriver = $this->configuration->newDefaultAnnotationDriver($paths, false, true); $reader = $annotationDriver->getReader(); $annotation = $reader->getMethodAnnotation( $reflectionClass->getMethod('namespacedAnnotationMethod'), diff --git a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php index 3da2ea5f4ff..f253266bc7a 100644 --- a/tests/Doctrine/Tests/ORM/Functional/EnumTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/EnumTest.php @@ -36,7 +36,7 @@ public function setUp(): void { parent::setUp(); - $this->_em = $this->getEntityManager(null, new AttributeDriver([dirname(__DIR__, 2) . '/Models/Enums'])); + $this->_em = $this->getEntityManager(null, new AttributeDriver([dirname(__DIR__, 2) . '/Models/Enums'], true)); $this->_schemaTool = new SchemaTool($this->_em); if ($this->isSecondLevelCacheEnabled) { diff --git a/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php b/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php index 49769a3d576..49e6425a5f3 100644 --- a/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/MergeProxiesTest.php @@ -242,7 +242,9 @@ private function createEntityManager(): EntityManagerInterface TestUtil::configureProxies($config); $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver( - [realpath(__DIR__ . '/../../Models/Cache')] + [realpath(__DIR__ . '/../../Models/Cache')], + null, + true )); // always runs on sqlite to prevent multi-connection race-conditions with the test suite diff --git a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php b/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php index 17aa2306df6..2aa53a00212 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ReadonlyPropertiesTest.php @@ -26,7 +26,8 @@ protected function setUp(): void } $this->_em = $this->getEntityManager(null, new AttributeDriver( - [dirname(__DIR__, 2) . '/Models/ReadonlyProperties'] + [dirname(__DIR__, 2) . '/Models/ReadonlyProperties'], + true )); $this->_schemaTool = new SchemaTool($this->_em); diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php index 48e6b5cd16a..b0d08902e9f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC719Test.php @@ -31,7 +31,7 @@ public function testIsEmptySqlGeneration(): void { $q = $this->_em->createQuery('SELECT g, c FROM Doctrine\Tests\ORM\Functional\Ticket\DDC719Group g LEFT JOIN g.children c WHERE g.parents IS EMPTY'); - $referenceSQL = 'SELECT g0_.name AS name_0, g0_.description AS description_1, g0_.id AS id_2, g1_.name AS name_3, g1_.description AS description_4, g1_.id AS id_5 FROM groups g0_ LEFT JOIN groups_groups g2_ ON g0_.id = g2_.parent_id LEFT JOIN groups g1_ ON g1_.id = g2_.child_id WHERE (SELECT COUNT(*) FROM groups_groups g3_ WHERE g3_.child_id = g0_.id) = 0'; + $referenceSQL = 'SELECT g0_.id AS id_0, g0_.name AS name_1, g0_.description AS description_2, g1_.id as id_3, g1_.name AS name_4, g1_.description AS description_5 FROM groups g0_ LEFT JOIN groups_groups g2_ ON g0_.id = g2_.parent_id LEFT JOIN groups g1_ ON g1_.id = g2_.child_id WHERE (SELECT COUNT(*) FROM groups_groups g3_ WHERE g3_.child_id = g0_.id) = 0'; self::assertEquals( strtolower($referenceSQL), diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10450Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10450Test.php new file mode 100644 index 00000000000..c522049f820 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10450Test.php @@ -0,0 +1,181 @@ +getTestEntityManager(); + + $this->expectException(MappingException::class); + + $em->getClassMetadata($className); + } + + public function classesThatOverrideFieldNames(): Generator + { + yield 'Entity class that redeclares a private field inherited from a base entity' => [GH10450EntityChildPrivate::class]; + yield 'Entity class that redeclares a private field inherited from a mapped superclass' => [GH10450MappedSuperclassChildPrivate::class]; + yield 'Entity class that redeclares a protected field inherited from a base entity' => [GH10450EntityChildProtected::class]; + yield 'Entity class that redeclares a protected field inherited from a mapped superclass' => [GH10450MappedSuperclassChildProtected::class]; + } +} + +/** + * @ORM\Entity + * @ORM\InheritanceType("JOINED") + * @ORM\DiscriminatorMap({ "base": "GH10450BaseEntityPrivate", "child": "GH10450EntityChildPrivate" }) + * @ORM\DiscriminatorColumn(name="type") + */ +class GH10450BaseEntityPrivate +{ + /** + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue + * + * @var int + */ + private $id; + + /** + * @ORM\Column(type="text", name="base") + * + * @var string + */ + private $field; +} + +/** + * @ORM\Entity + */ +class GH10450EntityChildPrivate extends GH10450BaseEntityPrivate +{ + /** + * @ORM\Column(type="text", name="child") + * + * @var string + */ + private $field; +} + +/** + * @ORM\MappedSuperclass + */ +class GH10450BaseMappedSuperclassPrivate +{ + /** + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue + * + * @var int + */ + private $id; + + /** + * @ORM\Column(type="text", name="base") + * + * @var string + */ + private $field; +} + +/** + * @ORM\Entity + */ +class GH10450MappedSuperclassChildPrivate extends GH10450BaseMappedSuperclassPrivate +{ + /** + * @ORM\Column(type="text", name="child") + * + * @var string + */ + private $field; +} + +/** + * @ORM\Entity + * @ORM\InheritanceType("JOINED") + * @ORM\DiscriminatorMap({ "base": "GH10450BaseEntityProtected", "child": "GH10450EntityChildProtected" }) + * @ORM\DiscriminatorColumn(name="type") + */ +class GH10450BaseEntityProtected +{ + /** + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue + * + * @var int + */ + protected $id; + + /** + * @ORM\Column(type="text", name="base") + * + * @var string + */ + protected $field; +} + +/** + * @ORM\Entity + */ +class GH10450EntityChildProtected extends GH10450BaseEntityProtected +{ + /** + * @ORM\Column(type="text", name="child") + * + * @var string + */ + protected $field; +} + +/** + * @ORM\MappedSuperclass + */ +class GH10450BaseMappedSuperclassProtected +{ + /** + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue + * + * @var int + */ + protected $id; + + /** + * @ORM\Column(type="text", name="base") + * + * @var string + */ + protected $field; +} + +/** + * @ORM\Entity + */ +class GH10450MappedSuperclassChildProtected extends GH10450BaseMappedSuperclassProtected +{ + /** + * @ORM\Column(type="text", name="child") + * + * @var string + */ + protected $field; +} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10454Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10454Test.php new file mode 100644 index 00000000000..18b6553e0ad --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH10454Test.php @@ -0,0 +1,107 @@ +getTestEntityManager(); + + $this->expectException(MappingException::class); + $this->expectExceptionMessageMatches('/Property "field" .* was already declared, but it must be declared only once/'); + + $em->getClassMetadata($className); + } + + public function classesThatOverrideFieldNames(): Generator + { + yield 'Entity class that redeclares a protected field inherited from a base entity' => [GH10454EntityChildProtected::class]; + yield 'Entity class that redeclares a protected field inherited from a mapped superclass' => [GH10454MappedSuperclassChildProtected::class]; + } +} + +/** + * @ORM\Entity + * @ORM\InheritanceType("JOINED") + * @ORM\DiscriminatorMap({ "base": "GH10454BaseEntityProtected", "child": "GH10454EntityChildProtected" }) + * @ORM\DiscriminatorColumn(name="type") + */ +class GH10454BaseEntityProtected +{ + /** + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue + * + * @var int + */ + protected $id; + + /** + * @ORM\Column(type="text", name="base") + * + * @var string + */ + protected $field; +} + +/** + * @ORM\Entity + */ +class GH10454EntityChildProtected extends GH10454BaseEntityProtected +{ + /** + * @ORM\Column(type="text", name="child") + * + * @var string + */ + protected $field; +} + +/** + * @ORM\MappedSuperclass + */ +class GH10454BaseMappedSuperclassProtected +{ + /** + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue + * + * @var int + */ + protected $id; + + /** + * @ORM\Column(type="text", name="base") + * + * @var string + */ + protected $field; +} + +/** + * @ORM\Entity + */ +class GH10454MappedSuperclassChildProtected extends GH10454BaseMappedSuperclassProtected +{ + /** + * @ORM\Column(type="text", name="child") + * + * @var string + */ + protected $field; +} diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5998Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5998Test.php index 028bced80ba..ab031886124 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5998Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5998Test.php @@ -48,6 +48,7 @@ private function classTests($className): void $this->_em->persist($child->rel); $this->_em->flush(); $this->_em->clear(); + $id = $child->id; // Test find by rel $child = $this->_em->getRepository($className)->findOneBy(['rel' => $child->rel]); @@ -55,7 +56,7 @@ private function classTests($className): void $this->_em->clear(); // Test query by id with fetch join - $child = $this->_em->createQuery('SELECT t, r FROM ' . $className . ' t JOIN t.rel r WHERE t.id = 1')->getOneOrNullResult(); + $child = $this->_em->createQuery('SELECT t, r FROM ' . $className . ' t JOIN t.rel r WHERE t.id = ?0')->setParameter(0, $id)->getOneOrNullResult(); self::assertNotNull($child); // Test lock and update @@ -65,14 +66,15 @@ private function classTests($className): void $child->status = 0; }); $this->_em->clear(); - $child = $this->_em->getRepository($className)->find(1); + $child = $this->_em->getRepository($className)->find($id); + self::assertNotNull($child); self::assertEquals($child->firstName, 'Bob'); self::assertEquals($child->status, 0); // Test delete $this->_em->remove($child); $this->_em->flush(); - $child = $this->_em->getRepository($className)->find(1); + $child = $this->_em->getRepository($className)->find($id); self::assertNull($child); } } diff --git a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php index c9ea55ddb7a..43a9942fb3a 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AttributeDriverTest.php @@ -33,7 +33,7 @@ protected function loadDriver(): MappingDriver { $paths = []; - return new AttributeDriver($paths); + return new AttributeDriver($paths, true); } public function testNamedQuery(): void diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 6ed3aa7eab7..2214a9509e2 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -1164,7 +1164,7 @@ public function testMappedSuperclassAssociationJoin(): void { $this->assertSqlGeneration( 'SELECT f FROM Doctrine\Tests\Models\DirectoryTree\File f JOIN f.parentDirectory d WHERE f.id = ?1', - 'SELECT f0_.id AS id_0, f0_.extension AS extension_1, f0_.name AS name_2 FROM "file" f0_ INNER JOIN Directory d1_ ON f0_.parentDirectory_id = d1_.id WHERE f0_.id = ?' + 'SELECT f0_.id AS id_0, f0_.name AS name_1, f0_.extension AS extension_2 FROM "file" f0_ INNER JOIN Directory d1_ ON f0_.parentDirectory_id = d1_.id WHERE f0_.id = ?' ); } diff --git a/tests/Doctrine/Tests/OrmFunctionalTestCase.php b/tests/Doctrine/Tests/OrmFunctionalTestCase.php index c2054179d6f..368e2b6f71b 100644 --- a/tests/Doctrine/Tests/OrmFunctionalTestCase.php +++ b/tests/Doctrine/Tests/OrmFunctionalTestCase.php @@ -799,7 +799,7 @@ protected function getEntityManager( $mappingDriver ?? ORMSetup::createDefaultAnnotationDriver([ realpath(__DIR__ . '/Models/Cache'), realpath(__DIR__ . '/Models/GeoNames'), - ]) + ], null, true) ); $conn = $connection ?: static::$sharedConn; diff --git a/tests/Doctrine/Tests/OrmTestCase.php b/tests/Doctrine/Tests/OrmTestCase.php index f5741540613..2ac45922ca7 100644 --- a/tests/Doctrine/Tests/OrmTestCase.php +++ b/tests/Doctrine/Tests/OrmTestCase.php @@ -81,7 +81,7 @@ protected function getTestEntityManager(?Connection $connection = null): EntityM $config->setQueryCache(self::getSharedQueryCache()); $config->setMetadataDriverImpl(ORMSetup::createDefaultAnnotationDriver([ realpath(__DIR__ . '/Models/Cache'), - ])); + ], null, true)); if ($this->isSecondLevelCacheEnabled) { $cacheConfig = new CacheConfiguration();