diff --git a/src/ArrayObject.php b/src/ArrayObject.php index ac64dfc12..b4d9eb79d 100644 --- a/src/ArrayObject.php +++ b/src/ArrayObject.php @@ -404,10 +404,13 @@ public function uksort($function) */ public function unserialize($data) { - $ar = unserialize($data); + $ar = unserialize($data); + $this->protectedProperties = array_keys(get_object_vars($this)); + $this->setFlags($ar['flag']); $this->exchangeArray($ar['storage']); $this->setIteratorClass($ar['iteratorClass']); + foreach ($ar as $k => $v) { switch ($k) { case 'flag': diff --git a/test/ArrayObjectTest.php b/test/ArrayObjectTest.php index dd1c5fcab..5685d1dda 100644 --- a/test/ArrayObjectTest.php +++ b/test/ArrayObjectTest.php @@ -351,4 +351,15 @@ public function testUksort() $this->assertSame($sorted, $ar->getArrayCopy()); } + /** + * @group 6089 + */ + public function testSerializationRestoresProperties() + { + $ar = new ArrayObject(); + $ar->foo = 'bar'; + $ar['bar'] = 'foo'; + + $this->assertEquals($ar, unserialize(serialize($ar))); + } }