ZF-2092: XML-RPC client fails during parsing of response with empty array on PHP-5.2.4

Description

Under PHP-5.2.4 Zend_XmlRpc client fails to parse responses that contain empty arrays, like this:

{{...messages...}}

I've found the probable cause for it: behavour of empty() function on SimpleXMLElement objects is changed in PHP-5.2.4 (see http://www.php.net/ChangeLog-5.php) and the following script:

{{$xml = new SimpleXMLElement("");}} {{echo "Element is empty: "; echo empty($xml->data);}}

prints {{false}} under PHP<5.2.4 and {{true}} under PHP-5.2.4.

Zend_XmlRpc checks for value of empty($value->data) in {{Zend/XmlRpc/Value.php}} line 330 and throws exception when $value->data is false (it is the case on PHP-5.2.4).

Proposed solution is to use {{isset($value->data)}} in that condition, since empty arrays are perfectly valid in XML-RPC responses.

Comments

I am running ZF 1.0.2 under PHP 5.2.4 and can confirm this is an issue. I did try the above proposed solution but it didn't fix things for me.

When I get returned an empty array I get the Exception: Array ( [Error] => 651 [Message] => Failed to parse response ).

If I comment out lines 330 & 331 in Zend/XmlRpc/Value.php I get an empty Array() returned

If I change line 330 to use isset then I get the Exception: Array ( [Error] => 653 [Message] => Invalid XMLRPC value in response

Happy to test/try out any more suggestions

Many thanks!

Just upgrade to PHP 5.2.5 and the above issue/problem still exists.

Cheers!

I ran into this as well, so the sooner this is fixed, the better(er). :)

Scheduling for 1.0.3

Fixed in trunk and release branch as of r6884.

Closed the wrong issue last time; meant to close ZF-2053. Reopening

A fix is present in trunk as of r6885. I've used children() to determine if a element is present; if not, I throw an exception, otherwise I set the initial value to an empty array and attempt to populate it by iterating over $data->value. Please test and let me know if this works in >=5.2.4 ( I don't have 5.2.4 installed currently); if so, I will merge to the release branch.

Hi,

I am now running on 5.2.5 and as far as I can see no changes were made to simplexml from 5.2.4 and the problem still exists under ZF 1.0.2. I have just downloaded from FishEye the xmlrpc part of the framework and installed and tested and I now can handle empty arrays :-)

So, initial testing is looking positive, will continue and report back again at the end of this week to confirm.

Many thanks!

Merged to release branch r6930.