Skip to content

Fix false positive inheritance deprecation for embeddable subclasses#12399

Open
isaackaara wants to merge 1 commit into
doctrine:2.20.xfrom
isaackaara:fix/embeddable-inheritance-deprecation
Open

Fix false positive inheritance deprecation for embeddable subclasses#12399
isaackaara wants to merge 1 commit into
doctrine:2.20.xfrom
isaackaara:fix/embeddable-inheritance-deprecation

Conversation

@isaackaara

Copy link
Copy Markdown
Contributor

What

When an embeddable class extends another embeddable class, ClassMetadataFactory incorrectly triggers a deprecation warning about a missing inheritance mapping type declaration.

Why

The check at line 164 of ClassMetadataFactory::doLoadMetadata() only guards against isMappedSuperclass, but does not exclude embedded classes. Since embeddable classes cannot have inheritance mapping types, the deprecation should not fire for them.

Fix

Added && ! $class->isEmbeddedClass to the condition so the deprecation is only triggered for regular entity classes, not embeddables.

How to reproduce

/** @Embeddable */
class Timeframe {
    public function __construct(
        protected readonly ?\DateTimeImmutable $from,
        protected readonly ?\DateTimeImmutable $to,
    ) {}
}

/** @Embeddable */
class BoundedTimeframe extends Timeframe {
    public function __construct(\DateTimeImmutable $from, \DateTimeImmutable $to) {
        parent::__construct($from, $to);
    }
}

Before this fix, loading metadata for BoundedTimeframe triggers:

Entity class 'BoundedTimeframe' is a subclass of the root entity class 'Timeframe', but no inheritance mapping type was declared. This is a misconfiguration and will be an error in Doctrine ORM 3.0.

After this fix, no deprecation is triggered.

Fixes #11843

When an embeddable class extends another embeddable class, the check
in ClassMetadataFactory incorrectly triggers the deprecation warning
about missing inheritance mapping type declarations.

Embeddable classes do not support inheritance mapping types, so the
check should be skipped when the class is an embedded class.

Fixes doctrine#11843
@github-actions

Copy link
Copy Markdown
Contributor

There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.
If you want to continue working on it, please leave a comment.

@github-actions github-actions Bot added the Stale label Jun 13, 2026
@greg0ire

Copy link
Copy Markdown
Member

Sorry, 2.20.x is closed for bugfixes. Please retarget to 3.6.x

@greg0ire greg0ire removed the Stale label Jun 13, 2026
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.

2 participants