From 93a7d2eab0a3156671974ff91b13a26200d5b4bc Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 9 Oct 2024 16:57:07 +0200 Subject: [PATCH 1/3] [GH-8471] Undeprecate all PARTIAL object usage. --- UPGRADE.md | 8 +++++--- src/Query/Parser.php | 8 -------- src/UnitOfWork.php | 9 --------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index a42be6a437..df648b1846 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -8,10 +8,12 @@ change in behavior. Progress on this is tracked at https://github.com/doctrine/orm/issues/11624 . -## PARTIAL DQL syntax is undeprecated for non-object hydration +## PARTIAL DQL syntax is undeprecated -Use of the PARTIAL keyword is not deprecated anymore in DQL when used with a hydrator -that is not creating entities, such as the ArrayHydrator. +Use of the PARTIAL keyword is not deprecated anymore in DQL, because we will be +able to support PARTIAL objects with PHP 8.4 Lazy Objects and +Symfony/VarExporter in a better way. When we decided to remove this feature +these two abstractions did not exist yet. ## Deprecate `\Doctrine\ORM\Query\Parser::setCustomOutputTreeWalker()` diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 7d0a0176f4..7b50c2920e 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -1852,14 +1852,6 @@ public function JoinAssociationDeclaration() */ public function PartialObjectExpression() { - if ($this->query->getHydrationMode() === Query::HYDRATE_OBJECT) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8471', - 'PARTIAL syntax in DQL is deprecated for object hydration.' - ); - } - $this->match(TokenType::T_PARTIAL); $partialFieldSet = []; diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index fa51983e30..a70411103c 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -2920,15 +2920,6 @@ private function newInstance(ClassMetadata $class) */ public function createEntity($className, array $data, &$hints = []) { - if (isset($hints[SqlWalker::HINT_PARTIAL])) { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8471', - 'Partial Objects are deprecated for object hydration (here entity %s)', - $className - ); - } - $class = $this->em->getClassMetadata($className); $id = $this->identifierFlattener->flattenIdentifier($class, $data); From 12f87e54d2aeb8deb58a86d4040beed999c43f6c Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 9 Oct 2024 17:42:28 +0200 Subject: [PATCH 2/3] Warning about having to upgrade to 3.3 --- UPGRADE.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index df648b1846..a44bbd5a35 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -15,6 +15,10 @@ able to support PARTIAL objects with PHP 8.4 Lazy Objects and Symfony/VarExporter in a better way. When we decided to remove this feature these two abstractions did not exist yet. +WARNING: If you want to upgrade to 3.x and still use PARTIAL keyword in DQL +with array or object hydrators, then you have to directly migrate to ORM 3.3.x or higher. +PARTIAL keyword in DQL is not available in 3.0, 3.1 and 3.2 of ORM. + ## Deprecate `\Doctrine\ORM\Query\Parser::setCustomOutputTreeWalker()` Use the `\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER` query hint to set the output walker From fc299b184b6c8e918ba08e4328687db126699ccd Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 9 Oct 2024 22:12:08 +0200 Subject: [PATCH 3/3] phpcs --- src/UnitOfWork.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index a70411103c..39ba6b68b7 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -41,7 +41,6 @@ use Doctrine\ORM\Persisters\Entity\JoinedSubclassPersister; use Doctrine\ORM\Persisters\Entity\SingleTablePersister; use Doctrine\ORM\Proxy\InternalProxy; -use Doctrine\ORM\Query\SqlWalker; use Doctrine\ORM\Utility\IdentifierFlattener; use Doctrine\Persistence\Mapping\RuntimeReflectionService; use Doctrine\Persistence\NotifyPropertyChanged;