Merge pull request #12114 from jitendrapurohit/membership-2
[civicrm-core.git] / api / api.php
index 1675d9d1aa0066a326d147a91802699df2d909ba..04b0421bcbb213757ab02e81d11882094e97e891 100644 (file)
@@ -129,6 +129,10 @@ function _civicrm_api_get_camel_name($entity) {
  */
 function _civicrm_api_replace_variables(&$params, &$parentResult, $separator = '.') {
   foreach ($params as $field => &$value) {
+    if (substr($field, 0, 4) == 'api.') {
+      // CRM-21246 - Leave nested calls alone.
+      continue;
+    }
     if (is_string($value) && substr($value, 0, 6) == '$value') {
       $value = _civicrm_api_replace_variable($value, $parentResult, $separator);
     }
@@ -136,6 +140,10 @@ function _civicrm_api_replace_variables(&$params, &$parentResult, $separator = '
     elseif (is_array($value) && is_string(reset($value)) && substr(reset($value), 0, 6) == '$value') {
       $key = key($value);
       $value[$key] = _civicrm_api_replace_variable($value[$key], $parentResult, $separator);
+      // A null value with an operator will cause an error, so remove it.
+      if ($value[$key] === NULL) {
+        $value = '';
+      }
     }
   }
 }