[BUGFIX] Don't list records from tables without searchFields on search 59/55059/2
authorStephan Großberndt <stephan@grossberndt.de>
Tue, 12 Dec 2017 14:05:56 +0000 (15:05 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Tue, 12 Dec 2017 23:57:31 +0000 (00:57 +0100)
When searching for a string in the database list do not show any records
from tables without a searchField definition, if the searchString is not
an integer which might be a uid.

Releases: master, 8.7
Resolves: #83301
Change-Id: I259a4d9b2f89c55f9a0ac307b812e950ab549b20
Reviewed-on: https://review.typo3.org/55059
Reviewed-by: Stephan Großberndt <stephan@grossberndt.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php

index b118d9b..1ad748b 100644 (file)
@@ -912,15 +912,12 @@ class AbstractDatabaseRecordList extends AbstractRecordList
         $constraints = [];
         $currentPid = (int)$currentPid;
         $tablePidField = $table === 'pages' ? 'uid' : 'pid';
-        // Make query, only if table is valid and a search string is actually defined:
+        // Make query only if table is valid and a search string is actually defined
         if (empty($this->searchString)) {
             return '';
         }
 
         $searchableFields = $this->getSearchFields($table);
-        if (empty($searchableFields)) {
-            return '';
-        }
         if (MathUtility::canBeInterpretedAsInteger($this->searchString)) {
             $constraints[] = $expressionBuilder->eq('uid', (int)$this->searchString);
             foreach ($searchableFields as $fieldName) {
@@ -950,7 +947,7 @@ class AbstractDatabaseRecordList extends AbstractRecordList
                     );
                 }
             }
-        } else {
+        } elseif (!empty($searchableFields)) {
             $like = $queryBuilder->quote('%' . $queryBuilder->escapeLikeWildcards($this->searchString) . '%');
             foreach ($searchableFields as $fieldName) {
                 if (!isset($GLOBALS['TCA'][$table]['columns'][$fieldName])) {
@@ -991,7 +988,7 @@ class AbstractDatabaseRecordList extends AbstractRecordList
                 }
             }
         }
-        // If no search field conditions have been build ensure no results are returned
+        // If no search field conditions have been built ensure no results are returned
         if (empty($constraints)) {
             return '0=1';
         }