ZF-2199: Make loading image details optional to increase performance

Description

Currently, after performing a query in Flickr, one typically iterates over the results using:


$results = $flickr->tagSearch($tagQuery, $options);
foreach ($results as $result) {
  echo $result->id;
  echo $result->Thumbnail->uri;
  //etc
}

Each result is of type Zend_Service_Flickr_Result. In the constructor of this class, additional image details are acquired by performing an additional query, and thus connecting to the Flickr servers:


foreach ($this->_flickr->getImageDetails($this->id) as $k => $v) {
  $this->$k = $v;
}

When the result-set, as mentioned before, gets large, the amount of queries to the Flickr service also increase, decreasing overall performance. For example:

20 images are fetched. Using the basic search command, this requires only one query. But when processing the results, another 20 queries for image details are fired to the Flickr-servers. As a work-around in my web-application, I first send over the image-details to the browser (id, text, etc) and I send over some javascript which performs a new Ajax-call. This Ajax-call results in fetching the details of an image and filling in the src-attribute. of the already loaded skeleton of the image. Now the search takes me only a few miliseconds, after which the user receives a response from the webserver (the image skeletons), and THEN the images start to popup as a result of the Ajax-calls. A disadvantage of this solution is the increased server-load, caused by the various incoming ajax-requests for image details. Nevertheless it significantly decreases the time it takes to send back some result to the user

In summary: I would like to see the option to NOT fetch the imageDetails when processing the results, increasing initial performance and overall user-experience.

Comments

Some typo

This issue should have been fixed for the 1.5 release.

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.

Please evaluate and fix/categorize as necessary.

Hi, I'm quite new to ZF and this is my first comment, so I may be posting to a wrong place, please correct me if I'm wrong. I faced this problem in one of my projects, here is the proposed solution:


  public function __get($name)
  {
    // parameters that are present in initial search result
    if(in_array($name,array('id','owner','secret','server','title','ispublic','isfriend','isfamily')))
    {
      return $this->{$name};
    }
    else
    {
      foreach ($this->_flickr->getImageDetails($this->id) as $k => $v) {
        $this->$k = $v;
      }
    }
    return $this->{$name};
  }

This method is to be added to Zend_Service_Flickr_Result and, obviously, we can remove this foreach loop in constructor.

I have also implemented flickr search by latitude/longitude and bounding box, is it possible to create a ticket and add the code there?

Thanks in advance for your help.

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.