mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Proxy classes and bounded operations to proxy class (instead of the entity class directly) #6017
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 @mvorisek on GitHub (Jul 11, 2018).
Originally assigned to: @Ocramius on GitHub.
Bug Report
If entity is proxied and some manipulation is done with scope set to the proxy class, private properties are not set/read, instead of new public (and duplicate) properties are added.
Summary
It is quite common to use the following scope change construction to operate with private entity properties:
The user expects that the private property of the entity is set.
Current behavior
It works if the entity is not proxied. But when the entity is proxied, it currently behave differently - a new public property is set! This can produce very strange results and it is very hard to debug.
Here is a print_r() output for the current implementation:
The current workaround is to get the entity class manually (using
Doctrine\Common\Util\ClassUtils::getRealClass()method) and then bound the set method to this class explicitly. But this can be very easily forget by the programmer and as this bug is only presented when the entity is proxied, this may be very hard to find later if for some reasons the entity is now lazy loaded and proxied and previously it was not the case.How to reproduce
Expected behavior
The expected behaviour is that entity private property is set even if set from proxy scope. The proxy impl. should behave as much as possible as the entity itself.
Expected print_r() output:
@Ocramius commented on GitHub (Jul 11, 2018):
@mvorisek this is something that is already fixed in
master, but isn't fixable in2.xdue to the proxy system being completely replaced byocramius/proxy-manager.If you think you have an edge case that you'd like to have fixed, please check
99542a2c0f/tests/language-feature-scriptsand add your scenario there.