mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-883: "private" properties and proxy classes. #1097
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 @doctrinebot on GitHub (Nov 18, 2010).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user fumanchu182:
When creating entities I usually create properties with the access level of private. However this prevents Proxy classes from retrieving data via **get or. For example the class
This generates a proxy class that has the following mapping for get:
However the call from a proxy class to lets say $image->getUser()->id; will generate the following error:
Undefined property via __get(): id in /var/www/sites/foobar/library/Application/Entity/Proxy/Application_Entity_UserProxy.php on line
This is due to the access declaration in the original class. I filed this as a bug since I know a lot of the documentation has properties of entities defined as private. Changing those declarations to protected alleviates this issue and also does not introduce any security risks or break the OOP access security. With all this being said if I have missed documentation that says please make all entity properties "protected" ignore this and delete.
@doctrinebot commented on GitHub (Nov 18, 2010):
Comment created by fumanchu182:
Removed personal site information in the text.
@doctrinebot commented on GitHub (Nov 19, 2010):
Comment created by @beberlei:
Since it calls parent::**get() i don't see why there should be a bug in the proxy. From my understanding of PHP OOP Model this should work with private properties.
@doctrinebot commented on GitHub (Nov 19, 2010):
Comment created by @beberlei:
Ah property_exists() is the problem, please try isset($this->$name) or empty.
@doctrinebot commented on GitHub (Nov 19, 2010):
Comment created by fumanchu182:
I created a test entity (posted here) to test and everything seem complacent. If you would like to mark this issue as resolved I would agree that it has been addressed.
@doctrinebot commented on GitHub (Nov 22, 2010):
Issue was closed with resolution "Invalid"