From bf05e1733d18e7f6d72145f23d3cd26ad062d688 Mon Sep 17 00:00:00 2001
From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com>
Date: Wed, 8 Jan 2025 12:38:51 +1300
Subject: [PATCH] ENH Align ArrayList case sensitivity with other lists
 (#11529)

---
 src/Model/List/ArrayList.php           | 20 --------------
 tests/php/Model/List/ArrayListTest.php | 38 +++++++++++++-------------
 2 files changed, 19 insertions(+), 39 deletions(-)

diff --git a/src/Model/List/ArrayList.php b/src/Model/List/ArrayList.php
index de7b8bac822..3ffb0b03dd9 100644
--- a/src/Model/List/ArrayList.php
+++ b/src/Model/List/ArrayList.php
@@ -5,7 +5,6 @@
 use InvalidArgumentException;
 use LogicException;
 use SilverStripe\Dev\Debug;
-use SilverStripe\Dev\Deprecation;
 use SilverStripe\ORM\Filters\ExactMatchFilter;
 use SilverStripe\ORM\Filters\SearchFilterable;
 use SilverStripe\Model\ArrayData;
@@ -33,14 +32,6 @@ class ArrayList extends ModelData implements SS_List
 {
     use SearchFilterable;
 
-    /**
-     * Whether filter and exclude calls should be case sensitive by default or not.
-     * This configuration property is here for backwards compatability.
-     *
-     * @deprecated 5.1.0 use SearchFilter.default_case_sensitive instead
-     */
-    private static bool $default_case_sensitive = true;
-
     /**
      * Holds the items in the list
      *
@@ -690,17 +681,6 @@ protected function filterOrExclude(array $filters, bool $inclusive = true, bool
                 $hasNullFilter = true;
             }
             $searchFilter = $this->createSearchFilter($filterKey, $filterValue);
-
-            // Apply default case sensitivity for backwards compatability
-            if (!str_contains($filterKey, ':case') && !str_contains($filterKey, ':nocase')) {
-                $caseSensitive = Deprecation::withSuppressedNotice(fn() => static::config()->get('default_case_sensitive'));
-                if ($caseSensitive && in_array('case', $searchFilter->getSupportedModifiers())) {
-                    $searchFilter->setModifiers($searchFilter->getModifiers() + ['case']);
-                } elseif (!$caseSensitive && in_array('nocase', $searchFilter->getSupportedModifiers())) {
-                    $searchFilter->setModifiers($searchFilter->getModifiers() + ['nocase']);
-                }
-            }
-
             $searchFilters[$filterKey] = $searchFilter;
         }
 
diff --git a/tests/php/Model/List/ArrayListTest.php b/tests/php/Model/List/ArrayListTest.php
index c5ec7ee0886..69d265b1358 100644
--- a/tests/php/Model/List/ArrayListTest.php
+++ b/tests/php/Model/List/ArrayListTest.php
@@ -349,20 +349,20 @@ public static function provideFindWithSearchfilters()
         return [
             // test a couple of search filters
             // don't need to be as explicit as the filter tests, just check the syntax works
-            'exact match not case sensitive' => [
-                'args' => ['NoCase:nocase', 'case sensitive'],
+            'exact match case insensitive' => [
+                'args' => ['NoCase', 'case sensitive'],
                 'objects' => $objects,
                 'expected' => $objects[0],
             ],
             'startswith match' => [
                 'args' => ['StartsWithTest:StartsWith', 'test'],
                 'objects' => $objects,
-                'expected' => $objects[3],
+                'expected' => $objects[0],
             ],
-            'startswith match no case' => [
-                'args' => ['StartsWithTest:StartsWith:nocase', 'test'],
+            'startswith match case' => [
+                'args' => ['StartsWithTest:StartsWith:case', 'test'],
                 'objects' => $objects,
-                'expected' => $objects[0],
+                'expected' => $objects[3],
             ],
             'startswith match negated' => [
                 'args' => ['StartsWithTest:StartsWith:not', 'Test'],
@@ -1187,20 +1187,20 @@ public static function provideFilterWithSearchfilters()
                 'expected' => [$objects[3], $objects[4]],
             ],
             // case sensitivity checks
-            'exact match case sensitive' => [
+            'exact match case insensitive' => [
                 'args' => [['NoCase' => 'case sensitive']],
                 'objects' => $objects,
-                'expected' => [$objects[1]],
+                'expected' => [$objects[0], $objects[1]],
             ],
-            'exact match case insensitive' => [
-                'args' => ['NoCase:nocase', 'case sensitive'],
+            'exact match case sensitive' => [
+                'args' => ['NoCase:case', 'case sensitive'],
                 'objects' => $objects,
-                'expected' => [$objects[0], $objects[1]],
+                'expected' => [$objects[1]],
             ],
             'exact match mixed case filters' => [
                 'args' => [[
                     'NoCase:nocase' => 'case sensitive',
-                    'CaseSensitive' => 'case sensitive',
+                    'CaseSensitive:case' => 'case sensitive',
                 ]],
                 'objects' => $objects,
                 'expected' => [$objects[1]],
@@ -1218,14 +1218,14 @@ public static function provideFilterWithSearchfilters()
             ],
             // partialmatch filter
             'partial match' => [
-                'args' => ['StartsWithTest:PartialMatch', 'start'],
+                'args' => [['StartsWithTest:PartialMatch' => 'start']],
                 'objects' => $objects,
-                'expected' => [$objects[2]],
+                'expected' => [$objects[1], $objects[2]],
             ],
             'partial match with modifier' => [
-                'args' => [['StartsWithTest:PartialMatch:nocase' => 'start']],
+                'args' => ['StartsWithTest:PartialMatch:case', 'start'],
                 'objects' => $objects,
-                'expected' => [$objects[1], $objects[2]],
+                'expected' => [$objects[2]],
             ],
             // greaterthan filter
             'greaterthan match' => [
@@ -1324,12 +1324,12 @@ public static function provideFilterAnyWithSearchfilters()
             'partial match' => [
                 'args' => ['StartsWithTest:PartialMatch', 'start'],
                 'objects' => $objects,
-                'expected' => [$objects[2]],
+                'expected' => [$objects[1], $objects[2]],
             ],
             'partial match with modifier' => [
-                'args' => ['StartsWithTest:PartialMatch:nocase', 'start'],
+                'args' => ['StartsWithTest:PartialMatch:case', 'start'],
                 'objects' => $objects,
-                'expected' => [$objects[1], $objects[2]],
+                'expected' => [$objects[2]],
             ],
             'greaterthan match' => [
                 'args' => ['GreaterThan100:GreaterThan', 100],