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
Posted by Robert Castley (rcastley) on 2007-11-08T10:17:14.000+0000
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!
Posted by Robert Castley (rcastley) on 2007-11-13T04:22:28.000+0000
Just upgrade to PHP 5.2.5 and the above issue/problem still exists.
Cheers!
Posted by Till Klampaeckel (till) on 2007-11-14T13:02:13.000+0000
I ran into this as well, so the sooner this is fixed, the better(er). :)
Posted by Matthew Weier O'Phinney (matthew) on 2007-11-16T15:06:11.000+0000
Scheduling for 1.0.3
Posted by Matthew Weier O'Phinney (matthew) on 2007-11-20T15:46:01.000+0000
Fixed in trunk and release branch as of r6884.
Posted by Matthew Weier O'Phinney (matthew) on 2007-11-20T15:47:03.000+0000
Closed the wrong issue last time; meant to close ZF-2053. Reopening
Posted by Matthew Weier O'Phinney (matthew) on 2007-11-20T16:21:56.000+0000
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.
Posted by Robert Castley (rcastley) on 2007-11-21T03:58:56.000+0000
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!
Posted by Matthew Weier O'Phinney (matthew) on 2007-11-25T13:02:39.000+0000
Merged to release branch r6930.