From a64db2880f462c24d4292e2f40f1555275e661a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Gro=C3=9Fberndt?= <stephan@grossberndt.de> Date: Tue, 12 Dec 2017 15:05:56 +0100 Subject: [PATCH] [BUGFIX] Don't list records from tables without searchFields on search 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/55048 Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de> Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Hannes Lau <office@hanneslau.de> Reviewed-by: Markus Klein <markus.klein@typo3.org> Tested-by: Markus Klein <markus.klein@typo3.org> --- typo3/sysext/backend/Classes/View/PageLayoutView.php | 9 +++------ .../Classes/RecordList/AbstractDatabaseRecordList.php | 9 +++------ .../recordlist/Classes/RecordList/DatabaseRecordList.php | 9 +++------ 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/typo3/sysext/backend/Classes/View/PageLayoutView.php b/typo3/sysext/backend/Classes/View/PageLayoutView.php index a0999d551d50..a09d1084c8e0 100644 --- a/typo3/sysext/backend/Classes/View/PageLayoutView.php +++ b/typo3/sysext/backend/Classes/View/PageLayoutView.php @@ -3472,15 +3472,12 @@ class PageLayoutView implements LoggerAwareInterface $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) { @@ -3510,7 +3507,7 @@ class PageLayoutView implements LoggerAwareInterface ); } } - } else { + } elseif (!empty($searchableFields)) { $like = $queryBuilder->quote('%' . $queryBuilder->escapeLikeWildcards($this->searchString) . '%'); foreach ($searchableFields as $fieldName) { if (!isset($GLOBALS['TCA'][$table]['columns'][$fieldName])) { @@ -3551,7 +3548,7 @@ class PageLayoutView implements LoggerAwareInterface } } } - // 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'; } diff --git a/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php index ba24e0143262..08980b88bdf4 100644 --- a/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php +++ b/typo3/sysext/recordlist/Classes/RecordList/AbstractDatabaseRecordList.php @@ -904,15 +904,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) { @@ -942,7 +939,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])) { @@ -983,7 +980,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'; } diff --git a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php index a714577e090b..34ce004fc927 100644 --- a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php +++ b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php @@ -3353,15 +3353,12 @@ class DatabaseRecordList $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) { @@ -3391,7 +3388,7 @@ class DatabaseRecordList ); } } - } else { + } elseif (!empty($searchableFields)) { $like = $queryBuilder->quote('%' . $queryBuilder->escapeLikeWildcards($this->searchString) . '%'); foreach ($searchableFields as $fieldName) { if (!isset($GLOBALS['TCA'][$table]['columns'][$fieldName])) { @@ -3432,7 +3429,7 @@ class DatabaseRecordList } } } - // 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'; } -- GitLab