2 namespace TYPO3\CMS\Install\Updates;
27 parent::__construct();
28 $this->title =
'Update database schema: Modify tables and fields';
39 $contextService = $this->objectManager->get(\TYPO3\CMS\Install\Service\ContextService::class);
40 $description =
'There are tables or fields in the database which need to be changed.<br /><br />' .
41 'This update wizard can be run only when there are no other update wizards left to make sure they have all needed fields unchanged.<br /><br />' .
42 'If you want to apply changes selectively, <a href="Install.php?install[action]=importantActions&install[context]=' . $contextService->getContextString() .
'&install[controller]=tool">go to Database Analyzer</a>.';
45 $updateSuggestions = $this->schemaMigrationService->getUpdateSuggestions($databaseDifferences);
47 return isset($updateSuggestions[
'change']);
61 $updateSuggestions = $this->schemaMigrationService->getUpdateSuggestions($databaseDifferences);
63 if (!isset($updateSuggestions[
'change'])) {
69 Change the following fields in tables:
72 <ol class="t3-install-form-label-after">%s</ol>
76 Change the following keys in tables:
79 <ol class="t3-install-form-label-after">%s</ol>
82 <li class="labelAfter">
83 <label><strong>%1$s</strong>: %2$s</label>
86 $fieldItems = array();
88 foreach ($databaseDifferences[
'diff'] as $tableName => $difference) {
89 if ($difference[
'fields']) {
90 $fieldNames = array();
91 foreach ($difference[
'fields'] as $fieldName => $sql) {
92 $fieldNames[] = $fieldName;
94 $fieldItems[] = sprintf($item, $tableName, implode(
', ', $fieldNames));
96 if ($difference[
'keys']) {
98 foreach ($difference[
'keys'] as $keyName => $sql) {
99 $keyNames[] = $keyName;
101 $keyItems[] = sprintf($item, $tableName, implode(
', ', $keyNames));
104 if (!empty($fieldItems)) {
105 $result .= sprintf($fieldsList, implode(
'', $fieldItems));
107 if (!empty($keyItems)) {
108 $result .= sprintf($keysList, implode(
'', $keyItems));
126 $updateStatements = $this->schemaMigrationService->getUpdateSuggestions($databaseDifferences);
129 $customMessagesArray = array();
130 foreach ((array)$updateStatements[
'change'] as $query) {
131 $db->admin_query($query);
132 $dbQueries[] = $query;
133 if ($db->sql_error()) {
134 $customMessagesArray[] =
'SQL-ERROR: ' . htmlspecialchars($db->sql_error());
138 if (!empty($customMessagesArray)) {
139 $customMessages =
'Update process not fully processed. This can happen because of dependencies of table fields and ' .
140 'indexes. Please repeat this step! Following errors occurred:' . LF . LF . implode(LF, $customMessagesArray);
143 return empty($customMessagesArray);