Skip to content

Conversation

@GromNaN
Copy link
Member

@GromNaN GromNaN commented Nov 21, 2025

Q A
Type bug
BC Break yes-ish (see #2916)
Fixed issues -

Summary

Re-implement #2698 for native lazy objects.

Using the method ReflectionProperty::skipLazyInitialization, accessing properties that are not mapped in Doctrine will not initialize the document object.

@GromNaN GromNaN added this to the 2.15.2 milestone Nov 21, 2025
@GromNaN GromNaN added the Bug label Nov 21, 2025
@GromNaN GromNaN force-pushed the skip-unmapped-properties branch from 65b9940 to b4022ab Compare November 21, 2025 21:11
@GromNaN GromNaN changed the base branch from 2.16.x to 2.15.x November 21, 2025 21:11
{
if (isset($this->skippedProperties[$metadata->name])) {
return $this->skippedProperties[$metadata->name];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memoization!

continue;
}

if ($property->isVirtual()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pleasantly surprised that the ReflectionProperty docs explain what virtual properties are.

$skippedProperties = [];
foreach ($metadata->reflClass->getProperties() as $property) {
if (array_key_exists($property->name, $metadata->propertyAccessors)) {
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, every mapped field should have its own property accessor according to ClassMetadata::mapField(), correct?

So this foreach look is really just checking for unmapped, non-virtual properties.

Will this logic be useful in any other contexts? If so, it may be worth capturing this logic in a ClassMetadata method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants