History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ZF-2092
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Matthew Weier O'Phinney
Reporter: Andrey Lebedev
Votes: 2
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

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

Created: 22/Oct/07 07:12 AM   Updated: 15/Dec/07 09:52 PM
Component/s: Zend_XmlRpc_Client
Affects Version/s: 1.0.1
Fix Version/s: 1.0.3

Time Tracking:
Original Estimate: 1 hour
Original Estimate - 1 hour
Remaining Estimate: 1 hour
Remaining Estimate - 1 hour
Time Spent: Not Specified
Remaining Estimate - 1 hour

 Public Fields   Internal Project Management Fields   
Tags:
Participants: Andrey Lebedev, Matthew Weier O'Phinney, Robert Castley and Till Klampaeckel
Fix Version Priority: Must Have


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

...<member><name>messages</name><value><array><data/></array></value></member>...

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("<array><data/></array>");
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.



 All   Comments   Work Log   Change History   FishEye   Crucible      Sort Order: Ascending order - Click to sort in descending order
Robert Castley - 08/Nov/07 10:17 AM
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!


Robert Castley - 13/Nov/07 04:22 AM
Just upgrade to PHP 5.2.5 and the above issue/problem still exists.

Cheers!


Till Klampaeckel - 14/Nov/07 01:02 PM
I ran into this as well, so the sooner this is fixed, the better(er).

Matthew Weier O'Phinney - 16/Nov/07 03:06 PM
Scheduling for 1.0.3

Matthew Weier O'Phinney - 20/Nov/07 03:46 PM
Fixed in trunk and release branch as of r6884.

Matthew Weier O'Phinney - 20/Nov/07 03:47 PM
Closed the wrong issue last time; meant to close ZF-2053. Reopening

Matthew Weier O'Phinney - 20/Nov/07 04:21 PM
A fix is present in trunk as of r6885. I've used children() to determine if a <data> 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.

Robert Castley - 21/Nov/07 03:58 AM
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!


Matthew Weier O'Phinney - 25/Nov/07 01:02 PM
Merged to release branch r6930.