Skip to content

Fix translations collection detection for hierarchies with mapped superclasses#90

Merged
mpdude merged 4 commits intomasterfrom
fix-inheritance
Mar 27, 2026
Merged

Fix translations collection detection for hierarchies with mapped superclasses#90
mpdude merged 4 commits intomasterfrom
fix-inheritance

Conversation

@mpdude
Copy link
Copy Markdown
Member

@mpdude mpdude commented Mar 27, 2026

This fixes that the "translations collection" was not detected when it is defined in a mapped superclass and inherited by an entity. Due to how MappedSuperclasses work for one-to-many associations, this requires to set up the ResolveTargetEntityListener with an interface to point back from the translation class to the concrete entity class.

See https://github.com/doctrine/orm/blob/580a95ce3f5f016547d15ecc6cc94dd85453bed5/src/Mapping/AssociationMapping.php#L34-L57 for the meaning of the two inherited and declared mapping entries.

inherited means that the field in question exists also in a parent entity class. This parent entity class is named in ClassMetadata::$parentClasses, and will be inspected by PolyglotListener::getTranslationMetadatas().

The previous check, which was looking at declared, is wrong for fields declared in mapped superclasses: Mapped superclasses are not part of the parentClasses list, and so we missed translation collections defined in those.

@mpdude mpdude merged commit e40e3de into master Mar 27, 2026
@mpdude mpdude deleted the fix-inheritance branch March 27, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant