Merge pull request #22664 from braders/membershipview-default-values
[civicrm-core.git] / Civi / Api4 / Generic / AbstractSaveAction.php
index 50aa311c4657f3a109b0f6ffec8081cbeb5b3e95..94b932efd3915280f56c1c9f936b3b6525db32e4 100644 (file)
@@ -142,7 +142,13 @@ abstract class AbstractSaveAction extends AbstractAction {
       $where = [];
       foreach ($record as $key => $val) {
         if (isset($val) && in_array($key, $this->match, TRUE)) {
-          $where[] = [$key, '=', $val];
+          if ($val === '' || is_null($val)) {
+            // If we want to match empty string we have to match on NULL/''
+            $where[] = [$key, 'IS EMPTY'];
+          }
+          else {
+            $where[] = [$key, '=', $val];
+          }
         }
       }
       if (count($where) === count($this->match)) {