[BUGFIX] PHP warnings may show up in the List module
authorDmitry Dulepov <dmitry@typo3.org>
Thu, 24 Nov 2011 15:19:02 +0000 (17:19 +0200)
committerSteffen Ritter <info@rs-websystems.de>
Wed, 7 Mar 2012 07:41:31 +0000 (08:41 +0100)
If the table is defined in $TCA but it misses "columns" array,
there will be a warning in the List module when searching for
any phrase. Implement a check that "columns" entry exists and
write a log message if it does not.

Change-Id: I8b4663ba81f039d4ea416100dc8f2b8e4658cf35
Resolves: #22152
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/6893
Reviewed-by: Philipp Gampe
Reviewed-by: Sebastian Fischer
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/class.db_list.inc

index 047e352..f022c72 100644 (file)
@@ -833,47 +833,55 @@ class recordList extends t3lib_recordList {
                ) {
                        t3lib_div::loadTCA($table);
 
-                               // 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'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $fN))
-                                       && $fieldValue['config']['type']!='passthrough')) {
-                                       $fieldListArr[]=$fN;
+                       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'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $fN))
+                                                                       && $fieldValue['config']['type']!='passthrough')) {
+                                               $fieldListArr[]=$fN;
+                                       }
                                }
-                       }
 
                                // Add special fields:
-                       if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin()) {
-                               $fieldListArr[]='uid';
-                               $fieldListArr[]='pid';
-                       }
+                               if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin()) {
+                                       $fieldListArr[]='uid';
+                                       $fieldListArr[]='pid';
+                               }
 
                                // Add date fields
-                       if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin() || $addDateFields) {
-                               if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) {
-                                       $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['tstamp'];
-                               }
-                               if ($GLOBALS['TCA'][$table]['ctrl']['crdate']) {
-                                       $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['crdate'];
+                               if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin() || $addDateFields) {
+                                       if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) {
+                                               $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['tstamp'];
+                                       }
+                                       if ($GLOBALS['TCA'][$table]['ctrl']['crdate']) {
+                                               $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['crdate'];
+                                       }
                                }
-                       }
 
                                // Add more special fields:
-                       if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin()) {
-                               if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id']) {
-                                       $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['cruser_id'];
-                               }
-                               if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
-                                       $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['sortby'];
-                               }
-                               if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
-                                       $fieldListArr[]='t3ver_id';
-                                       $fieldListArr[]='t3ver_state';
-                                       $fieldListArr[]='t3ver_wsid';
-                                       if ($table==='pages')   {
-                                               $fieldListArr[]='t3ver_swapmode';
+                               if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin()) {
+                                       if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id']) {
+                                               $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['cruser_id'];
+                                       }
+                                       if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
+                                               $fieldListArr[]=$GLOBALS['TCA'][$table]['ctrl']['sortby'];
+                                       }
+                                       if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
+                                               $fieldListArr[]='t3ver_id';
+                                               $fieldListArr[]='t3ver_state';
+                                               $fieldListArr[]='t3ver_wsid';
+                                               if ($table==='pages')   {
+                                                       $fieldListArr[]='t3ver_swapmode';
+                                               }
                                        }
                                }
+                       } else {
+                               t3lib_div::sysLog(
+                                       sprintf('$TCA is broken for the table "%s": no required "columns" entry in $TCA.', $table),
+                                       'core',
+                                       t3lib_div::SYSLOG_SEVERITY_ERROR
+                               );
                        }
                }
                return $fieldListArr;