[FEATURE] Add error message for missing TCA
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Mon, 19 Dec 2011 23:09:25 +0000 (00:09 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Mon, 13 Feb 2012 08:18:42 +0000 (09:18 +0100)
Adds an error message in case the TCA of a table is missing
column definitions. The error message adds a hint that helps
the developer to find the affected table.
In addition it changes the table header to show the table name
as it is in the database if there is no title defined in TCA.

Change-Id: I568c63d40de11385da0bf848904b860c4269fac4
Resolves: #17961
Releases: 4.7
Reviewed-on: http://review.typo3.org/6883
Reviewed-by: Stefan Neufeind
Reviewed-by: Oliver Klee
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
typo3/class.db_list.inc
typo3/class.db_list_extra.inc
typo3/sysext/lang/locallang_mod_web_list.xlf

index 2fb0ca6..047e352 100644 (file)
@@ -827,7 +827,10 @@ class recordList extends t3lib_recordList {
                $fieldListArr = array();
 
                        // Check table:
-               if (is_array($GLOBALS['TCA'][$table])) {
+               if (is_array($GLOBALS['TCA'][$table])
+                       && isset($GLOBALS['TCA'][$table]['columns'])
+                       && is_array($GLOBALS['TCA'][$table]['columns'])
+               ) {
                        t3lib_div::loadTCA($table);
 
                                // Traverse configured columns and add them to field array, if available for user.
index 15f4361..9fe34c1 100644 (file)
@@ -94,6 +94,8 @@ class localRecordList extends recordList {
        var $translations;                                              // Translations of the current record
        var $selFieldList;                                              // select fields for the query which fetches the translations of the current record
 
+       public $disableSingleTableView = FALSE;
+
        public function __construct() {
                parent::__construct();
        }
@@ -346,8 +348,28 @@ class localRecordList extends recordList {
                        );
                }
                $selectFields = array_unique($selectFields);            // Unique list!
-               $selectFields = array_intersect($selectFields,$this->makeFieldList($table,1));          // Making sure that the fields in the field-list ARE in the field-list from TCA!
-               $selFieldList = implode(',',$selectFields);             // implode it into a list of fields for the SQL-statement.
+               $fieldListFields = $this->makeFieldList($table, 1);
+               if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
+
+                       $message = sprintf(
+                               $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.php:missingTcaColumnsMessage', TRUE),
+                               $table,
+                               $table
+                       );
+                       $messageTitle = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.php:missingTcaColumnsMessageTitle', TRUE);
+
+                       $flashMessage = t3lib_div::makeInstance(
+                               't3lib_FlashMessage',
+                               $message,
+                               $messageTitle,
+                               t3lib_FlashMessage::WARNING,
+                               TRUE
+                       );
+                       /** @var t3lib_FlashMessage $flashMessage */
+                       t3lib_FlashMessageQueue::addMessage($flashMessage);
+               }
+               $selectFields = array_intersect($selectFields, $fieldListFields);       // Making sure that the fields in the field-list ARE in the field-list from TCA!
+               $selFieldList = implode(',', $selectFields);            // implode it into a list of fields for the SQL-statement.
                $this->selFieldList = $selFieldList;
 
                /**
@@ -420,12 +442,18 @@ class localRecordList extends recordList {
                                $out.=$this->addelement(0,'',$theData,'class="c-table-row-spacer"',$this->leftMargin);
                        }
 
+                       $tableTitle = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE);
+                       if ($tableTitle === '') {
+                               $tableTitle = $table;
+                       }
                                // Header line is drawn
-                       $theData = Array();
+                       $theData = array();
                        if ($this->disableSingleTableView)      {
-                               $theData[$titleCol] = '<span class="c-table">' . t3lib_BEfunc::wrapInHelp($table, '', $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE)) . '</span> ('.$this->totalItems.')';
+                               $theData[$titleCol] = '<span class="c-table">' .
+                                               t3lib_BEfunc::wrapInHelp($table, '', $tableTitle) .
+                                               '</span> (' . $this->totalItems . ')';
                        } else {
-                               $theData[$titleCol] = $this->linkWrapTable($table, '<span class="c-table">' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE) . '</span> (' . $this->totalItems . ') ' .
+                               $theData[$titleCol] = $this->linkWrapTable($table, '<span class="c-table">' . $tableTitle . '</span> (' . $this->totalItems . ') ' .
                                                ($this->table ? t3lib_iconWorks::getSpriteIcon('actions-view-table-collapse', array('title' => $GLOBALS['LANG']->getLL('contractView', TRUE))) : t3lib_iconWorks::getSpriteIcon('actions-view-table-expand', array('title' => $GLOBALS['LANG']->getLL('expandView', TRUE))))
                                        );
                        }
index e129c34..2eda536 100644 (file)
                        <trans-unit id="rangeIndicator" xml:space="preserve">
                                <source>Records %1$d - %2$d</source>
                        </trans-unit>
+                       <trans-unit id="missingTcaColumnsMessageTitle" xml:space="preserve">
+                               <source>Missing TCA definition</source>
+                       </trans-unit>
+                       <trans-unit id="missingTcaColumnsMessage" xml:space="preserve">
+                               <source>Warning: No fields for table "%s" have been found. $TCA['%s']['columns'] does not contain the neccessary definitions.</source>
+                       </trans-unit>
                </body>
        </file>
 </xliff>