-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
Switch proxies back to Doctrine Persistence and LazyGhostTrait
#2692
Conversation
5585b46
to
6bd757b
Compare
847dac8
to
606d3bc
Compare
self::assertInstanceOf(Proxy::class, $profile); | ||
$this->expectException(DocumentNotFoundException::class); | ||
$this->expectExceptionMessage( | ||
'The "Documents\Profile" document with identifier ' . | ||
'"abcdefabcdefabcdefabcdef" could not be found.', | ||
); | ||
$profile->__load(); |
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.
I don't understand why there was no exception for this missing document, while there is for previous tests.
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 class my not be required for this PR, but it enable serialization/unserialization of proxy objects. The doc need to be duplicated for the ODM: https://www.doctrine-project.org/projects/doctrine-orm/en/3.3/reference/advanced-configuration.html#autoloading-proxies
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 interface could be deprecated in 2.10.x
. I don't think we need more than a single ProxyFactory
.
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.
Or maybe this will be useful again, if we can have an optimized ProxyFactory
for PHP 8.4 with Lazy Objects.
Wouldn't it be better to wait for PHP's native proxies? Or change from Symfony's implementation to native one will be transparent for end users? |
My main motivation is to get rid of laminas code dependency and converge to the same implementation as the ORM. This change is compatible with every supported PHP version whereas the new native lazy objects are PHP 8.4+ only. I'm novice in the lazy ghost objects domain. Maybe @nicolas-grekas would have a better insight. My guess is that we are going to have 2 ProxyFactory classes: one for PHP 8.4+ and one for older versions. But both would use var-exporter and doctrine/persistence. |
I think it should be possible to delegate all the native proxy handling to var-exporter (+doctrine/persistence). That's where the choice of the best implement should happen. |
735cb9a
to
3b1c32e
Compare
FWIW we should do absolutely everything, to not release this as 3.0 and have 4.0 few months later. |
I agree. I haven't had a chance to take a detailed look yet, but I think it should be possible to somehow make this happen in 2.x. |
Replaced by #2700 |
Summary
This PR replaces the proxy implementation from
friendsofphp/proxy-manager-lts
(which requireslaminas/laminas-code
) withdoctrine/persistence
and theLazyGhostTrait
fromsymfony/var-exporter
.Copy the proxy implementation from Doctrine ORM: https://github.com/doctrine/orm/blob/3.3.x/src/Proxy/ProxyFactory.php
The
Doctrine\Persistence\Proxy
class was added indoctrine/persistence: 3.1
, we already require3.2
.This is a breaking change, so I open this PR for 3.0. The opposite move was done between 1.x and 2.0: #1875, but that was before Nicolas work on lazy ghost objects.