From: monishdeb Date: Fri, 19 Jun 2015 11:00:29 +0000 (+0530) Subject: CRM-16581 fix - API and checking if a custom field is empty is ignored X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=919b61fd95d7f62b33c5a27bd94a206546c52c23;p=civicrm-core.git CRM-16581 fix - API and checking if a custom field is empty is ignored https://issues.civicrm.org/jira/browse/CRM-16581 --- diff --git a/CRM/Core/BAO/CustomQuery.php b/CRM/Core/BAO/CustomQuery.php index 60613023ae..990e277086 100644 --- a/CRM/Core/BAO/CustomQuery.php +++ b/CRM/Core/BAO/CustomQuery.php @@ -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); }