[BUGFIX] Changing TCA via Tools->Configuration breaks TCA
authorMarkus Klein <klein.t3@mfc-linz.at>
Fri, 4 Mar 2011 12:22:50 +0000 (13:22 +0100)
committerSteffen Gebert <steffen.gebert@typo3.org>
Thu, 10 Mar 2011 22:05:42 +0000 (23:05 +0100)
Changing the TCA (especially the columns-part of a table) via
Tools->Configuration breaks eg. the list module.
Tools->Configuration writes strings like
$GLOBALS['TCA']['tt_news']['columns']['image']['config']['allowed'] = 'jpg';
to typo3conf/extTables.php.

However, a call to loadTCA($table) call is not added before, so
the TCA array is incomplete. Furthermore if you set the columns part
in extTables.php any proceeding call to loadTCA will not work, since
'columns' is already defined.

Change-Id: I98cf3b2a570a06fe13ca69e99d8f18e0c35a30d3
Resolves: #M17754
Reviewed-on: http://review.typo3.org/1128
Reviewed-by: Steffen Gebert <steffen.gebert@typo3.org>
Tested-by: Steffen Gebert <steffen.gebert@typo3.org>
Reviewed-by: Markus Klein <klein.t3@mfc-linz.at>
Tested-by: Markus Klein <klein.t3@mfc-linz.at>
typo3/sysext/lowlevel/config/index.php

index bdccb13..c7383b8 100755 (executable)
@@ -269,8 +269,22 @@ class SC_mod_tools_config_index {
                                $length = strpos($line, '[');
                                $var = substr($line, 0, $length);
                                $changedLine = '$GLOBALS[\'' . substr($line, 1, $length - 1) . '\']' . substr($line, $length);
-                                       // insert line  in extTables.php
+                                       // load current extTables.php
                                $extTables = t3lib_div::getURL(PATH_typo3conf . TYPO3_extTableDef_script);
+                               if ($var === '$TCA') {
+                                               // check if we are editing the TCA
+                                       preg_match_all('/\[\'([^\']+)\'\]/', $line, $parts);
+                                       if ($parts[1][1] !== 'ctrl') {
+                                                       // anything else than ctrl section requires to load TCA
+                                               $loadTCA = 't3lib_div::loadTCA(\'' . $parts[1][0] . '\');';
+                                               if (strpos($extTables, $loadTCA) === FALSE) {
+                                                               // check if the loadTCA statement is not already present in the file
+                                                       $changedLine = $loadTCA . LF . $changedLine;
+                                               }
+                                       }
+                               }
+
+                                       // insert line in extTables.php
                                $extTables = '<?php' . preg_replace('/<\?php|\?>/is', '', $extTables) . $changedLine . LF . '?>';
                                $success = t3lib_div::writeFile(PATH_typo3conf . TYPO3_extTableDef_script, $extTables);
                                if ($success) {
@@ -278,7 +292,7 @@ class SC_mod_tools_config_index {
                                        $flashMessage = t3lib_div::makeInstance(
                                                't3lib_FlashMessage',
                                                '',
-                                               sprintf($GLOBALS['LANG']->getLL('writeMessage', TRUE), TYPO3_extTableDef_script,  '<br />', '<strong>' . $changedLine . '</strong>'),
+                                               sprintf($GLOBALS['LANG']->getLL('writeMessage', TRUE), TYPO3_extTableDef_script,  '<br />', '<strong>' . nl2br($changedLine) . '</strong>'),
                                                t3lib_FlashMessage::OK
                                        );
                                } else {