From 919b61fd95d7f62b33c5a27bd94a206546c52c23 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Fri, 19 Jun 2015 16:30:29 +0530 Subject: [PATCH] CRM-16581 fix - API and checking if a custom field is empty is ignored https://issues.civicrm.org/jira/browse/CRM-16581 --- CRM/Core/BAO/CustomQuery.php | 9 +++++++++ 1 file changed, 9 insertions(+) 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); } -- 2.25.1