ID:               29323
 Comment by:       php at mojeime dot com
 Reported By:      ralf dot praschak at gmx dot net
 Status:           Open
 Bug Type:         WDDX related
 Operating System: windows 2000 professional sp4
 PHP Version:      5.0.0
 New Comment:

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!!!


Previous Comments:
------------------------------------------------------------------------

[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.

------------------------------------------------------------------------

[2004-09-06 17:43:51] s dot lemke at infoworxx dot de

I experienced the same behaviour with php 5.0.1 running on
linux/apache.

------------------------------------------------------------------------

[2004-07-22 11:56:01] 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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=29323&edit=1

Reply via email to