From 12eb905e478ca8700d39c05e18bb522fc2fea62e Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Sun, 8 Aug 2010 10:13:43 -0400 Subject: [PATCH] Don't try to call getImages() if there are no related images --- ansel/lib/Storage.php | 2 +- ansel/lib/Tagger.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) 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; } - } -- 2.11.0