Browse Source

bux fix: getTagsForElementSearch: si le tableau d'ids était vide, err 500.

bastien 13 years ago
parent
commit
666c5fb2ab
1 changed files with 13 additions and 10 deletions
  1. 13 10
      src/Muzich/CoreBundle/Repository/TagRepository.php

+ 13 - 10
src/Muzich/CoreBundle/Repository/TagRepository.php View File

@@ -44,16 +44,19 @@ class TagRepository extends EntityRepository
44 44
   public function getTagsForElementSearch($ids)
45 45
   {
46 46
     $tags = array();
47
-    foreach ($this->getEntityManager()
48
-      ->createQuery('
49
-        SELECT t.id, t.name FROM MuzichCoreBundle:Tag t
50
-        WHERE t.id IN (:ids)
51
-        ORDER BY t.name ASC'
52
-      )
53
-      ->setParameter('ids', $ids)
54
-      ->getArrayResult() as $tag)
55
-    {
56
-      $tags[$tag['id']] = $tag['name'];
47
+    if (count($ids))
48
+      {
49
+      foreach ($this->getEntityManager()
50
+        ->createQuery('
51
+          SELECT t.id, t.name FROM MuzichCoreBundle:Tag t
52
+          WHERE t.id IN (:ids)
53
+          ORDER BY t.name ASC'
54
+        )
55
+        ->setParameter('ids', $ids)
56
+        ->getArrayResult() as $tag)
57
+      {
58
+        $tags[$tag['id']] = $tag['name'];
59
+      }
57 60
     }
58 61
     
59 62
     return $tags;