From: Chuck Hagenbuch Date: Sun, 8 Aug 2010 14:13:43 +0000 (-0400) Subject: Don't try to call getImages() if there are no related images X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=12eb905e478ca8700d39c05e18bb522fc2fea62e;p=horde.git Don't try to call getImages() if there are no related images --- diff --git a/ansel/lib/Storage.php b/ansel/lib/Storage.php index 2664c6bb9..90c472fc0 100644 --- a/ansel/lib/Storage.php +++ b/ansel/lib/Storage.php @@ -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? */ diff --git a/ansel/lib/Tagger.php b/ansel/lib/Tagger.php index f9592d923..02690cc16 100644 --- a/ansel/lib/Tagger.php +++ b/ansel/lib/Tagger.php @@ -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; } - }