[BUGFIX] Fix misleading SQL error message in TCEforms
authorAndreas Wolf <andreas.wolf@ikt-werk.de>
Tue, 18 Oct 2011 14:45:30 +0000 (16:45 +0200)
committerXavier Perseguers <xavier@typo3.org>
Mon, 24 Oct 2011 18:44:30 +0000 (20:44 +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: I31bea64cf656c951bc63a89eff47fbeb893ae73f
Resolves: #16306
Releases: 4.6, 4.5
Reviewed-on: http://review.typo3.org/4764
Reviewed-by: Steffen Gebert
Tested-by: Steffen Gebert
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
t3lib/class.t3lib_tceforms.php
typo3/sysext/lang/locallang_core.xlf

index 456a342..abc5564 100644 (file)
@@ -4749,12 +4749,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 5e73286..810f8ad 100644 (file)
@@ -923,6 +923,12 @@ Check also the following points:\n
                        <trans-unit id="csh_tooltip_loading" xml:space="preserve">
                                <source>Loading help...</source>
                        </trans-unit>
+                       <trans-unit id="error.database_schema_mismatch" xml:space="preserve">
+                               <source>A SQL error occurred. This may indicate a schema mismatch between TCA and the database. Try running database compare in the Install Tool.</source>
+                       </trans-unit>
+                       <trans-unit id="error.database_schema_mismatch_title" xml:space="preserve">
+                               <source>Database Error</source>
+                       </trans-unit>
                </body>
        </file>
 </xliff>