[BUGFIX] Improve database scheme updater 45/28945/3
authorNicole Cordes <typo3@cordes.co>
Fri, 28 Mar 2014 19:34:29 +0000 (20:34 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 12 Apr 2014 15:57:19 +0000 (17:57 +0200)
This patch improves the update process as it removes the hard stop after
an SQL error occurred. All queries should get executed and errors should
be reported at the end. Sometimes it gets necessary that the updater is
called more that once - a notice to the user is added.

Besides the index length is reduced by 1 to ensure the index is set
with limitation in the database and all fields can be updated in the
second step.

Resolves: #57421
Releases: 6.2
Change-Id: I2f830a8a62b8dff3fbe949d40de8ddc30f3dfb9a
Reviewed-on: https://review.typo3.org/28945
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
Reviewed-by: Dmitry Dulepov
Tested-by: Dmitry Dulepov
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/ext_tables.sql
typo3/sysext/install/Classes/Updates/FinalDatabaseSchemaUpdate.php

index 810ef7c..071705e 100644 (file)
@@ -380,7 +380,7 @@ CREATE TABLE sys_file_processedfile (
 
        PRIMARY KEY (uid),
        KEY combined_1 (original,task_type,configurationsha1),
-       KEY identifier (storage,identifier(200))
+       KEY identifier (storage,identifier(199))
 );
 
 #
index 6aa9228..13becfe 100644 (file)
@@ -135,15 +135,20 @@ class FinalDatabaseSchemaUpdate extends AbstractDatabaseSchemaUpdate {
                $databaseDifferences = $this->getDatabaseDifferences();
                $updateStatements = $this->schemaMigrationService->getUpdateSuggestions($databaseDifferences);
 
+               $customMessagesArray = array();
                foreach ((array)$updateStatements['change'] as $query) {
                        $GLOBALS['TYPO3_DB']->admin_query($query);
                        $dbQueries[] = $query;
                        if ($GLOBALS['TYPO3_DB']->sql_error()) {
-                               $customMessages = 'SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error());
-                               return FALSE;
+                               $customMessagesArray[] = 'SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error());
                        }
                }
 
-               return TRUE;
+               if (!empty($customMessagesArray)) {
+                       $customMessages = 'Update process not fully processed. This can happen because of dependencies of table fields and ' .
+                               'indexes. Please repeat this step! Following errors occurred:' . LF . LF . implode(LF, $customMessagesArray);
+               }
+
+               return count($customMessagesArray) === 0;
        }
 }