diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index a45b8bf08..f5e75a19c 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -117,6 +117,8 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection */ private $_isDirty = false; + private $_isSerializing = false; + /** * Creates a new persistent collection. */ @@ -427,4 +429,18 @@ final class PersistentCollection extends \Doctrine\Common\Collections\Collection { $this->_isDirty = $dirty; } + + /* Serializable implementation */ + + /** + * Called by PHP when this collection is serialized. Ensures that only the + * elements are properly serialized. + * + * @internal Tried to implement Serializable first but that did not work well + * with circular references. This solution seems simpler and works well. + */ + public function __sleep() + { + return array('_elements'); + } } \ No newline at end of file