[DCOM-175] Proxies return private properties in __sleep, which is not supported by PHP. Created: 27/Mar/12 Updated: 02/Dec/13 Resolved: 30/Jul/13
|Reporter:||Ryan Mauger||Assignee:||Marco Pivetta|
__sleep should not return private parent property names (see http://php.net/__sleep) this raises notices, and also results in the value of the property being 'N' (null) instead of keeping its value.
I am unfortunately stuck having to serialize proxies in my revision tracking, as doctrine seems to be currently ignoring the fetch="EAGER" I set on the related properties.
Proxies should use the Serializable interface, and not __sleep, or not return parent property names which are private, it serves no purpose, and is not supported by PHP itself anyway.
Also, if you keep __sleep, but do not return the parent property names, then it will only include the items you return, so it would be better to simply drop the __sleep method, I cannot actually see any useful purpose it serves.
|Comment by Ryan Mauger [ 27/Mar/12 ]|
just updated the issue body, realised that I worded something badly.
|Comment by Marco Pivetta [ 23/Jan/13 ]|
Ryan Mauger I think that's a limitation we have. We use `__sleep` to avoid serializing fields like the initializers and the persisters of course.
Even by implementing serializable, it would only work if the end user implemented it in the parent class.
Tempted to mark it as "can't fix"
|Comment by Marco Pivetta [ 24/Jan/13 ]|
I think there's a solution by having something like following:
|Comment by Marco Pivetta [ 23/Feb/13 ]|
Ryan Mauger I started implementing this one at https://github.com/Ocramius/common/compare/hotfix;DCOM-175 and so far it looks promising.
The only doubts so far are with handling cases like following:
So far I didn't get to write tests that demonstrate the exact behaviour for this case, but it looks like when `Serializable` is implemented, `_sleep` and `_wakeup` are ignored. Any thoughts on this?
|Comment by Marco Pivetta [ 19/Apr/13 ]|
A possible solution is to use something like http://eval.in/16806, and thus exploiting the ability of php to retrieve an object's private properties by using the special
This can be abstracted by using
, which retrieves also those special keys
|Comment by Marco Pivetta [ 19/Jun/13 ]|
Provided a fix at https://github.com/doctrine/common/pull/284
|Comment by Marco Pivetta [ 30/Jul/13 ]|