Skip to content

Commit

Permalink
Reword the actual fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdude committed Jan 15, 2023
1 parent 959b133 commit 0408e70
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,6 @@ private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $p
if ($mapping['type'] & ClassMetadata::TO_MANY && ! $mapping['isOwningSide']) {
throw MappingException::illegalToManyAssociationOnMappedSuperclass($parentClass->name, $field);
}

if (! isset($mapping['inherited'])) {
$mapping['sourceEntity'] = $subClass->name;
}
}

//$subclassMapping = $mapping;
Expand All @@ -396,6 +392,16 @@ private function addInheritedRelations(ClassMetadata $subClass, ClassMetadata $p
$mapping['declared'] = $parentClass->name;
}

// When the class inheriting the relation ($subClass) is the first entity class since the
// relation has been defined in a mapped superclass (or in a chain
// of mapped superclasses) above, then declare this current entity class as the source of
// the relationship.
// According to the definitions given in https://github.com/doctrine/orm/pull/10396/,
// this is the case <=> ! isset($mapping['inherited']).
if (! isset($mapping['inherited'])) {
$mapping['sourceEntity'] = $subClass->name;
}

$subClass->addInheritedAssociationMapping($mapping);
}
}
Expand Down

0 comments on commit 0408e70

Please sign in to comment.