Browse Source

Evolution #188: Recherche: tags strict

bastien 12 years ago
parent
commit
a7fdad8924

+ 12 - 3
src/Muzich/CoreBundle/Repository/ElementRepository.php View File

@@ -223,9 +223,18 @@ class ElementRepository extends EntityRepository
223 223
         $strict_element_ids[] = $strict_id['element_id'];
224 224
       }
225 225
       
226
-      $where_tag_strict = ($is_where) ? ' AND' : ' WHERE';
227
-      $where_tag_strict .= ' e_.id IN (:tag_strict_ids)';
228
-      $params_ids['tag_strict_ids'] = $strict_element_ids;
226
+      if (count($strict_element_ids))
227
+      {
228
+        $where_tag_strict = ($is_where) ? ' AND' : ' WHERE';
229
+        $where_tag_strict .= ' e_.id IN (:tag_strict_ids)';
230
+        $params_ids['tag_strict_ids'] = $strict_element_ids;
231
+      }
232
+      // Ce else palie au bug du au cas ou $strict_element_ids est egal a array();
233
+      else
234
+      {
235
+        $where_tag_strict = ($is_where) ? ' AND' : ' WHERE';
236
+        $where_tag_strict .= ' 1 = 2';
237
+      }
229 238
     }
230 239
     
231 240
     // Requête qui selectionnera les ids en fonction des critéres

+ 4 - 2
src/Muzich/CoreBundle/Tests/Searcher/ElementSearcherTest.php View File

@@ -18,7 +18,8 @@ class ElementSearcherTest extends UnitTest
18 18
         'group_id'  => null, 
19 19
         'favorite'  => false,
20 20
         'ids'       => null,
21
-        'ids_display' => null
21
+        'ids_display' => null,
22
+        'tag_strict' => false
22 23
     ));
23 24
 
24 25
     $this->assertEquals($ia, $es->getParams());
@@ -43,7 +44,8 @@ class ElementSearcherTest extends UnitTest
43 44
         'group_id'  => null, 
44 45
         'favorite'  => false,
45 46
         'ids'       => null,
46
-        'ids_display' => null
47
+        'ids_display' => null,
48
+        'tag_strict' => false
47 49
     ));
48 50
 
49 51
     $this->assertEquals($ua, $es->getParams());