From:             glideraerobatics at hotmail dot com
Operating system: FreeBSD 6.1
PHP version:      5.1.4
PHP Bug Type:     XMLRPC-EPI related
Bug description:  Incorrect encoding of PHP associative arrays in XML-RPC 
response.

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 bug report at http://bugs.php.net/?id=37746&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37746&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=37746&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37746&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37746&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=37746&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37746&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37746&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37746&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37746&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37746&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=37746&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=37746&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37746&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37746&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37746&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37746&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37746&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37746&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37746&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37746&r=mysqlcfg

Reply via email to