Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undeprecate PARTIAL for array hydration. #11366

Open
wants to merge 2 commits into
base: 2.20.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions UPGRADE.md
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions src/Query/Parser.php
Expand Up @@ -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);

Expand Down
10 changes: 10 additions & 0 deletions src/UnitOfWork.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down