Skip to content

Commit

Permalink
BUGFIX: Since #2700 it is not longer possible to inherit Accounts for…
Browse files Browse the repository at this point in the history
… special usage

This will only ask Doctrine about objects, which are definitely marked as entity themself.
  • Loading branch information
fcool committed Jul 6, 2023
1 parent f5bd1cb commit 971c2cd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Neos.Flow/Classes/Persistence/Doctrine/PersistenceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\Tools\ToolsException;
Expand Down Expand Up @@ -128,6 +129,21 @@ public function isNewObject($object): bool
if (!$object instanceof PersistenceMagicInterface) {
return true;
}
// This filters for classes, which have inherited the PersistenceMagicInterface, but did not get annotated
// Such objects are by definition no persistable objects, so we should not let ask doctrine anything about them.
// Should probably get removed as soon as Accounts are usable without the base class carrying the entity
// annotation.
$annotations = \array_filter(
$this->reflectionService->getClassAnnotations(\get_class($object)),
static function ($annotation) {
return ($annotation instanceof Entity)
|| ($annotation instanceof Flow\Entity)
|| ($annotation instanceof Flow\ValueObject);
}
);
if (\count($annotations) === 0) {
return true;
}

return ($this->entityManager->getUnitOfWork()->getEntityState($object) === UnitOfWork::STATE_NEW);
}
Expand Down

0 comments on commit 971c2cd

Please sign in to comment.