ZF-10914: Zend_XmlRpc_Value converts Integer to String param

Issue Type: Bug Created: 2011-01-05T03:38:42.000+0000 Last Updated: 2011-01-08T13:20:34.000+0000 Status: Resolved Fix version(s): - 1.11.3 (01/Feb/11)

Reporter: Alexey Bass (alexey.bass) Assignee: Ramon Henrique Ornelas (ramon) Tags: - Zend_XmlRpc_Client

Related issues: - ZF-10920



Yesterday I've updated ZF from 1.11.1 to 1.11.2 and today morning got some errors with Zend_XmlRpc_Client.

I have remote XML-RPC server that has one of following methods signature:

<pre class="highlight">
simulator.copySetupDevices(String dstIp, Integer dstPort, String setupName, String options)

I was using this code to communicate with it:

<pre class="highlight"> 
$client = new Zend_XmlRpc_Client($connectUrl);
$params = array('', 9999, 'TestReload3', '{}');
$client->call('simulator.copySetupDevices', $params);

Until 1.11.2 it worked fine. But after upgrade I got an exception

<pre class="highlight">
No method matching arguments: java.lang.String, java.lang.String, java.lang.String, java.lang.String

I see from here that while passing second argument as PHP Integer, it was converted in ZF to String somewhere.

Debugging the code I found that problem in Zend_XmlRpc_Value::getXmlRpcValue().

Auto-detecting type done via

<pre class="highlight">

On line 318 we got switch that returns 'int' for our '(int) 9999'.

<pre class="highlight">
switch (self::getXmlRpcTypeByValue($value))

That's fine, but switch's case for Integers is case 'integer': (@line 349), so we bypass it and goto the default: which is

<pre class="highlight">
return new Zend_XmlRpc_Value_String($value)

In ZF 1.11.1 switch was returning 'integer' for Integers because of gettype()

<pre class="highlight">
switch (gettype($value))

I think Matthew missed this when committed new Zend/XmlRpc/Value.php

<pre class="highlight">
@version    $Id: Value.php 23584 2010-12-28 19:51:49Z matthew $

Proposed solution - change to

<pre class="highlight">


case 'integer':


Posted by Alexey Bass (alexey.bass) on 2011-01-05T05:13:07.000+0000

better formatting

Posted by Alexey Bass (alexey.bass) on 2011-01-05T05:38:38.000+0000

Meanwhile workaround is to use Zend_XmlRpc_Value_* class

<pre class="highlight">
$client = new Zend_XmlRpc_Client($connectUrl);

$params = array(
  new Zend_XmlRpc_Value_Integer(9999),

$client->call('simulator.copySetupDevices', $params);

Posted by Tim Rupp (caphrim007) on 2011-01-07T08:30:10.000+0000

It goes further than just integers.

The Zend_XmlRpc_Value class also appears to have done away with the struct type. So associative arrays are converted to strings too. Note the _phpVarToNativeXmlRpc method and how it is missing a case for 'struct' in the switch statement

switch (self::getXmlRpcTypeByValue($value))

line 318

There is an array type, but no struct type even though the array case very explicitly shows Struct code.

Posted by Ramon Henrique Ornelas (ramon) on 2011-01-08T13:20:02.000+0000

The merge r23584 incomplete fixed with r23624 - thanks.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.