X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FConfig%2FEntity%2FQuery%2FCondition.php;h=bd2facd18fe8070c3b6c918ccd52d27a19ecb81f;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=6764d01ea6eab259f60fadd0bbaf3d8c97a4e891;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Config/Entity/Query/Condition.php b/web/core/lib/Drupal/Core/Config/Entity/Query/Condition.php index 6764d01ea..bd2facd18 100644 --- a/web/core/lib/Drupal/Core/Config/Entity/Query/Condition.php +++ b/web/core/lib/Drupal/Core/Config/Entity/Query/Condition.php @@ -50,7 +50,7 @@ class Condition extends ConditionBase { // matter and this config object does not match. // If OR and it is matching, then the rest of conditions do not // matter and this config object does match. - if ($and != $match ) { + if ($and != $match) { break; } } @@ -154,6 +154,13 @@ class Condition extends ConditionBase { * TRUE when matches else FALSE. */ protected function match(array $condition, $value) { + // "IS NULL" and "IS NOT NULL" conditions can also deal with array values, + // so we return early for them to avoid problems. + if (in_array($condition['operator'], ['IS NULL', 'IS NOT NULL'], TRUE)) { + $should_be_set = $condition['operator'] === 'IS NOT NULL'; + return $should_be_set === isset($value); + } + if (isset($value)) { // We always want a case-insensitive match. if (!is_bool($value)) { @@ -183,15 +190,11 @@ class Condition extends ConditionBase { return strpos($value, $condition['value']) !== FALSE; case 'ENDS_WITH': return substr($value, -strlen($condition['value'])) === (string) $condition['value']; - case 'IS NOT NULL': - return TRUE; - case 'IS NULL': - return FALSE; default: throw new QueryException('Invalid condition operator.'); } } - return $condition['operator'] === 'IS NULL'; + return FALSE; } }