[BUGFIX] Fix misleading SQL error message in TCEforms
authorXavier Perseguers <xavier@typo3.org>
Mon, 24 Oct 2011 18:48:24 +0000 (20:48 +0200)
committerXavier Perseguers <xavier@typo3.org>
Mon, 24 Oct 2011 21:47:45 +0000 (23:47 +0200)
When an SQL error occurs, TCEforms shows the error message
"This may indicate a table defined in tables.php is not
existing in the database!"

The error can be caused by any schema mismatch, not only
missing table, so this is misleading.

The error message is now localizable and gives a hint to
run the database compare in the install tool.

Change-Id: I8083463f70dd27a83bb681577ba751b1b6044f2a
Resolves: #16306
Releases: 4.6, 4.5
Reviewed-on: http://review.typo3.org/6257
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
t3lib/class.t3lib_tceforms.php
typo3/sysext/lang/locallang_core.xml

index 69460c8..29e202b 100644 (file)
@@ -4863,12 +4863,25 @@ class t3lib_TCEforms {
                $f_table = $fieldValue['config'][$pF . 'foreign_table'];
                $uidPre = $pFFlag ? '-' : '';
 
-                       // Get query:
+                       // Exec query:
                $res = t3lib_BEfunc::exec_foreign_table_where_query($fieldValue, $field, $TSconfig, $pF);
 
-                       // Perform lookup
+                       // Perform error test
                if ($GLOBALS['TYPO3_DB']->sql_error()) {
-                       echo($GLOBALS['TYPO3_DB']->sql_error() . "\n\nThis may indicate a table defined in tables.php is not existing in the database!");
+                       $msg = htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error());
+                       $msg .= '<br />' . LF;
+                       $msg .= $this->sL('LLL:EXT:lang/locallang_core.php:error.database_schema_mismatch');
+                       $msgTitle = $this->sL('LLL:EXT:lang/locallang_core.php:error.database_schema_mismatch_title');
+                       /** @var $flashMessage t3lib_FlashMessage */
+                       $flashMessage = t3lib_div::makeInstance(
+                               't3lib_FlashMessage',
+                               $msg,
+                               $msgTitle,
+                               t3lib_FlashMessage::ERROR,
+                               TRUE
+                       );
+                       t3lib_FlashMessageQueue::addMessage($flashMessage);
+
                        return array();
                }
 
index c861279..78cabe7 100755 (executable)
@@ -317,6 +317,8 @@ Check also the following points:\n
                        <label index="link.to.filefile.correctly">Please, do not link to this page.</label>
                        <label index="loadingIndicator">Loading ...</label>
                        <label index="csh_tooltip_loading">Loading help...</label>
+                       <label index="error.database_schema_mismatch">A SQL error occurred. This may indicate a schema mismatch between TCA and the database. Try running database compare in the Install Tool.</label>
+                       <label index="error.database_schema_mismatch_title">Database Error</label>
                </languageKey>
        </data>
 </T3locallang>