Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Config / Entity / Query / Condition.php
index 6764d01ea6eab259f60fadd0bbaf3d8c97a4e891..3410a6ef53ce157f53b458caab4acdb84619b5d8 100644 (file)
@@ -2,7 +2,6 @@
 
 namespace Drupal\Core\Config\Entity\Query;
 
-use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Entity\Query\ConditionBase;
 use Drupal\Core\Entity\Query\ConditionInterface;
 use Drupal\Core\Entity\Query\QueryException;
@@ -32,10 +31,10 @@ class Condition extends ConditionBase {
 
         // Lowercase condition value(s) for case-insensitive matches.
         if (is_array($condition['value'])) {
-          $condition['value'] = array_map('Drupal\Component\Utility\Unicode::strtolower', $condition['value']);
+          $condition['value'] = array_map('mb_strtolower', $condition['value']);
         }
         elseif (!is_bool($condition['value'])) {
-          $condition['value'] = Unicode::strtolower($condition['value']);
+          $condition['value'] = mb_strtolower($condition['value']);
         }
 
         $single_conditions[] = $condition;
@@ -50,7 +49,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,10 +153,17 @@ 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)) {
-        $value = Unicode::strtolower($value);
+        $value = mb_strtolower($value);
       }
 
       switch ($condition['operator']) {
@@ -183,15 +189,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;
   }
 
 }