Skip to content

Doctrine 3 preparation: Mark abstract entity classes as MappedSuperclass; use resolve_target_entities (Case 212955) - #21

Merged
janopae merged 1 commit into
masterfrom
212955-mapped-superclass
Jul 30, 2026
Merged

Doctrine 3 preparation: Mark abstract entity classes as MappedSuperclass; use resolve_target_entities (Case 212955)#21
janopae merged 1 commit into
masterfrom
212955-mapped-superclass

Conversation

@janopae

@janopae janopae commented Jul 30, 2026

Copy link
Copy Markdown
Member

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.

@janopae janopae changed the title Doctrine 3 preparation: Mark abstract entity classes as MappedSuperclass; use resolve_target_entities Doctrine 3 preparation: Mark abstract entity classes as MappedSuperclass; use resolve_target_entities (Case 212955) Jul 30, 2026
…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
janopae force-pushed the 212955-mapped-superclass branch from a73a9ea to 3685504 Compare July 30, 2026 12:04
@janopae
janopae merged commit 34cc2b5 into master Jul 30, 2026
3 checks passed
@janopae
janopae deleted the 212955-mapped-superclass branch July 30, 2026 14:24
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