Remove COLLECTION_PER_CLASS inheritance type - #3022
Open
GromNaN wants to merge 6 commits into
Open
Conversation
…on (doctrine#3021) Ensures that a ReferenceMany PersistentCollection marked as dirty (same instance, new element added) is detected as changed by computeChangeSets(). Unlike EmbedMany, ReferenceMany collections are excluded from the association changeset loop, so detection relies solely on the dirty flag check in computeOrRecomputeChangeSet().
* Deprecate COLLECTION_PER_CLASS inheritance type This inheritance type persists one collection per class, which is already the default behavior for any document. It provides no extra behavior and cannot guarantee _id uniqueness across the distinct collections of a hierarchy. Deprecate it with no replacement: remove the InheritanceType mapping, each class remains mapped to its own collection. Closes doctrine#2742 * Add trigger_deprecation to isInheritanceTypeCollectionPerClass() Also refactor ClassMetadataFactory to compare against the constant directly, avoiding an internal call to the now-deprecated method.
…-3.0.x-4723 # Conflicts: # src/Mapping/ClassMetadataFactory.php
The COLLECTION_PER_CLASS inheritance type, deprecated in 2.17, is removed with no replacement. Each document class is already mapped to its own collection, so the type provided no additional behavior. The mapping drivers now throw a MappingException when an unknown inheritance type is configured, instead of relying on an undefined constant.
GromNaN
force-pushed
the
merge-2.17.x-into-3.0.x-4723
branch
from
June 30, 2026 06:58
d3a3e43 to
4f415b3
Compare
malarzm
reviewed
Jun 30, 2026
|
|
||
| .. _collection_per_class_inheritance: | ||
|
|
||
| Collection Per Class Inheritance |
Member
There was a problem hiding this comment.
I think it'd be good to keep a section and showing you can just extend documents and change the collection
Member
Author
There was a problem hiding this comment.
Good point. There was already a section on MappedSuperclass, but I've revised the doc to make it clear that PHP inheritance just works.
GromNaN
force-pushed
the
merge-2.17.x-into-3.0.x-4723
branch
from
June 30, 2026 08:48
2ef4082 to
e6bf183
Compare
GromNaN
force-pushed
the
merge-2.17.x-into-3.0.x-4723
branch
from
June 30, 2026 09:54
e6bf183 to
7d3fc4e
Compare
GromNaN
commented
Jun 30, 2026
Comment on lines
+176
to
+181
| $constantName = ClassMetadata::class . '::INHERITANCE_TYPE_' . $inheritanceType; | ||
| if (! defined($constantName)) { | ||
| throw MappingException::invalidInheritanceType($className, $inheritanceType); | ||
| } | ||
|
|
||
| $metadata->setInheritanceType(constant($constantName)); |
Member
Author
There was a problem hiding this comment.
In a follow-up PR, we can add support for using the const value in the InheritanceType attribute.
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.
Summary
Removes the
COLLECTION_PER_CLASSinheritance type, deprecated in 2.17. Each document class is already mapped to its own collection, so the type provided no additional behavior. The mapping drivers now throw aMappingExceptionwhen an unknown inheritance type is configured.This PR also merges 2.17.x into 3.0.x.