Don't try to call getImages() if there are no related images
authorChuck Hagenbuch <chuck@horde.org>
Sun, 8 Aug 2010 14:13:43 +0000 (10:13 -0400)
committerChuck Hagenbuch <chuck@horde.org>
Sun, 8 Aug 2010 14:13:43 +0000 (10:13 -0400)
ansel/lib/Storage.php
ansel/lib/Tagger.php

index 2664c6b..90c472f 100644 (file)
@@ -605,7 +605,7 @@ class Ansel_Storage
                 $sql .= (int)$id . (($i++ < $cnt) ? ',' : ');');
             }
         } else {
-            throw new Ansel_Exception('Ansel_Storage::getImages requires either a gallery_id or an array of images_ids');
+            throw new Ansel_Exception('Ansel_Storage::getImages requires either a gallery_id or an array of image ids');
         }
 
         /* Limit the query? */
index f9592d9..02690cc 100644 (file)
@@ -370,17 +370,20 @@ class Ansel_Tagger
             throw new Ansel_Exception($e);
         }
 
+        if (count($ids) == 0) {
+            return array();
+        }
+
         try {
             $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImages(array('ids' => array_keys($ids)));
         } catch (Horde_Exception_NotFound $e) {
             $images = array();
         }
+
         $results = array();
         foreach ($images as $key => $image) {
             $results[] = array('image' => $image, 'rank' => $ids[$key]);
         }
-
         return $results;
     }
-
 }