Doctrine 3 preparation: Mark abstract entity classes as MappedSuperclass; use resolve_target_entities (Case 212955) - #21
Merged
Conversation
…ass; use resolve_target_entities Newsletter, Recipient and PendingOptIn are abstract classes with property-level ORM attributes but no class-level mapping. Doctrine only picked the mappings up implicitly through reflection of the concrete subclasses — undocumented behaviour that Doctrine ORM 3 no longer guarantees. This adds #[ORM\MappedSuperclass] so each base owns its mapping, including the $newsletters association, and let the concrete subclasses inherit it. Binds the NewsletterInterface target to the concrete class through resolve_target_entities instead of redeclaring the association in the test dummies — the same mechanism downstream implementors use (and the shape the tests/Fixtures/App classes already have). Drops the @ ORM\Entity pseudo-docblock templates and update the README to match. Note: removing the Dummy\Recipient override reverts its newsletter join to the abstract Recipient's id-based (primary key) column. The Dummy referenced uuid instead; that non-PK case is not needed, so we let it inherit the base. No test depends on it.
janopae
force-pushed
the
212955-mapped-superclass
branch
from
July 30, 2026 12:04
a73a9ea to
3685504
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Newsletter, Recipient and PendingOptIn are abstract classes with property-level ORM attributes but no class-level mapping. Doctrine only picked the mappings up implicitly through reflection of the concrete subclasses — undocumented behaviour that Doctrine ORM never garanteed and that is known to break in ORM 3.
This adds #[ORM\MappedSuperclass] so each base owns its mapping, including the $newsletters association, and let the concrete subclasses inherit it. Binds the NewsletterInterface target to the concrete class through resolve_target_entities instead of redeclaring the association in the test dummies — the same mechanism downstream implementors use (and the shape the tests/Fixtures/App classes already have). Drops the @ ORM\Entity pseudo-docblock templates and update the README to match.
Note: removing the Dummy\Recipient override reverts its newsletter join to the abstract Recipient's id-based (primary key) column. The Dummy referenced uuid instead; that non-PK case is not needed, so we let it inherit the base. No test depends on it.