[BUGFIX] Do not fetch type=none fields from db in list module 33/58133/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 3 Sep 2018 00:48:04 +0000 (02:48 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 3 Sep 2018 09:15:46 +0000 (11:15 +0200)
A type=none TCA field is the only field type that is entirely ignored
by DataHandler. An incoming value for such a field is discarded in
checkValue_SW() method and not persisted to db.
The list and query modules should not try to fetch this field type
from database, and a type=none field should not be selectable in
list module single table view.
If a field exists in db and should just be formatted and displayed
readOnly, type=input with readOnly=true is a better option.

Resolves: #86092
Releases: master
Change-Id: Ie3b8e966de66bfd7820b6a17853d4ad591480502
Reviewed-on: https://review.typo3.org/58133
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Database/QueryGenerator.php
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php

index 64e991c..9dedcf5 100644 (file)
@@ -293,7 +293,11 @@ class QueryGenerator
                 $fC = $GLOBALS['TCA'][$this->table]['columns'][$fieldName];
                 $this->fields[$fieldName] = $fC['config'];
                 $this->fields[$fieldName]['exclude'] = $fC['exclude'];
-                if ($this->fields[$fieldName]['type'] === 'user' && !isset($this->fields[$fieldName]['type']['userFunc'])) {
+                if ($this->fields[$fieldName]['type'] === 'user' && !isset($this->fields[$fieldName]['type']['userFunc'])
+                    || $this->fields[$fieldName]['type'] === 'none'
+                ) {
+                    // Do not list type=none "virtual" fields or query them from db,
+                    // and if type is user without defined userFunc
                     unset($this->fields[$fieldName]);
                     continue;
                 }
index 3619dfb..0683afc 100644 (file)
@@ -3811,10 +3811,13 @@ class DatabaseRecordList
             if (isset($GLOBALS['TCA'][$table]['columns']) && is_array($GLOBALS['TCA'][$table]['columns'])) {
                 // Traverse configured columns and add them to field array, if available for user.
                 foreach ($GLOBALS['TCA'][$table]['columns'] as $fN => $fieldValue) {
-                    if ($dontCheckUser || (!$fieldValue['exclude'] || $backendUser->check(
-                                'non_exclude_fields',
-                                $table . ':' . $fN
-                            )) && $fieldValue['config']['type'] !== 'passthrough') {
+                    if ($fieldValue['config']['type'] === 'none') {
+                        // Never render or fetch type=none fields from db
+                        continue;
+                    }
+                    if ($dontCheckUser
+                        || (!$fieldValue['exclude'] || $backendUser->check('non_exclude_fields', $table . ':' . $fN)) && $fieldValue['config']['type'] !== 'passthrough'
+                    ) {
                         $fieldListArr[] = $fN;
                     }
                 }