|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-02-17 02:33 UTC] laruence@php.net
-Status: Open
+Status: Verified
-Assigned To:
+Assigned To: mike
[2013-02-20 03:33 UTC] laruence@php.net
[2013-02-20 09:07 UTC] mike@php.net
[2013-02-20 10:42 UTC] mike@php.net
[2013-02-20 14:47 UTC] laruence@php.net
[2013-02-20 14:56 UTC] mike@php.net
[2013-02-20 15:03 UTC] laruence@php.net
[2013-02-20 22:02 UTC] cameron dot junge at sella dot co dot nz
[2013-08-19 20:48 UTC] mike@php.net
-Status: Verified
+Status: Wont fix
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 20:00:02 2025 UTC |
Description: ------------ When trying to serialize an inherited object, PHP 5.4 serializes the inherited object as a reference to the parent object, when there is no parent object to reference. This works fine in PHP 5.3. See test script for an example. Test script: --------------- class A implements \Serializable { public function serialize() { $s = new \stdClass(); $s->id = 1; var_dump($s); return serialize($s); } public function unserialize($s) { } } class B extends A { public function serialize() { $p = parent::serialize(); $s = unserialize($p); $s->foo = 'bar'; $s2 = serialize($s); var_dump($p, $s, $s2); // $s2 = 'r:2' //var_dump(unserialize($s2)); // will throw error as can't unserialize die; //return serialize($s); } } $b = new B; serialize($b); Expected result: ---------------- // PHP5.3.6 object(stdClass)[794] public 'id' => int 1 string 'O:8:"stdClass":1:{s:2:"id";i:1;}' (length=32) object(stdClass)[794] public 'id' => int 1 public 'foo' => string 'bar' (length=3) string 'O:8:"stdClass":2:{s:2:"id";i:1;s:3:"foo";s:3:"bar";}' (length=52) Actual result: -------------- // PHP 5.4.11 object(stdClass)[794] public 'id' => int 1 string 'O:8:"stdClass":1:{s:2:"id";i:1;}' (length=32) object(stdClass)[794] public 'id' => int 1 public 'foo' => string 'bar' (length=3) string 'r:2;' (length=4)