Commit a64db288 authored by Stephan Großberndt's avatar Stephan Großberndt Committed by Markus Klein
Browse files

[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: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarHannes Lau <office@hanneslau.de>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
parent 54d0332b
......@@ -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';
}
......
......@@ -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';
}
......
......@@ -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';
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment