Skip to content

Conversation

@GromNaN
Copy link
Member

@GromNaN GromNaN commented Oct 31, 2025

Q A
Type bug
BC Break no
Fixed issues -

Summary

  • Fix initialization of proxies when hydrating collection with ProxyManager (bug fix).
  • Fix unsetting native lazy object config to not enable symfony lazy ghost objects (bug fix)
  • Add a CI job without optional dependencies to ensure they are not required.
  • Create test with read-only properties with lazy-objects. Not supported by ProxyManager Public readonly properties FriendsOfPHP/proxy-manager-lts#26

@GromNaN GromNaN force-pushed the fix-classNameResolver branch 2 times, most recently from 2d4f5df to 7746f7d Compare October 31, 2025 10:53
@GromNaN GromNaN force-pushed the fix-classNameResolver branch from 7746f7d to e67c780 Compare October 31, 2025 12:03
$skippedFieldsFqns = [];

foreach ($metadata->getIdentifierFieldNames() as $idField) {
$skippedFieldsFqns[] = $this->propertyFqcn($metadata->getReflectionProperty($idField));
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove usage of the deprecated ClassMetadata::getReflectionProperty()

Comment on lines -464 to -476
if ($document instanceof GhostObjectInterface && $document->getProxyInitializer() !== null) {
// Inject an empty initialiser to not load any object data
$document->setProxyInitializer(static function (
GhostObjectInterface $ghostObject,
string $method, // we don't care
array $parameters, // we don't care
&$initializer,
array $properties, // we currently do not use this
): bool {
$initializer = null;

return true;
});
Copy link
Member Author

Choose a reason for hiding this comment

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

We need to set the initializer to null, so that the proxy is marked as initialized. Otherwise, updating a value that is already set doesn't initialize the proxy, and the UOW ignore the document when computing changeset.

}

$this->nativeLazyObject = $nativeLazyObject;
$this->lazyGhostObject = ! $nativeLazyObject || $this->lazyGhostObject;
Copy link
Member Author

Choose a reason for hiding this comment

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

This was setting lazyGhostObject = true when calling setUseNativeLazyObject(false), which is not expected.

public ?string $id;

#[ODM\Field]
public readonly string $name;
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove the reaonly property that was added in #2840. That makes Doctrine\ODM\MongoDB\Tests\Aggregation\BuilderTest::testAggregationBuilder fail.

{
$configuration = $this->dm->getConfiguration();
if (! $configuration->isNativeLazyObjectEnabled() && ! $configuration->isLazyGhostObjectEnabled()) {
$this->markTestSkipped('Read-only properties are not supported by the legacy Proxy Manager. https://github.com/FriendsOfPHP/proxy-manager-lts/issues/26');
Copy link
Member Author

Choose a reason for hiding this comment

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

@GromNaN GromNaN requested review from alcaeus and jmikola October 31, 2025 21:04
…ction

Fix test NestedCollectionsTest with ProxyManager

Add a test for read-only properties, not supported by ProxyManager

FriendsOfPHP/proxy-manager-lts#26
@GromNaN GromNaN force-pushed the fix-classNameResolver branch 2 times, most recently from 51d519a to e8cbed4 Compare October 31, 2025 21:26
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.

1 participant