Zend Framework

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

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.1
  • Fix Version/s: 1.0.3
  • Component/s: Zend_XmlRpc_Client
  • Labels:
    None
  • Fix Version Priority:
    Must Have

Description

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.

Activity

Hide
Robert Castley added a comment -

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!

Show
Robert Castley added a comment - 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!
Hide
Robert Castley added a comment -

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

Cheers!

Show
Robert Castley added a comment - Just upgrade to PHP 5.2.5 and the above issue/problem still exists. Cheers!
Hide
Till Klampaeckel added a comment -

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

Show
Till Klampaeckel added a comment - I ran into this as well, so the sooner this is fixed, the better(er).
Hide
Matthew Weier O'Phinney added a comment -

Scheduling for 1.0.3

Show
Matthew Weier O'Phinney added a comment - Scheduling for 1.0.3
Hide
Matthew Weier O'Phinney added a comment -

Fixed in trunk and release branch as of r6884.

Show
Matthew Weier O'Phinney added a comment - Fixed in trunk and release branch as of r6884.
Hide
Matthew Weier O'Phinney added a comment -

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

Show
Matthew Weier O'Phinney added a comment - Closed the wrong issue last time; meant to close ZF-2053. Reopening
Hide
Matthew Weier O'Phinney added a comment -

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.

Show
Matthew Weier O'Phinney added a comment - 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.
Hide
Robert Castley added a comment -

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!

Show
Robert Castley added a comment - 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!
Hide
Matthew Weier O'Phinney added a comment -

Merged to release branch r6930.

Show
Matthew Weier O'Phinney added a comment - Merged to release branch r6930.

People

Vote (2)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
1h
Original Estimate - 1 hour
Remaining:
1h
Remaining Estimate - 1 hour
Logged:
Not Specified
Time Spent - Not Specified