CRM/Contact - Fix fatal error on tag search
authorPatrick Figel <pfigel@greenpeace.org>
Fri, 1 Mar 2019 18:28:27 +0000 (19:28 +0100)
committereileen <emcnaughton@wikimedia.org>
Sat, 2 Mar 2019 06:30:43 +0000 (19:30 +1300)
This fixes a fatal error caused by the CommaSeparatedIntegers not
accepting empty strings. This can be triggered by performing a
search with "Tag(s) IS NULL" using the search builder.

CRM/Contact/BAO/Query.php

index 5b21ceb1c3ba3762a619a3de507653307c56c0df..d30c4bbaab1cf48e8d098b4e63bff5e208745b82 100644 (file)
@@ -3262,11 +3262,14 @@ WHERE  $smartGroupClause
       }
     }
 
-    // implode array, then remove all spaces and validate CommaSeparatedIntegers
-    $value = CRM_Utils_Type::validate(
-      str_replace(' ', '', implode(',', (array) $value)),
-      'CommaSeparatedIntegers'
-    );
+    // implode array, then remove all spaces
+    $value = str_replace(' ', '', implode(',', (array) $value));
+    if (!empty($value)) {
+      $value = CRM_Utils_Type::validate(
+        $value,
+        'CommaSeparatedIntegers'
+      );
+    }
 
     $useAllTagTypes = $this->getWhereValues('all_tag_types', $grouping);
     $tagTypesText = $this->getWhereValues('tag_types_text', $grouping);