Issues

ZF-1307: Fatal error resulting from bug in getInfo() method

Issue Type: Bug Created: 2007-04-23T15:29:01.000+0000 Last Updated: 2008-02-26T12:55:58.000+0000 Status: Resolved Fix version(s): - 1.0.4 (26/Feb/08)

Reporter: Darby Felton (darby) Assignee: Simone Carletti (weppos) Tags: - Zend_Service_Audioscrobbler

Related issues: Attachments:

Description

Posting on behalf of [~cgraefe]; have not yet confirmed issue. Deferring to [~chartjes] for initial comment.

Thank you for implementing the interface to the Audioscrobbler web service in Zend Framework! Currently, there is an annoying bug in the private getInfo() method, though. The following code example:

<pre class="highlight">
$as = new Zend_Service_Audioscrobbler(); 
$as->set('artist', 'This is an unknown artist.'); 
$as->set('track', 'Track does not matter.'); 
$tags = $as->trackGetTopTags(); 

results in a PHP Fatal error:

PHP Fatal error: Call to a member function getStatus() on a non-object in /var/httpd/servers/noise.graefe.net/lib/ZendFramework-0.9.1-Beta/library/Zend/Service/Audioscrobbler.php on line 165

My suggestion is to change the error handling in getInfo() to something like this:

<pre class="highlight">
if ($response == 'No such path') { 
    throw new Zend_Http_Client_Exception('Could not find: ' . $this->_client->getUri()); 
} else if ($request->isError()) { 
    if (is_object($response)) { 
        throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $response->getStatus()); 
    } else { 
        throw new Zend_Http_Client_Exception( $response ); 
    } 
} else { 
    return simplexml_load_string($response); 
}

I would have opened an issue in the tracker but either I'm to blind to find the button to do so, or I'm not allowed to. :)

Comments

Posted by Eric Coleman (eric) on 2007-07-25T10:05:38.000+0000

You should be able to fix it using the following... $response is actually the body in most cases (or all I believe)

<pre class="highlight">
Index: Audioscrobbler.php
===================================================================
--- Audioscrobbler.php  (revision 5842)
+++ Audioscrobbler.php  (working copy)
@@ -177,7 +177,7 @@
         } else if ($response == 'No user exists with this name.') {
             throw new Zend_Http_Client_Exception('No user exists with this name');
         } else if ($request->isError()) {
-            throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $response->getStatus());
+            throw new Zend_Http_Client_Exception('The web service ' . $this->_client->getUri() . ' returned the following status code: ' . $request->getStatus() . ' ' . $request->getMessage());
         }
 
         set_error_handler(array($this, '_errorHandler'));

Posted by Chris Hartjes (chartjes) on 2007-08-24T13:44:45.000+0000

This looks okay to me, I'll see if I can free up some time to fix it.

Posted by Simone Carletti (weppos) on 2008-01-14T04:07:48.000+0000

Fixed in r7419 (unit tests available).

Posted by Simone Carletti (weppos) on 2008-01-29T14:39:07.000+0000

Merged to branch/release-1.0 (r7688), target changed to mini release.

Have you found an issue?

See the Overview section for more details.

Copyright

© 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.

Contacts