ID: 29865 Comment by: cmoore at getzeroedin dot com Reported By: [EMAIL PROTECTED] Status: Open Bug Type: Strings related Operating System: N/A PHP Version: 5CVS-2004-08-27 (dev) New Comment:
I am seeing a similar problem with serializing and unserializing two-dimensional arrays on 4.3.8. When the array reaches a certain size, it appears to get serialized (although I'm not looking at a hex dump), but the unserialize function fails. When the array is small it appears to work fine. Basically I'm using serialization to manage web page state $array_page[]=$_SERVER['PHP_SELF']; $array_requests[]= $_REQUEST; $new_state = array('page' => $array_page, 'reqests' => $_REQUEST); $serial_state = serialize($new_state); Then I store $serial_state into a MySQL text column. Once the first dimension of the array grows to about 9 elements, the unserialize returns false. Previous Comments: ------------------------------------------------------------------------ [2004-08-27 13:37:32] [EMAIL PROTECTED] Description: ------------ Using serialize() with a class produces invalid output. Reproduce code: --------------- I haven't had a chance to properly investigate why this particular code causes a problem, but Derick seemed ontop of it already. <?php class cr { private $priv_member; function cr($val) { $this->priv_member = $val; } function comp_func_cr($a, $b) { if ($a->priv_member === $b->priv_member) return 0; return ($a->priv_member > $b->priv_member)? 1:-1; } function comp_func_key($a, $b) { if ($a === $b) return 0; return ($a > $b)? 1:-1; } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr(3), 1=> new cr(4), 2 => new cr(-15),); $result = array_udiff_uassoc($a, $b, array("cr", "comp_func_cr"), array("cr", "comp_func_key")); $foo = serialize($result); echo $foo; ?> Actual result: -------------- 0000 61 3a 33 3a 7b 73 3a 33 3a 22 30 2e 31 22 3b 4f a:3:{s:3 :"0.1";O 0010 3a 32 3a 22 63 72 22 3a 31 3a 7b 73 3a 31 35 3a :2:"cr": 1:{s:15: 0020 22 00 63 72 00 70 72 69 76 5f 6d 65 6d 62 65 72 ".cr.pri v_member 0030 22 3b 69 3a 39 3b 7d 73 3a 33 3a 22 30 2e 35 22 ";i:9;}s :3:"0.5" 0040 3b 4f 3a 32 3a 22 63 72 22 3a 31 3a 7b 73 3a 31 ;O:2:"cr ":1:{s:1 0050 35 3a 22 00 63 72 00 70 72 69 76 5f 6d 65 6d 62 5:".cr.p riv_memb 0060 65 72 22 3b 69 3a 31 32 3b 7d 69 3a 30 3b 4f 3a er";i:12 ;}i:0;O: 0070 32 3a 22 63 72 22 3a 31 3a 7b 73 3a 31 35 3a 22 2:"cr":1 :{s:15:" 0080 00 63 72 00 70 72 69 76 5f 6d 65 6d 62 65 72 22 .cr.priv _member" 0090 3b 69 3a 32 33 3b 7d 7d ;i:23;}} As you can see from this hexdump, there are 0 bytes being produced. This should not happen. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29865&edit=1