diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Query.php b/core/lib/Drupal/Core/Config/Entity/Query/Query.php index 033f774..27d2a42 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/Query.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/Query.php @@ -111,7 +111,7 @@ protected function loadRecords() { // Search the conditions for restrictions on entity IDs. $ids = array(); - $id_condition = NULL; + $id_conditions = []; if ($this->condition->getConjunction() == 'AND') { foreach ($this->condition->conditions() as $condition) { if (is_string($condition['field']) && $condition['field'] == $this->entityType->getKey('id')) { @@ -123,7 +123,7 @@ protected function loadRecords() { $ids = $condition['value']; } else { - $id_condition = $condition; + $id_conditions[] = $condition; } // We stop at the first restricting condition on ID. In the (weird) // case where there are additional restricting conditions, results @@ -142,43 +142,43 @@ protected function loadRecords() { return $prefix . $id; }, $ids); } - // If no restrictions on IDs were found, we need to parse all records. + // If no restrictions on IDs were found, we need to list all records. else { $names = $this->configFactory->listAll($prefix); - // In case we have an ID condition, try to narrow down the list of config - // objects to load. - if ($id_condition) { - $value = $id_condition['value']; - $filter = NULL; - switch ($id_condition['operator']) { - case '<>': - $filter = function ($name) use ($value, $prefix_length) { - $id = substr($name, $prefix_length); - return $id !== $value; - }; - break; - case 'STARTS_WITH': - $filter = function ($name) use ($value, $prefix_length) { - $id = substr($name, $prefix_length); - return strpos($id, $value) === 0; - }; - break; - case 'CONTAINS': - $filter = function ($name) use ($value, $prefix_length) { - $id = substr($name, $prefix_length); - return strpos($id, $value) !== FALSE; - }; - break; - case 'ENDS_WITH': - $filter = function ($name) use ($value, $prefix_length) { - $id = substr($name, $prefix_length); - return strrpos($id, $value) === strlen($id) - strlen($value); - }; - break; - } - if ($filter) { - $names = array_filter($names, $filter); - } + } + // In case we have any ID conditions, try to narrow down the list of config + // objects to load. + foreach ($id_conditions as $id_condition) { + $value = $id_condition['value']; + $filter = NULL; + switch ($id_condition['operator']) { + case '<>': + $filter = function ($name) use ($value, $prefix_length) { + $id = substr($name, $prefix_length); + return $id !== $value; + }; + break; + case 'STARTS_WITH': + $filter = function ($name) use ($value, $prefix_length) { + $id = substr($name, $prefix_length); + return strpos($id, $value) === 0; + }; + break; + case 'CONTAINS': + $filter = function ($name) use ($value, $prefix_length) { + $id = substr($name, $prefix_length); + return strpos($id, $value) !== FALSE; + }; + break; + case 'ENDS_WITH': + $filter = function ($name) use ($value, $prefix_length) { + $id = substr($name, $prefix_length); + return strrpos($id, $value) === strlen($id) - strlen($value); + }; + break; + } + if ($filter) { + $names = array_filter($names, $filter); } }