ID: 29323 Updated by: php-bugs@lists.php.net Reported By: ralf dot praschak at gmx dot net -Status: Feedback +Status: No Feedback Bug Type: WDDX related Operating System: windows 2000 professional sp4 PHP Version: 5.0.0 New Comment:
No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". Previous Comments: ------------------------------------------------------------------------ [2005-03-06 20:51:57] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2004-11-19 09:08:14] pauls at sellingsource dot com I am using 5.0.3-DEV (Stable Snapshot 200411161730). Deserialization works fine for objects that are all public. However as soon as the object has private or protected member variables, the result bombs. Sample code: (Failure Only) --------------------------- try { throw new Exception ("FooBar", 1111); } catch (Exception $e) { $s = wddx_serialize_value ($e); } $t = wddx_deserialize($s); print_r ($t); ---------------- Expected Result: ---------------- Exception Object ( [message:protected] => FooBar [string:private] => [code:protected] => 1111 [file:protected] => /virtualhosts/test/wddx3.php [line:protected] => 4 [trace:private] => Array ( ) ) -------------- Actual Result: -------------- Exception Object ( [message:protected] => [string:private] => [code:protected] => 0 [file:protected] => /virtualhosts/test/wddx3.php [line:protected] => 16 [trace:private] => Array ( ) [0] => FooBar [1] => [2] => 1111 [3] => /virtualhosts/test/wddx3.php [4] => 4 [5] => Array ( ) ) ------------------------------------------------------------------------ [2004-11-18 19:22:41] php at mojeime dot com There is a BUG. And a major one. The most interesting aspect of this bug is that the deserialization works perfectly under Zend Development Environment (3.5.0) but does not work under my Apache 2.50 /PHP5.0.2. I'm using Win2003. But the problem isn't in Apache (it seems), because the same bug occurs when I run my .php file with php.exe. DO SOMETHING!!! ------------------------------------------------------------------------ [2004-10-16 23:08:43] php at stew dot org More info on my previous note. Sample code: ------------------------------------------------------------- <? function SanitizeArray ($arr) { if (!is_array($arr)) { return $arr; }; while (list($key,$val) = each($arr) ){ if (is_array($val)) { $val = SanitizeArray($val); }; $rtn[$key] = $val; }; return $rtn; }; $test = array( 0 =>array( 'me' => "you" ), 'one' => array( 'me' => "you" ) ); print "<PRE>"; var_dump($test); print $test[0]['me'] . "\n"; print $test['0']['me'] . "\n"; print $test['one']['me'] . "\n"; $ddx = wddx_serialize_vars("test"); $after = wddx_deserialize($ddx); var_dump($after['test']); print $after['test'][0]['me'] . "\n"; print $after['test']['0']['me'] . "\n"; print $after['test']['one']['me'] . "\n"; list($key,$val) = each($after['test']); print gettype($key); $clean = SanitizeArray($after); var_dump($clean['test']); print $clean['test'][0]['me'] . "\n"; print $clean['test']['0']['me'] . "\n"; print $clean['test']['one']['me'] . "\n"; list($key,$val) = each($after['test']); print gettype($key); print "</PRE>"; phpinfo(); ?> ----------------------------------------------------------- Produces: array(2) { [0]=> array(1) { ["me"]=> string(3) "you" } ["one"]=> array(1) { ["me"]=> string(3) "you" } } you you you array(2) { ["0"]=> array(1) { ["me"]=> string(3) "you" } ["one"]=> array(1) { ["me"]=> string(3) "you" } } Notice: Undefined offset: 0 in C:\Program Files\Apache Group\Apache2\htdocs\syncit\test.php on line 27 Notice: Undefined index: 0 in C:\Program Files\Apache Group\Apache2\htdocs\syncit\test.php on line 28 you stringarray(2) { [0]=> array(1) { ["me"]=> string(3) "you" } ["one"]=> array(1) { ["me"]=> string(3) "you" } } you you you string ----------------------------------------------------------- PHP Version 5.0.0 Windows NT COUNTER-3 5.0 build 2195 Build Date: Jul 13 2004 21:34:42 ------------------------------------------------------------------------ [2004-10-16 22:39:54] php at stew dot org I am also having difficulty with deserialize. If I take an array and run wddx_serialize_vars("thisarr"). Then take the result and deserialize it, any array keys that are numbers produce a "no such index" when dereferencing. I was able to work around the problem with the following: function SanitizeArray ($arr) { if (!is_array($arr)) { return $arr; }; while (list($key,$val) = each($arr) ){ if (is_array($val)) { $val = SanitizeArray($val); }; $rtn[$key] = $val; }; return $rtn; }; array keys that were strings did not have any problems. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/29323 -- Edit this bug report at http://bugs.php.net/?id=29323&edit=1