From 39dfce6c52d2a07bd37f0fa2434efd7d040a8eb5 Mon Sep 17 00:00:00 2001 From: Maciej Malarz Date: Mon, 24 Feb 2020 22:24:15 +0100 Subject: [PATCH] Treat parent embeddables as mapped superclasses --- lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php | 5 +++-- lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 8410ce5b0de..f4015129e22 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -401,7 +401,7 @@ private function getShortName($className) private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass) { foreach ($parentClass->fieldMappings as $mapping) { - if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass) { + if ( ! isset($mapping['inherited']) && ! $parentClass->isMappedSuperclass && ! $parentClass->isEmbeddedClass) { $mapping['inherited'] = $parentClass->name; } if ( ! isset($mapping['declared'])) { @@ -780,7 +780,8 @@ protected function getDriver() */ protected function isEntity(ClassMetadataInterface $class) { - return isset($class->isMappedSuperclass) && $class->isMappedSuperclass === false; + return isset($class->isMappedSuperclass) && $class->isMappedSuperclass === false + && isset($class->isEmbeddedClass) && $class->isEmbeddedClass === false; } /** diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index bafd5d27499..28cf958a315 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -277,6 +277,8 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) /* @var $property \ReflectionProperty */ foreach ($class->getProperties() as $property) { if ($metadata->isMappedSuperclass && ! $property->isPrivate() + || + $metadata->isEmbeddedClass && $property->getDeclaringClass()->getName() !== $class->getName() || $metadata->isInheritedField($property->name) ||