Bug #66085 [NEW]: in function serialize() there is irregular behaviour

From: Date: Tue, 12 Nov 2013 20:21:15 +0000
Subject: Bug #66085 [NEW]: in function serialize() there is irregular behaviour
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182722@lists.php.net to get a copy of this message
From: machine dot check dot exception at gmail dot com Operating system: Windows 7 PHP version: 5.5.5 Package: Arrays related Bug Type: Bug Bug description:in function serialize() there is irregular behaviour Description: ------------ Doing tests I found a different behaviour between versions of php. The code in the test script returns in php 5.2.7, 5.3.0, 5.3.9, this: O:8:"stdClass":1:{s:1:"a";s:4:"tmp1";} O:8:"stdClass":1:{s:1:"a";s:4:"tmp2";} In php 5.4.0RC8, 5.4.3 and 5.5.5 this: O:8:"stdClass":1:{s:1:"a";s:4:"tmp1";} r:3; Test script: --------------- class test implements Serializable { public $a; public function __construct( $_val ){ $this->a = $_val; } public function serialize() { $tmp = (object) array(); $tmp->a = $this->a; echo serialize( $tmp ) . "\n"; return serialize( $tmp ); } } $n = array(); $n[0] = new test('tmp1'); $n[1] = new test('tmp2'); print_r( unserialize( serialize( $n ) ) ); Expected result: ---------------- O:8:"stdClass":1:{s:1:"a";s:4:"tmp1";} O:8:"stdClass":1:{s:1:"a";s:4:"tmp2";} Actual result: -------------- O:8:"stdClass":1:{s:1:"a";s:4:"tmp1";} r:3; -- Edit bug report at https://bugs.php.net/bug.php?id=66085&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66085&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66085&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66085&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66085&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66085&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66085&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66085&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66085&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66085&r=support Expected behavior: https://bugs.php.net/fix.php?id=66085&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66085&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66085&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66085&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66085&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66085&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66085&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66085&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66085&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66085&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66085&r=mysqlcfg

« previous php.bugs (#182722) next »