diff --git a/UPGRADE.md b/UPGRADE.md index 768e133648f..488fda55a0f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -21,6 +21,14 @@ Signatures of overridden methods should be changed accordingly Method `Doctrine\ORM\EntityManagerInterface#copy()` never got its implementation and is removed in 3.0. +## BC BREAK: Removed classes related to UUID and TABLE generator strategies + +The following classes have been removed: +- `Doctrine\ORM\Id\TableGenerator` +- `Doctrine\ORM\Id\UuidGenerator` + +Using the `UUID` strategy for generating identifiers is not supported anymore. + # Upgrade to 2.10 ## BC Break: Removed `TABLE` id generator strategy diff --git a/lib/Doctrine/ORM/Id/TableGenerator.php b/lib/Doctrine/ORM/Id/TableGenerator.php deleted file mode 100644 index c65b5272617..00000000000 --- a/lib/Doctrine/ORM/Id/TableGenerator.php +++ /dev/null @@ -1,83 +0,0 @@ -_tableName = $tableName; - $this->_sequenceName = $sequenceName; - $this->_allocationSize = $allocationSize; - } - - /** - * {@inheritDoc} - */ - public function generate( - EntityManager $em, - $entity - ) { - if ($this->_maxValue === null || $this->_nextValue === $this->_maxValue) { - // Allocate new values - $conn = $em->getConnection(); - - if ($conn->getTransactionNestingLevel() === 0) { - // use select for update - $sql = $conn->getDatabasePlatform()->getTableHiLoCurrentValSql($this->_tableName, $this->_sequenceName); - $currentLevel = $conn->fetchOne($sql); - - if ($currentLevel !== null) { - $this->_nextValue = $currentLevel; - $this->_maxValue = $this->_nextValue + $this->_allocationSize; - - $updateSql = $conn->getDatabasePlatform()->getTableHiLoUpdateNextValSql( - $this->_tableName, - $this->_sequenceName, - $this->_allocationSize - ); - - if ($conn->executeStatement($updateSql, [1 => $currentLevel, 2 => $currentLevel + 1]) !== 1) { - // no affected rows, concurrency issue, throw exception - } - } else { - // no current level returned, TableGenerator seems to be broken, throw exception - } - } else { - // only table locks help here, implement this or throw exception? - // or do we want to work with table locks exclusively? - } - } - - return $this->_nextValue++; - } -} diff --git a/lib/Doctrine/ORM/Id/UuidGenerator.php b/lib/Doctrine/ORM/Id/UuidGenerator.php deleted file mode 100644 index f6b87589378..00000000000 --- a/lib/Doctrine/ORM/Id/UuidGenerator.php +++ /dev/null @@ -1,47 +0,0 @@ -getConnection(); - $sql = 'SELECT ' . $conn->getDatabasePlatform()->getGuidExpression(); - - return $conn->executeQuery($sql)->fetchOne(); - } -} diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index c7fb339d453..f18f7cd7d37 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -17,10 +17,8 @@ use Doctrine\ORM\Id\BigIntegerIdentityGenerator; use Doctrine\ORM\Id\IdentityGenerator; use Doctrine\ORM\Id\SequenceGenerator; -use Doctrine\ORM\Id\UuidGenerator; use Doctrine\ORM\Mapping\Exception\CannotGenerateIds; use Doctrine\ORM\Mapping\Exception\InvalidCustomGenerator; -use Doctrine\ORM\Mapping\Exception\TableGeneratorNotImplementedYet; use Doctrine\ORM\Mapping\Exception\UnknownGeneratorType; use Doctrine\Persistence\Mapping\AbstractClassMetadataFactory; use Doctrine\Persistence\Mapping\ClassMetadata as ClassMetadataInterface; @@ -617,16 +615,6 @@ private function completeIdGeneratorMapping(ClassMetadataInfo $class): void $class->setIdGenerator(new AssignedGenerator()); break; - case ClassMetadata::GENERATOR_TYPE_UUID: - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/7312', - 'Mapping for %s: the "UUID" id generator strategy is deprecated with no replacement', - $class->name - ); - $class->setIdGenerator(new UuidGenerator()); - break; - case ClassMetadata::GENERATOR_TYPE_CUSTOM: $definition = $class->customGeneratorDefinition; if ($definition === null) { diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index c4e1c9e3094..39f66bb2751 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -14,7 +14,6 @@ use Doctrine\Deprecations\Deprecation; use Doctrine\Instantiator\Instantiator; use Doctrine\Instantiator\InstantiatorInterface; -use Doctrine\ORM\Cache\Exception\CacheException; use Doctrine\ORM\Cache\Exception\NonCacheableEntityAssociation; use Doctrine\ORM\Id\AbstractIdGenerator; use Doctrine\Persistence\Mapping\ClassMetadata; @@ -111,15 +110,6 @@ class ClassMetadataInfo implements ClassMetadata */ public const GENERATOR_TYPE_SEQUENCE = 2; - /** - * TABLE means a separate table is used for id generation. - * Offers full portability (in that it results in an exception being thrown - * no matter the platform). - * - * @deprecated no replacement planned - */ - public const GENERATOR_TYPE_TABLE = 3; - /** * IDENTITY means an identity column is used for id generation. The database * will fill in the id column on insertion. Platforms that do not support @@ -134,14 +124,6 @@ class ClassMetadataInfo implements ClassMetadata */ public const GENERATOR_TYPE_NONE = 5; - /** - * UUID means that a UUID/GUID expression is used for id generation. Full - * portability is currently not guaranteed. - * - * @deprecated use an application-side generator instead - */ - public const GENERATOR_TYPE_UUID = 6; - /** * CUSTOM means that customer will use own ID generator that supposedly work */ @@ -2231,18 +2213,6 @@ public function isIdGeneratorSequence() return $this->generatorType === self::GENERATOR_TYPE_SEQUENCE; } - /** - * Checks whether the class uses a table for id generation. - * - * @deprecated - * - * @return false - */ - public function isIdGeneratorTable() - { - return false; - } - /** * Checks whether the class has a natural identifier/pk (which means it does * not use any Id generator. @@ -2254,16 +2224,6 @@ public function isIdentifierNatural() return $this->generatorType === self::GENERATOR_TYPE_NONE; } - /** - * Checks whether the class use a UUID for id generation. - * - * @return bool - */ - public function isIdentifierUuid() - { - return $this->generatorType === self::GENERATOR_TYPE_UUID; - } - /** * Gets the type of a field. * diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index 086a3baf879..a65412dae7b 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -5,12 +5,7 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\Common\Annotations\AnnotationReader; -use Doctrine\Common\Annotations\Reader; -use Doctrine\DBAL\Types\Type; -use Doctrine\ORM\Annotation; -use Doctrine\ORM\Cache\Exception\CacheException; use Doctrine\ORM\Events; -use Doctrine\ORM\Id\TableGenerator; use Doctrine\ORM\Mapping; use Doctrine\ORM\Mapping\Builder\EntityListenerBuilder; use Doctrine\ORM\Mapping\MappingException; diff --git a/lib/Doctrine/ORM/Tools/EntityGenerator.php b/lib/Doctrine/ORM/Tools/EntityGenerator.php index 06d6b0243c7..437c7fcdfd5 100644 --- a/lib/Doctrine/ORM/Tools/EntityGenerator.php +++ b/lib/Doctrine/ORM/Tools/EntityGenerator.php @@ -221,7 +221,6 @@ class EntityGenerator ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE => 'SEQUENCE', ClassMetadataInfo::GENERATOR_TYPE_IDENTITY => 'IDENTITY', ClassMetadataInfo::GENERATOR_TYPE_NONE => 'NONE', - ClassMetadataInfo::GENERATOR_TYPE_UUID => 'UUID', ClassMetadataInfo::GENERATOR_TYPE_CUSTOM => 'CUSTOM', ]; diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php index 1f59747f549..ea1cb540d44 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php @@ -253,9 +253,6 @@ protected function _getIdGeneratorTypeString($type) case ClassMetadataInfo::GENERATOR_TYPE_IDENTITY: return 'IDENTITY'; - case ClassMetadataInfo::GENERATOR_TYPE_UUID: - return 'UUID'; - case ClassMetadataInfo::GENERATOR_TYPE_CUSTOM: return 'CUSTOM'; } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d74880cfddf..e8c0added82 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -215,16 +215,6 @@ parameters: count: 1 path: lib/Doctrine/ORM/Event/PreFlushEventArgs.php - - - message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getTableHiLoCurrentValSql\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Id/TableGenerator.php - - - - message: "#^Call to an undefined method Doctrine\\\\DBAL\\\\Platforms\\\\AbstractPlatform\\:\\:getTableHiLoUpdateNextValSql\\(\\)\\.$#" - count: 1 - path: lib/Doctrine/ORM/Id/TableGenerator.php - - message: "#^Parameter \\#2 \\$discrMap of static method Doctrine\\\\ORM\\\\Internal\\\\Hydration\\\\HydrationException\\:\\:invalidDiscriminatorValue\\(\\) expects array\\, array\\ given\\.$#" count: 1 @@ -2092,7 +2082,7 @@ parameters: path: lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|3\\|4\\|5\\|6\\|7, int given\\.$#" + message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|4\\|5\\|7, int given\\.$#" count: 1 path: lib/Doctrine/ORM/Tools/Export/Driver/PhpExporter.php @@ -2102,7 +2092,7 @@ parameters: path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|3\\|4\\|5\\|6\\|7, int given\\.$#" + message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|4\\|5\\|7, int given\\.$#" count: 2 path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php @@ -2112,7 +2102,7 @@ parameters: path: lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php - - message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|3\\|4\\|5\\|6\\|7, int given\\.$#" + message: "#^Parameter \\#1 \\$type of method Doctrine\\\\ORM\\\\Tools\\\\Export\\\\Driver\\\\AbstractExporter\\:\\:_getIdGeneratorTypeString\\(\\) expects 1\\|2\\|4\\|5\\|7, int given\\.$#" count: 1 path: lib/Doctrine/ORM/Tools/Export/Driver/YamlExporter.php diff --git a/phpstan.neon b/phpstan.neon index 2ccd6581380..b43bc6e6af3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,9 +4,6 @@ includes: parameters: ignoreErrors: - # deprecations from doctrine/dbal:3.x - - '/^Call to an undefined method Doctrine\\DBAL\\Platforms\\AbstractPlatform::getGuidExpression\(\).$/' - # Fallback logic for DBAL 2 - message: '/HelperSet constructor expects/' diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 2ab865d4dd2..8c68f21e0ff 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -415,8 +415,7 @@ - - copy + getHydrator transactional transactional @@ -610,17 +609,6 @@ (string) $em->getConnection()->lastInsertId($this->sequenceName) - - - $currentLevel - $this->_nextValue - $this->_nextValue - - - getTableHiLoCurrentValSql - getTableHiLoUpdateNextValSql - - $vertex->state !== self::VISITED @@ -817,12 +805,6 @@ $parent new $definition['class']() - - new UuidGenerator() - - - ClassMetadata::GENERATOR_TYPE_UUID - addNamedNativeQuery addNamedQuery @@ -922,9 +904,6 @@ $class $subclass - - self::GENERATOR_TYPE_UUID - $this->columnNames $this->columnNames @@ -3491,9 +3470,6 @@ $this->getClassToExtend() ?: $metadata->name array_map('strlen', $paramTypes) - - ClassMetadataInfo::GENERATOR_TYPE_UUID - $metadata->reflClass !== null class_exists($metadata->name) @@ -3575,9 +3551,6 @@ ExportException::attemptOverwriteExistingFile($path) - - ClassMetadataInfo::GENERATOR_TYPE_UUID - string diff --git a/psalm.xml b/psalm.xml index 71ab6838c82..24d8872268d 100644 --- a/psalm.xml +++ b/psalm.xml @@ -31,7 +31,6 @@ - @@ -110,11 +109,5 @@ - - - - - - diff --git a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php b/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php deleted file mode 100644 index a10514c661d..00000000000 --- a/tests/Doctrine/Tests/ORM/Functional/UUIDGeneratorTest.php +++ /dev/null @@ -1,89 +0,0 @@ -expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issues/7312'); - $this->_em->getClassMetadata(UUIDEntity::class); - } - - public function testGenerateUUID(): void - { - if (! method_exists(AbstractPlatform::class, 'getGuidExpression')) { - self::markTestSkipped('Test valid for doctrine/dbal:2.x only.'); - } - - if ($this->_em->getConnection()->getDatabasePlatform()->getName() !== 'mysql') { - self::markTestSkipped('Currently restricted to MySQL platform.'); - } - - $this->_schemaTool->createSchema([ - $this->_em->getClassMetadata(UUIDEntity::class), - ]); - $entity = new UUIDEntity(); - - $this->_em->persist($entity); - self::assertNotNull($entity->getId()); - self::assertGreaterThan(0, strlen($entity->getId())); - } - - public function testItCannotBeInitialised(): void - { - if (method_exists(AbstractPlatform::class, 'getGuidExpression')) { - self::markTestSkipped('Test valid for doctrine/dbal:3.x only.'); - } - - $this->expectException(NotSupported::class); - $this->_em->getClassMetadata(UUIDEntity::class); - } -} - -/** - * @Entity - */ -class UUIDEntity -{ - /** - * @var string - * @Id - * @Column(type="string") - * @GeneratedValue(strategy="UUID") - */ - private $id; - - /** - * Get id. - * - * @return string. - */ - public function getId(): string - { - return $this->id; - } -} diff --git a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php index 9c243210a9e..23353fec799 100644 --- a/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/EntityGeneratorTest.php @@ -754,10 +754,6 @@ public function testGetIdGeneratorTypeString(): void continue; } - if ($name === 'GENERATOR_TYPE_TABLE') { - continue; - } - $expected = preg_replace($pattern, '', $name); $actual = $method->invoke($this->generator, $value);