From: Operating system: Windows XP SP3 PHP version: 5.2.17 Package: Class/Object related Bug Type: Bug Bug description:serialize a private attribute give it a bad length string
Description: ------------ When you serialize an object with private or protected members, their length names are baddly calculated (maybe because of "These prepended values [which] have null bytes on either side" like the documentation says. Anyway, this is a problem when you want to write your serialisation into a file and analyse it next. Note that I'm not using PHP 5.2.17 but 5.2.3. But I haven't read a fix of this problem between both version. Test script: --------------- Here is an example: class Ab { private $_i = 0; public function __construct() { $this->_i = 1; } }; $oAB = new Ab(); $str = serialize($oAB); echo $str; Expected result: ---------------- O:2:"Ab":1:{s:4:"Ab_i";i:1;} Actual result: -------------- O:2:"Ab":1:{s:6:"Ab_i";i:1;} Note the "s:6" instead of "s:4": this is why the unserialization from this string is impossible. -- Edit bug report at http://bugs.php.net/bug.php?id=55011&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=55011&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=55011&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=55011&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=55011&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=55011&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=55011&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=55011&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=55011&r=needscript Try newer version: http://bugs.php.net/fix.php?id=55011&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=55011&r=support Expected behavior: http://bugs.php.net/fix.php?id=55011&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=55011&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=55011&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=55011&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=55011&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=55011&r=dst IIS Stability: http://bugs.php.net/fix.php?id=55011&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=55011&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=55011&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=55011&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=55011&r=mysqlcfg