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

BUGFIX: Allow to inherit Accounts after the merge of #2700 again #3109

Open
wants to merge 2 commits into
base: 8.3
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 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 All @@ -30,6 +31,7 @@
use Neos\Flow\Validation\ValidatorResolver;
use Neos\Utility\Exception\PropertyNotAccessibleException;
use Neos\Utility\ObjectAccess;
use Neos\Utility\TypeHandling;
use Psr\Log\LoggerInterface;

/**
Expand Down Expand Up @@ -128,6 +130,22 @@ 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(TypeHandling::getTypeForValue($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