[DDC-1186] Proxy Objects are incompatible with Serialization Created: 01/Jun/11  Updated: 01/Jun/11  Resolved: 01/Jun/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Johannes Schmitt Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

Lazy-loading users is impossible atm if you want to serialize them at some point, and they are using private member variables.

My suggestion is to check whether the proxied class implements the Serializable interface, and in these cases instead of implementing a __sleep method, a serialize/unserialize method should be implemented instead.

Something like:

public function serialize()

{ return serialize(array($this->__isInitialized__, parent::serialize())); }

public function unserialize($str)

{ list($this->__initialized__, $parentStr) = unserialize($str); parent::unserialize($parentStr); }

At the moment, this makes Doctrine Proxy objects incompatible with the Symfony Security component, and if possible it should be fixed for the 2.1 release. If you need help on this, let me know.



 Comments   
Comment by Johannes Schmitt [ 01/Jun/11 ]

Closing this, not sure what I was debugging there, the problem is a Symfony one

Generated at Fri Aug 01 07:54:22 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.