From 68744489f023afd810b08b70c2ba582f500190a1 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Tue, 18 Jun 2024 14:15:31 +0200 Subject: [PATCH 1/3] Undeprecate PARTIAL for array hydration. (#11366) * Undeprecate PARTIAL for array hydration. * note about undeprecate partial in UPGRADE.md --- UPGRADE.md | 5 +++++ src/Query/Parser.php | 12 +++++++----- src/UnitOfWork.php | 10 ++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 5689b307bda..9e6c0cb2253 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -15,6 +15,11 @@ to find out. Use `Doctrine\ORM\Query\TokenType::T_*` instead. +## PARTIAL DQL syntax is undeprecated for non-object hydration + +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. + # Upgrade to 2.17 ## Deprecate annotations classes for named queries diff --git a/src/Query/Parser.php b/src/Query/Parser.php index 949a8f4ebdd..eb7da7337ac 100644 --- a/src/Query/Parser.php +++ b/src/Query/Parser.php @@ -1844,11 +1844,13 @@ public function JoinAssociationDeclaration() */ public function PartialObjectExpression() { - Deprecation::trigger( - 'doctrine/orm', - 'https://github.com/doctrine/orm/issues/8471', - 'PARTIAL syntax in DQL is deprecated.' - ); + 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); diff --git a/src/UnitOfWork.php b/src/UnitOfWork.php index f1affcf7ebc..7f4ce8c17c5 100644 --- a/src/UnitOfWork.php +++ b/src/UnitOfWork.php @@ -41,6 +41,7 @@ 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; @@ -2919,6 +2920,15 @@ 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 066ec1ac81c8409293763eeb1a50dc05b792fb8c Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 18 Jun 2024 14:18:37 +0200 Subject: [PATCH 2/3] Fix upgrade guide for 2.20 (#11504) --- UPGRADE.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 9e6c0cb2253..e20a8fef89b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,10 @@ +# Upgrade to 2.20 + +## PARTIAL DQL syntax is undeprecated for non-object hydration + +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. + # Upgrade to 2.19 ## Deprecate calling `ClassMetadata::getAssociationMappedByTargetField()` with the owning side of an association @@ -15,11 +22,6 @@ to find out. Use `Doctrine\ORM\Query\TokenType::T_*` instead. -## PARTIAL DQL syntax is undeprecated for non-object hydration - -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. - # Upgrade to 2.17 ## Deprecate annotations classes for named queries From e3d7c6076c3975eedd1abb8f2b2eeb34efcd7b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Wed, 26 Jun 2024 17:45:09 +0200 Subject: [PATCH 3/3] Use modern array syntax in the doc --- docs/en/tutorials/getting-started.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index 688030cc149..1fa463dd797 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -144,7 +144,7 @@ step: // Create a simple "default" Doctrine ORM configuration for Attributes $config = ORMSetup::createAttributeMetadataConfiguration( - paths: array(__DIR__."/src"), + paths: [__DIR__ . '/src'], isDevMode: true, ); // or if you prefer annotation, YAML or XML @@ -153,7 +153,7 @@ step: // isDevMode: true, // ); // $config = ORMSetup::createXMLMetadataConfiguration( - // paths: array(__DIR__."/config/xml"), + // paths: [__DIR__ . '/config/xml'], // isDevMode: true, //); // $config = ORMSetup::createYAMLMetadataConfiguration(