ZF-3705: Zend_Rest_Client_Result does not check if its operating on an object instance

Issue Type: Bug Created: 2008-07-21T12:33:28.000+0000 Last Updated: 2008-11-13T14:09:56.000+0000 Status: Resolved Fix version(s): - 1.7.0 (17/Nov/08)

Reporter: Lukas Smith (lsmith) Assignee: Benjamin Eberlei (beberlei) Tags: - Zend_Rest_Client

Related issues: - ZF-3647



One of the reasons to use the rest client is to get convenient overloading behavior. However if the expected structure of the result does not match, then I can end up with a fatal error unless I manually check.

For example: $pricesList = new Zend_Rest_Client($url); $result = $pricesList->get(); $result->pricesxmlexport->pricesgroup->price

I can easily end up with a fatal error here if the document does not match my expectations. This is due to the fact that the __get() method in Zend_Rest_Client_Result does not check if it can even call the xpath() method in $this->_sxml before calling it.


Posted by Martin Panel (xorax) on 2008-07-24T08:56:44.000+0000

a new class may be created to fix it :

Zend/Rest/Client/Result/Exception.php :

class Zend_Rest_Client_Result_Exception extends Zend_Rest_Client_Exception {}

and after line 43 of Zend/Rest/Client/Result.php:

    $this->_sxml = simplexml_load_string($data);

add :

    if (false === $this->_sxml) {
            throw new Zend_Rest_Client_Result_Exception('simplexml cannot load result data');

Posted by Dave Hall (skwashd) on 2008-07-25T16:25:59.000+0000

This looks like it is related to ZF-3647 and the fix is very similar

Posted by Benjamin Eberlei (beberlei) on 2008-11-07T04:28:22.000+0000

Fixed in trunk. Implementation is using a simple error handler for the Xml parsing to show a specific error message.

Posted by Wil Sinclair (wil) on 2008-11-13T14:09:56.000+0000

Changing issues in preparation for the 1.7.0 release.

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.