-
-
Notifications
You must be signed in to change notification settings - Fork 513
Ensure proxy-manager is not used when native lazy objects are enabled #2884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.14.x
Are you sure you want to change the base?
Conversation
2d4f5df to
7746f7d
Compare
7746f7d to
e67c780
Compare
| $skippedFieldsFqns = []; | ||
|
|
||
| foreach ($metadata->getIdentifierFieldNames() as $idField) { | ||
| $skippedFieldsFqns[] = $this->propertyFqcn($metadata->getReflectionProperty($idField)); |
There was a problem hiding this comment.
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()
| 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; | ||
| }); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ction Fix test NestedCollectionsTest with ProxyManager Add a test for read-only properties, not supported by ProxyManager FriendsOfPHP/proxy-manager-lts#26
51d519a to
e8cbed4
Compare
e8cbed4 to
7cc80ec
Compare
Summary