[BUGFIX] Fix 'pidonly' check in backend search 84/61884/5
authorChristian Eßl <indy.essl@gmail.com>
Fri, 4 Oct 2019 13:31:40 +0000 (15:31 +0200)
committerDaniel Goerz <daniel.goerz@posteo.de>
Wed, 23 Oct 2019 09:58:25 +0000 (11:58 +0200)
The TCA setting 'pidonly', which is used to limit a field to be only
searched in the single page view in the list module, was broken and
didn't behave as described in the official TCA documentation.

First, the 'pidonly' setting is expected to be a boolean. However, the
'if' condition would fail for a boolean because the in_array() check in
the code was using strict type mode. Also, this check would never care
about the actual value of 'pidonly', only if it was set.

Second, you couldn't search for an integer value, while not using the
'pidonly' setting, at all.

This patch fixes this behaviour.

Resolves: #89002
Releases: master, 9.5
Change-Id: Iedac044c32b8dd500f4de175ae97ab17984725f8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61884
Reviewed-by: Julian Geils <j_geils@web.de>
Reviewed-by: Sascha Rademacher <sascha.rademacher+typo3@gmail.com>
Reviewed-by: Felix P. <f.pachowsky@neusta.de>
Reviewed-by: Henning Liebe <h.liebe@neusta.de>
Reviewed-by: Jörg Bösche <typo3@joergboesche.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Sascha Rademacher <sascha.rademacher+typo3@gmail.com>
Tested-by: Jörg Bösche <typo3@joergboesche.de>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php

index fbf4f9f..fd80e0d 100644 (file)
@@ -3436,9 +3436,8 @@ class PageLayoutView implements LoggerAwareInterface
                 $fieldType = $fieldConfig['type'];
                 $evalRules = $fieldConfig['eval'] ?: '';
                 if ($fieldType === 'input' && $evalRules && GeneralUtility::inList($evalRules, 'int')) {
-                    if (is_array($fieldConfig['search'])
-                        && in_array('pidonly', $fieldConfig['search'], true)
-                        && $currentPid > 0
+                    if (!isset($fieldConfig['search']['pidonly'])
+                        || ($fieldConfig['search']['pidonly'] && $currentPid > 0)
                     ) {
                         $constraints[] = $expressionBuilder->andX(
                             $expressionBuilder->eq($fieldName, (int)$this->searchString),
index ec2c24d..a5ec12b 100644 (file)
@@ -3277,9 +3277,8 @@ class DatabaseRecordList
                 $fieldType = $fieldConfig['type'];
                 $evalRules = $fieldConfig['eval'] ?: '';
                 if ($fieldType === 'input' && $evalRules && GeneralUtility::inList($evalRules, 'int')) {
-                    if (is_array($fieldConfig['search'])
-                        && in_array('pidonly', $fieldConfig['search'], true)
-                        && $currentPid > 0
+                    if (!isset($fieldConfig['search']['pidonly'])
+                        || ($fieldConfig['search']['pidonly'] && $currentPid > 0)
                     ) {
                         $constraints[] = $expressionBuilder->andX(
                             $expressionBuilder->eq($fieldName, (int)$this->searchString),