ID:               37746
 Updated by:       [EMAIL PROTECTED]
 Reported By:      glideraerobatics at hotmail dot com
-Status:           Open
+Status:           Wont fix
 Bug Type:         XMLRPC-EPI related
 Operating System: FreeBSD 6.1
 PHP Version:      5.1.4
 New Comment:

It's been that way since the very first release, if the array contains
numeric indices only.



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

[2006-06-08 15:02:04] lars dot maes at gmail dot com

I confirm this bug on Debian 3.1a sarge with php4 version 4.3.10

The chr(0x00) solution also works

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

[2006-06-08 14:16:45] glideraerobatics at hotmail dot com

By the way, a quick workaround to the problem is to append a NULL byte
to the keys:

$key1 = '666' . chr(0x00);

This way the hash is returned as a correct xml-rpc response without the
NULL bytes.

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

[2006-06-08 14:02:55] glideraerobatics at hotmail dot com

Description:
------------
I've noticed that when a key of a hash begins with a digit between 1
and 9 that the resulting XML-RPC response will contain an empty key.

This array:
$result = array('666' => 'me', '007' => 'Bond');

will be returned as this which is obviously wrong:
<?xml version="1.0" encoding="iso-8859-1"?>
<methodResponse>
<params>
 <param>
  <value>
   <struct>
    <member>
     <name/>
     <value>
      <string>me</string>
     </value>
    </member>
    <member>
     <name>007</name>
     <value>
      <string>bond</string>
     </value>
    </member>
   </struct>
  </value>
 </param>
</params>
</methodResponse>


Clearly the xmlrpc module has correctly detected that the result is a
hash and has therefore made a 'struct'. What it didn't do correctly for
some strange reason is treat all keys of the hash as strings (they even
really are strings - ask gettype()).


Reproduce code:
---------------
function debug_getHash($method_name, $params, $app_data) {
  $key1 = '666';
  $key2 = '007';
  $result = array(
    $key1   => 'key1 is a ' . gettype($key1),
    $key2   => 'key2 is a ' . gettype($key2),
  );
  return $result;
}
xmlrpc_server_register_method($xmlrpc_server, 'debug.getHash',
'debug_getHash');

Expected result:
----------------
<?xml version="1.0" encoding="iso-8859-1"?>
<methodResponse>
<params>
 <param>
  <value>
   <struct>
    <member>
     <name>666</name>
     <value>
      <string>key1 is a string</string>
     </value>
    </member>
    <member>
     <name>007</name>
     <value>
      <string>key2 is a string</string>
     </value>
    </member>
   </struct>
  </value>
 </param>
</params>
</methodResponse>


Actual result:
--------------
<?xml version="1.0" encoding="iso-8859-1"?>
<methodResponse>
<params>
 <param>
  <value>
   <struct>
    <member>
     <name/>
     <value>
      <string>key1 is a string</string>
     </value>
    </member>
    <member>
     <name>007</name>
     <value>
      <string>key2 is a string</string>
     </value>
    </member>
   </struct>
  </value>
 </param>
</params>
</methodResponse>



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


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

Reply via email to