Closed jbcr closed 5 months ago
This is best to report to https://github.com/symfony/symfony repo, since proxy logic is there
@ostrolucky Why?
All code to generate Entity proxy are in Doctrine ORM and Doctrine Bundle.
That's for the ORM indeed.
I thought enable_lazy_ghost_objects utilizes LazyGhostTrait which is in symfony/var-exporter. Either way, this is very unlikely to be an issue in doctrine-bundle, will be ORM or var-exporter.
Sure, and that's in the ORM: the issue is that unmapped properties don't trigger initialization, which means postLoad events are not triggered (@stof figured this out).
Hello, I'm upgrading a project from Sylius 1.12 to 1.13.2.
During the upgrade, I have set the
enable_lazy_ghost_objects
totrue
to remove deprecation.But, if
enable_lazy_ghost_objects
istrue
I have an error when I try to access Sylius Ressource translation from a relation.In Sylius, you have an entity (resource) named Product that can be translated (ProductTranslation). On the Product, I have a method called
getTanslation(?string $local = null)
to get the current translation or requested translation by$local
parameter. This method throws an exception if the current local and the$local
parameter are null.I added a new entity (resource) named Tag with a one-to-many relation to Product.
When I execute
$tag->getFirstProduct()->getTranslation()->getName();
the exception is thrown because the product is not loaded.When
enable_lazy_ghost_objects
isfalse
, the proxy has a method to initialize the product entity ongetTranslation()
call.When
enable_lazy_ghost_objects
istrue
, the proxy does not intercept the function call and the object is not loaded. I must call a getter manually to force the object data loading before callgetTranslation()
.Why has this behavior changed with this option?
Installed Doctrine library: