PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Web Services » XML_RPC » Bug #8850

Incorrect serialization of structures

Details

Submitted2006-10-04 16:33 UTC
Frommark at webpit dot com
StatusBogus
PackageXML_RPC
PHP Version4.3.11
OSWindows XP
Roadmaps(Not assigned)

Comments

[2006-10-04 16:33 UTC] mark at webpit dot com

Description:
------------
Associative arrays result in warnings and bad array returned.

I was trying to return an associative array from a function.

$obj=new business();
$data=$obj->getById($id); // data is simple name=value array
$val=new XML_RPC_Value($data,'struct');
$r=new XML_RPC_Response($val);

the client side got lots of this:

Notice: Undefined index: value in C:\www\rivista\core\includes\classes\rpcclient.php on line 512

and this was the resulting value:

Array
(
[struct] => Array
(
[id] =>
[idnum] =>
[datecreated] =>
[datemodified] =>
[type] =>
[company]
... trimmed

my client code snippet:

if (!$resp->faultCode()) {
$val = $resp->value();
echo "<pre>";
print_r($val->me);

Making the following changes fixed it, but i have a feeling my solution isn't "proper"

Line 1701 of the client.php:

original:
$rs.=$this->serializeval($val2);

my fix:
$rs.='<value>' . htmlspecialchars($val2) . "</value>\n";

my new client code snippet:

print_r(XML_RPC_decode($val));

now the returned array is correct and no warnings.