[BUGFIX] RecordList: Use case insensitive search without explicit TCA config 93/48993/2
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Sat, 16 Jul 2016 01:26:30 +0000 (18:26 -0700)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 16 Jul 2016 13:37:46 +0000 (15:37 +0200)
Default to a case insensitive like based search constraint when the column
has no explicit 'search' configuration in the TCA.

Resolves: #77120
Related: #76259
Releases: master

Change-Id: I1bace422cb589284680e346b4d6e47d10b684f46
Reviewed-on: https://review.typo3.org/48993
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php

index 81063d4..0d70427 100755 (executable)
@@ -937,19 +937,18 @@ class AbstractDatabaseRecordList extends AbstractRecordList
                 $fieldConfig = $GLOBALS['TCA'][$table]['columns'][$fieldName]['config'];
                 $fieldType = $fieldConfig['type'];
                 $evalRules = $fieldConfig['eval'] ?: '';
-                $searchConstraint = $expressionBuilder->andX();
+                $searchConstraint = $expressionBuilder->andX(
+                    $expressionBuilder->comparison(
+                        'LOWER(' . $queryBuilder->quoteIdentifier($fieldName) . ')',
+                        'LIKE',
+                        'LOWER(' . $like . ')'
+                    )
+                );
                 if (is_array($fieldConfig['search'])) {
                     $searchConfig = $fieldConfig['search'];
                     if (in_array('case', $searchConfig)) {
-                        $searchConstraint->add($expressionBuilder->like($fieldName, $like));
-                    } else {
-                        $searchConstraint->add(
-                            $expressionBuilder->comparison(
-                                'LOWER(' . $queryBuilder->quoteIdentifier($fieldName) . ')',
-                                'LIKE',
-                                'LOWER(' . $like . ')'
-                            )
-                        );
+                        // Replace case insensitive default constraint
+                        $searchConstraint = $expressionBuilder->andX($expressionBuilder->like($fieldName, $like));
                     }
                     if (in_array('pidonly', $searchConfig) && $currentPid > 0) {
                         $searchConstraint->add($expressionBuilder->eq($tablePidField, (int)$currentPid));