mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Unintercepted function call to load entity data when enable_lazy_ghost_objects is enabled
#7387
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jbcr on GitHub (Jun 25, 2024).
Bug Report
Summary
When the option
enable_lazy_ghost_objectsis 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_objectstotrueto remove deprecation.But, if
enable_lazy_ghost_objectsistrueI 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$localparameter. This method throws an exception if the current local and the$localparameter 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: https://github.com/doctrine/DoctrineBundle/issues/1809
Sylius Issue: https://github.com/Sylius/SyliusResourceBundle/issues/901
@mrlukowski commented on GitHub (Sep 25, 2025):
After enabling it (dev seems fine), production started having random 502 responses (e.g. child 78 exited on signal 11 (SIGSEGV) after 47.698020 seconds from start — looks like a memory leak?). Stack: Symfony 6.4 + PHP 8.3.1 + doctrine/orm 2.20.1.
*update: php was 8.3.16 (image was falsely named)
@greg0ire commented on GitHub (Sep 25, 2025):
If you get a segfault, you should try upgrading to the latest php 8.3