Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.5

Bug #1493 XML_RPC_encode for empty array returns "struct" and not "array".
Submitted: 2004-05-25 13:09 UTC
From: pash_ka at fonbet dot info Assigned: danielc
Status: Closed Package: XML_RPC
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 21 - 19 = ?

 
 [2004-05-25 13:09 UTC] pash_ka at fonbet dot info
Description: ------------ I need to send an array to client. Sometimes this array is empty. In this case XML_RPC_encode() doesn't work as expected, and returns struct, and not array. The code in RPC.php now is ================= if ($firstkey === 0 && is_int($lastkey) && ($lastkey + 1) == $count) { ================= I think, it should be sonmething like this ================= if (($firstkey === null)||($firstkey === 0 && is_int($lastkey) && ($lastkey + 1) == $count)) { =================

Comments

 [2004-12-01 00:39 UTC] techtonik at tut dot by
Another patch. Please test this. --- E:\RPC_olda.php Wed Dec 01 01:05:54 2004 +++ E:\RPC_oldb.php Wed Dec 01 02:37:42 2004 @@ -1133,29 +1133,17 @@ switch ($type) { case "array": + // convert continuous non-associative array to <array> else to <struct> $keys = array_keys($php_val); - $count = count($php_val); - $firstkey = $keys[0]; - $lastkey = $keys[$count - 1]; - if ($firstkey === 0 && is_int($lastkey) && ($lastkey + 1) == $count) { - $is_continuous = true; - $expected = 0; - foreach ($keys as $actual) { - if ($actual != $expected) { - $is_continuous = false; - break; - } - $expected++; - } - - if ($is_continuous) { - $arr = array(); - foreach ($php_val as $k => $v) { - $arr[$k] = XML_RPC_encode($v); - } - $XML_RPC_val->addArray($arr); - break; + $expected = 0; + while ((($k = array_shift($keys)) !== NULL) && ($k != $expected++)); + if ($k === NULL) { + $arr = array(); + foreach ($php_val as $k => $v) { + $arr[$k] = XML_RPC_encode($v); } + $XML_RPC_val->addArray($arr); + break; } // fall though if not numerical and continuous case "object":
 [2004-12-29 19:01 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!