-
-
Notifications
You must be signed in to change notification settings - Fork 455
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
Compatibility with ORM 3 #1722
Compatibility with ORM 3 #1722
Conversation
use function sprintf; | ||
use function trait_exists; | ||
|
||
if (trait_exists(LazyGhostTrait::class)) { | ||
if (trait_exists(LazyGhostTrait::class) && property_exists(EntityRepository::class, '_entityName')) { |
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 basically opts us out of the new LazyServiceEntityRepository
for ORM 3. I need a little help to get this to work, @nicolas-grekas.
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.
Ideally, we would get rid of LazyServiceEntityRepository: I introduced it to keep BC with existing protected properties on EntityRepository. But since those are private in 3.0, we should now be able to deal with lazyness by decorating public/protected methods. As a reminder, the purpose of the lazy proxy is to move the $manager = $registry->getManagerForClass($entityClass);
call out of the construction step.
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 PR still support ORM 2.x though.
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've pushed a version with a proxy for EntityRepository
.
07f448a
to
08aee56
Compare
Ugh, Psalm 4 is a mess. :-( |
08aee56
to
93b0a66
Compare
93b0a66
to
a588397
Compare
$configuration = new Configuration(true); | ||
$configuration->getConfigTreeBuilder(); | ||
|
||
$this->assertFalse(class_exists('Doctrine\Common\Proxy\AbstractProxyFactory', false)); |
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 is a very old test and I'm not sure if we still need it. I cannot make it pass anymore because I need to feature-check if we can allow not enabling the lazy ghost implementation.
Can we move some of those psalm suppressions inline? We put it to config file only when that doesn't work. |
a588397
to
264a7f4
Compare
Done for the |
6fbd181
to
3e8ca45
Compare
*/ | ||
class ServiceEntityRepository extends LazyServiceEntityRepository | ||
{ | ||
if (property_exists(EntityRepository::class, '_entityName')) { |
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.
Oh boy, people were already complaining about previous logic being too difficult for SA tools to understand (#1677), now it's going to get worse. But I guess we can't do anything about it
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.
Not without breaking stuff, I'm afraid. It might be worth doing a 3.0 soon'ish.
3e8ca45
to
0c3005e
Compare
0c3005e
to
97517d8
Compare
This PR adds compatibility with ORM 3. I'm not very proud of the code that I had to write and I'm open to ideas. 🙈
As a side effect, I'm deprecating not enabling the lazy ghost implementation, just as the ORM did. If the app did not specify which proxy implementation should be used, this is what the bundle decides:
If the app explicitly opts out of lazy ghosts despite having ORM 3 installed, the container won't compile.