APIv4 - Fix potential PHP undefined index warning
authorColeman Watts <coleman@civicrm.org>
Wed, 5 Aug 2020 01:22:43 +0000 (21:22 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 5 Aug 2020 01:22:43 +0000 (21:22 -0400)
Ensures the array key '0' exists in the where clause before accessing it.

Civi/Api4/Generic/Traits/ArrayQueryActionTrait.php

index 7f16a88e69d3ced37aa4a87ec68dc3bff9a158eb..4ae6096c503965784deff942f29420d785cf50a0 100644 (file)
@@ -60,7 +60,7 @@ trait ArrayQueryActionTrait {
    * @return bool
    */
   private function evaluateFilters($row) {
-    $where = $this->getWhere();
+    $where = array_values($this->getWhere());
     $allConditions = in_array($where[0], ['AND', 'OR', 'NOT']) ? $where : ['AND', $where];
     return $this->walkFilters($row, $allConditions);
   }