You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the option enable_lazy_ghost_objects is enabled, calling a function not getter/setter on an entity can break the code.
Current behavior
An entity used from relation (with proxy) can execute function code without entity data. You need to explicitly call a property to load the entity data.
How to reproduce
I'm upgrading a project from Sylius 1.12 to 1.13.2.
During the upgrade, I have set the enable_lazy_ghost_objects to true to remove deprecation.
But, if enable_lazy_ghost_objects is true 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.
Expected behavior
The data of Product entity must be loaded when getTranslation() is called.
Bug Report
Summary
When the option
enable_lazy_ghost_objects
is enabled, calling a function not getter/setter on an entity can break the code.Current behavior
An entity used from relation (with proxy) can execute function code without entity data. You need to explicitly call a property to load the entity data.
How to reproduce
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.Expected behavior
The data of Product entity must be loaded when
getTranslation()
is called.Source issue: doctrine/DoctrineBundle#1809
Sylius Issue: Sylius/SyliusResourceBundle#901
The text was updated successfully, but these errors were encountered: