CRM-16581 fix - API and checking if a custom field is empty is ignored
authormonishdeb <monish.deb@webaccessglobal.com>
Fri, 19 Jun 2015 11:00:29 +0000 (16:30 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Fri, 19 Jun 2015 22:14:09 +0000 (03:44 +0530)
https://issues.civicrm.org/jira/browse/CRM-16581

CRM/Core/BAO/CustomQuery.php

index 60613023ae224c9cdeac64f1bb8cdfd7d5fc310d..990e277086e9275987b4e32efda68cddd92aeae3 100644 (file)
@@ -404,6 +404,15 @@ SELECT label, value
               if (!is_array($value)) {
                 $value = CRM_Utils_Type::escape($strtolower($value), 'String');
               }
+              // in api sometimes params is in array('sqlOp' => (mixed)'values') format
+              elseif (!empty($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
+                $op = key($value);
+                $value = CRM_Utils_Type::escape($strtolower($value[$op]), 'String');
+              }
+
+              if (strstr($op, 'NULL') || strstr($op, 'EMPTY')) {
+                $value = NULL;
+              }
               elseif ($isSerialized && strstr($op, 'IN')) {
                 $value = implode(',', $value);
               }