2 namespace TYPO3\CMS\Install\Controller\Action\Tool;
18 use TYPO3\CMS\Install\Controller\Action;
45 $initialUpdateDatabaseSchemaUpdateObject = $this->
getUpdateObjectInstance(\TYPO3\CMS\Install\Updates\InitialDatabaseSchemaUpdate::class,
'initialUpdateDatabaseSchema');
46 if ($initialUpdateDatabaseSchemaUpdateObject->shouldRenderWizard()) {
47 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/install'][
'update'] = array_merge(
48 array(
'initialUpdateDatabaseSchema' => \TYPO3\CMS\Install\Updates\InitialDatabaseSchemaUpdate::class),
49 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/install'][
'update']
51 $this->needsInitialUpdateDatabaseSchema =
true;
55 $finalUpdateDatabaseSchemaUpdateObject = $this->
getUpdateObjectInstance(\TYPO3\CMS\Install\Updates\FinalDatabaseSchemaUpdate::class,
'finalUpdateDatabaseSchema');
56 if ($finalUpdateDatabaseSchemaUpdateObject->shouldRenderWizard()) {
57 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/install'][
'update'][
'finalUpdateDatabaseSchema'] = \TYPO3\CMS\Install\Updates\FinalDatabaseSchemaUpdate::class;
61 $this->silentCacheFrameworkTableSchemaMigration();
63 $actionMessages = array();
65 if (isset($this->postValues[
'set'][
'getUserInput'])) {
66 $actionMessages[] = $this->getUserInputForUpdate();
67 $this->view->assign(
'updateAction',
'getUserInput');
68 }
elseif (isset($this->postValues[
'set'][
'performUpdate'])) {
69 $actionMessages[] = $this->performUpdate();
70 $this->view->assign(
'updateAction',
'performUpdate');
72 $actionMessages[] = $this->listUpdates();
73 $this->view->assign(
'updateAction',
'listUpdates');
76 $this->view->assign(
'actionMessages', $actionMessages);
78 return $this->view->render();
86 protected function listUpdates()
88 if (empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/install'][
'update'])) {
90 $message = $this->objectManager->get(\TYPO3\CMS\Install\Status\WarningStatus::class);
91 $message->setTitle(
'No update wizards registered');
95 $availableUpdates = array();
96 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/install'][
'update'] as $identifier => $className) {
98 if ($updateObject->shouldRenderWizard()) {
101 $updateObject->checkForUpdate($explanation);
102 $availableUpdates[$identifier] = array(
103 'identifier' => $identifier,
104 'title' => $updateObject->getTitle(),
105 'explanation' => $explanation,
106 'renderNext' =>
false,
108 if ($identifier ===
'initialUpdateDatabaseSchema') {
114 }
elseif ($identifier ===
'finalUpdateDatabaseSchema') {
116 $availableUpdates[
'finalUpdateDatabaseSchema'][
'renderNext'] = count($availableUpdates) === 1;
117 }
elseif (!$this->needsInitialUpdateDatabaseSchema && $updateObject->shouldRenderNextButton()) {
119 $availableUpdates[$identifier][
'renderNext'] =
true;
124 $this->view->assign(
'availableUpdates', $availableUpdates);
127 $message = $this->objectManager->get(\TYPO3\CMS\Install\Status\OkStatus::class);
128 $message->setTitle(
'Show available update wizards');
137 protected function getUserInputForUpdate()
139 $wizardIdentifier = $this->postValues[
'values'][
'identifier'];
141 $className =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/install'][
'update'][$wizardIdentifier];
144 if (method_exists($updateObject,
'getUserInput')) {
145 $wizardHtml = $updateObject->getUserInput(
'install[values][' . $wizardIdentifier .
']');
149 'identifier' => $wizardIdentifier,
150 'title' => $updateObject->getTitle(),
151 'wizardHtml' => $wizardHtml,
154 $this->view->assign(
'updateData', $updateData);
157 $message = $this->objectManager->get(\TYPO3\CMS\Install\Status\OkStatus::class);
158 $message->setTitle(
'Show wizard options');
168 protected function performUpdate()
172 $wizardIdentifier = $this->postValues[
'values'][
'identifier'];
173 $className =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/install'][
'update'][$wizardIdentifier];
177 'identifier' => $wizardIdentifier,
178 'title' => $updateObject->getTitle(),
182 $wizardInputErrorMessage =
'';
183 if (method_exists($updateObject,
'checkUserInput') && !$updateObject->checkUserInput($wizardInputErrorMessage)) {
185 $message = $this->objectManager->get(\TYPO3\CMS\Install\Status\ErrorStatus::class);
186 $message->setTitle(
'Input parameter broken');
187 $message->setMessage($wizardInputErrorMessage ?:
'Something went wrong!');
188 $wizardData[
'wizardInputBroken'] =
true;
190 if (!method_exists($updateObject,
'performUpdate')) {
191 throw new \TYPO3\CMS\Install\Exception(
192 'No performUpdate method in update wizard with identifier ' . $wizardIdentifier,
199 $databaseQueries = array();
200 $performResult = $updateObject->performUpdate($databaseQueries, $customOutput);
202 if ($performResult) {
204 $message = $this->objectManager->get(\TYPO3\CMS\Install\Status\OkStatus::class);
205 $message->setTitle(
'Update successful');
208 $message = $this->objectManager->get(\TYPO3\CMS\Install\Status\ErrorStatus::class);
209 $message->setTitle(
'Update failed!');
211 $message->setMessage($customOutput);
215 if ($this->postValues[
'values'][
'showDatabaseQueries'] == 1) {
216 $wizardData[
'queries'] = $databaseQueries;
220 $this->view->assign(
'wizardData', $wizardData);
226 $nextUpdateIdentifier =
'';
228 $nextUpdateIdentifier = $nextUpdate->getIdentifier();
230 $this->view->assign(
'nextUpdateIdentifier', $nextUpdateIdentifier);
244 $userInput = $this->postValues[
'values'][$identifier];
258 $isPreviousRecord =
true;
259 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'ext/install'][
'update'] as $identifier => $className) {
262 $isPreviousRecord =
false;
264 if ($identifier !==
'initialUpdateDatabaseSchema' && $identifier !==
'finalUpdateDatabaseSchema') {
268 if (!$isPreviousRecord) {
270 if ($nextUpdate->shouldRenderWizard()) {
284 protected function silentCacheFrameworkTableSchemaMigration()
287 $sqlHandler = $this->objectManager->get(\TYPO3\CMS\Install\Service\SqlSchemaMigrationService::class);
290 $cachingFrameworkDatabaseSchemaService = $this->objectManager->get(\TYPO3\CMS\Core\Cache\DatabaseSchemaService::class);
291 $expectedSchemaString = $cachingFrameworkDatabaseSchemaService->getCachingFrameworkRequiredDatabaseSchema();
292 $cleanedExpectedSchemaString = implode(LF, $sqlHandler->getStatementArray($expectedSchemaString,
true,
'^CREATE TABLE '));
293 $neededTableDefinition = $sqlHandler->getFieldDefinitions_fileContent($cleanedExpectedSchemaString);
294 $currentTableDefinition = $sqlHandler->getFieldDefinitions_database();
295 $updateTableDefinition = $sqlHandler->getDatabaseExtra($neededTableDefinition, $currentTableDefinition);
296 $updateStatements = $sqlHandler->getUpdateSuggestions($updateTableDefinition);
297 if (isset($updateStatements[
'create_table']) && !empty($updateStatements[
'create_table'])) {
298 $sqlHandler->performUpdateQueries($updateStatements[
'create_table'], $updateStatements[
'create_table']);
300 if (isset($updateStatements[
'add']) && !empty($updateStatements[
'add'])) {
301 $sqlHandler->performUpdateQueries($updateStatements[
'add'], $updateStatements[
'add']);
303 if (isset($updateStatements[
'change']) && !empty($updateStatements[
'change'])) {
304 $sqlHandler->performUpdateQueries($updateStatements[
'change'], $updateStatements[
'change']);