php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29323 php5 cannot deserialize greater wddx packets
Submitted: 2004-07-22 11:56 UTC Modified: 2005-03-14 01:00 UTC
Votes:7
Avg. Score:5.0 ± 0.0
Reproduced:7 of 7 (100.0%)
Same Version:4 (57.1%)
Same OS:1 (14.3%)
From: ralf dot praschak at gmx dot net Assigned:
Status: No Feedback Package: WDDX related
PHP Version: 5.0.0 OS: windows 2000 professional sp4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ralf dot praschak at gmx dot net
New email:
PHP Version: OS:

 

 [2004-07-22 11:56 UTC] ralf dot praschak at gmx dot net
Description:
------------
for exchanging a screenshot gallery i decode every exif information in a wddx packet. worked without problems in php4.3.x under win32 and linux.

now with php5.0.0, the wddx is generated proberly but cannot deserialized. if i reduce the size of the hash, it works, but that is not a solution. the error.log from apache shows nothing hintful.

Reproduce code:
---------------
1. the wddx generation
// save the cache file
	$wddx = wddx_packet_start("Screenshots");
	wddx_add_vars($wddx, "sort");
	$wddx = wddx_packet_end($wddx);
	$wddx = addslashes($wddx);

	$file = $_cache."_includes/screenshots.wddx.php";
	$fp = fopen($file, "w");
	fwrite($fp, $wddx);
	fclose($fp);

2. the deserialize process
// read wddx cache file
	$wddx = file_get_contents($_cache."_includes/screenshots.wddx.php");
	$wddx = stripslashes($wddx);
	$wddx = wddx_deserialize($wddx);
	$wddx = $wddx["sort"];

Expected result:
----------------
an array with the original hash

Actual result:
--------------
an empty result

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-06 17:43 UTC] s dot lemke at infoworxx dot de
I experienced the same behaviour with php 5.0.1 running on linux/apache.
 [2004-10-16 22:39 UTC] 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.
 [2004-10-16 23:08 UTC] 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-11-18 19:22 UTC] 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-11-19 09:08 UTC] 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
        (
        )
)
 [2005-03-06 20:51 UTC] sniper@php.net
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


 [2005-03-14 01:00 UTC] php-bugs at lists dot php dot net
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".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC