32 if (isset($this->postValues[
'set'][
'changeEncryptionKey'])) {
33 $this->setNewEncryptionKeyAndLogOut();
36 $actionMessages = array();
37 if (isset($this->postValues[
'set'][
'changeInstallToolPassword'])) {
38 $actionMessages[] = $this->changeInstallToolPassword();
40 if (isset($this->postValues[
'set'][
'changeSiteName'])) {
41 $actionMessages[] = $this->changeSiteName();
43 if (isset($this->postValues[
'set'][
'createAdministrator'])) {
44 $actionMessages[] = $this->createAdministrator();
46 if (isset($this->postValues[
'set'][
'clearAllCache'])) {
47 $actionMessages[] = $this->clearAllCache();
49 if (isset($this->postValues[
'set'][
'clearOpcodeCache'])) {
50 $actionMessages[] = $this->clearOpcodeCache();
54 if (isset($this->postValues[
'set'][
'databaseAnalyzerExecute'])
55 || isset($this->postValues[
'set'][
'databaseAnalyzerAnalyze'])
59 if (isset($this->postValues[
'set'][
'databaseAnalyzerExecute'])) {
60 $actionMessages = array_merge($actionMessages, $this->databaseAnalyzerExecute());
62 if (isset($this->postValues[
'set'][
'databaseAnalyzerAnalyze'])) {
63 $actionMessages[] = $this->databaseAnalyzerAnalyze();
66 $this->view->assign(
'actionMessages', $actionMessages);
68 $operatingSystem = TYPO3_OS ===
'WIN' ?
'Windows' :
'Unix';
71 $coreUpdateService = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Service\\CoreUpdateService');
73 ->assign(
'enableCoreUpdate', $coreUpdateService->isCoreUpdateEnabled())
74 ->assign(
'operatingSystem', $operatingSystem)
76 ->assign(
'databaseName',
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'database'])
77 ->assign(
'databaseUsername',
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'username'])
78 ->assign(
'databaseHost',
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'host'])
79 ->assign(
'databasePort',
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'port'])
80 ->assign(
'databaseSocket',
$GLOBALS[
'TYPO3_CONF_VARS'][
'DB'][
'socket'])
81 ->assign(
'databaseNumberOfTables', count($this->getDatabaseConnection()->admin_get_tables()))
82 ->assign(
'extensionCompatibilityTesterProtocolFile',
GeneralUtility::getIndpEnv(
'TYPO3_SITE_URL') .
'typo3temp/ExtensionCompatibilityTester.txt')
83 ->assign(
'extensionCompatibilityTesterErrorProtocolFile',
GeneralUtility::getIndpEnv(
'TYPO3_SITE_URL') .
'typo3temp/ExtensionCompatibilityTesterErrors.json')
86 return $this->view->render();
94 protected function changeInstallToolPassword() {
95 $values = $this->postValues[
'values'];
96 if ($values[
'newInstallToolPassword'] !== $values[
'newInstallToolPasswordCheck']) {
98 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
99 $message->setTitle(
'Install tool password not changed');
100 $message->setMessage(
'Given passwords do not match.');
101 } elseif (strlen($values[
'newInstallToolPassword']) < 8) {
103 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
104 $message->setTitle(
'Install tool password not changed');
105 $message->setMessage(
'Given password must be at least eight characters long.');
108 $configurationManager = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
109 $configurationManager->setLocalConfigurationValueByPath(
110 'BE/installToolPassword',
114 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
115 $message->setTitle(
'Install tool password changed');
125 protected function changeSiteName() {
126 $values = $this->postValues[
'values'];
127 if (isset($values[
'newSiteName']) && strlen($values[
'newSiteName']) > 0) {
129 $configurationManager = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
130 $configurationManager->setLocalConfigurationValueByPath(
'SYS/sitename', $values[
'newSiteName']);
132 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
133 $message->setTitle(
'Site name changed');
134 $this->view->assign(
'siteName', $values[
'newSiteName']);
137 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
138 $message->setTitle(
'Site name not changed');
139 $message->setMessage(
'Site name must be at least one character long.');
149 protected function clearAllCache() {
151 $clearCacheService = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Service\\ClearCacheService');
152 $clearCacheService->clearAll();
153 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
154 $message->setTitle(
'Successfully cleared all caches');
163 protected function clearOpcodeCache() {
166 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
167 $message->setTitle(
'Successfully cleared all available opcode caches');
176 protected function setNewEncryptionKeyAndLogOut() {
179 $configurationManager = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
180 $configurationManager->setLocalConfigurationValueByPath(
'SYS/encryptionKey', $newKey);
183 'TYPO3\\CMS\\Core\\FormProtection\\InstallToolFormProtection' 185 $formProtection->clean();
187 $session = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Service\\SessionService');
188 $session->destroySession();
197 protected function createAdministrator() {
198 $values = $this->postValues[
'values'];
199 $username = preg_replace(
'/\\s/i',
'', $values[
'newUserUsername']);
200 $password = $values[
'newUserPassword'];
201 $passwordCheck = $values[
'newUserPasswordCheck'];
203 if (strlen($username) < 1) {
205 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
206 $message->setTitle(
'Administrator user not created');
207 $message->setMessage(
'No valid username given.');
208 } elseif ($password !== $passwordCheck) {
210 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
211 $message->setTitle(
'Administrator user not created');
212 $message->setMessage(
'Passwords do not match.');
213 } elseif (strlen($password) < 8) {
215 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
216 $message->setTitle(
'Administrator user not created');
217 $message->setMessage(
'Password must be at least eight characters long.');
219 $database = $this->getDatabaseConnection();
220 $userExists =
$database->exec_SELECTcountRows(
223 'username=' .
$database->fullQuoteStr($username,
'be_users')
227 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
228 $message->setTitle(
'Administrator user not created');
229 $message->setMessage(
'A user with username "' . $username .
'" exists already.');
232 $adminUserFields = array(
233 'username' => $username,
234 'password' => $hashedPassword,
239 $database->exec_INSERTquery(
'be_users', $adminUserFields);
241 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
242 $message->setTitle(
'Administrator with username "' . $username .
'".');
254 protected function databaseAnalyzerExecute() {
258 if (empty($this->postValues[
'values'])) {
260 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\WarningStatus');
261 $message->setTitle(
'No database changes selected');
267 $schemaMigrationService = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService');
269 $expectedSchemaService = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService');
270 $expectedSchema = $expectedSchemaService->getExpectedDatabaseSchema();
271 $currentSchema = $schemaMigrationService->getFieldDefinitions_database();
273 $statementHashesToPerform = $this->postValues[
'values'];
278 $addCreateChange = $schemaMigrationService->getDatabaseExtra($expectedSchema, $currentSchema);
279 $addCreateChange = $schemaMigrationService->getUpdateSuggestions($addCreateChange);
280 $results[] = $schemaMigrationService->performUpdateQueries($addCreateChange[
'add'], $statementHashesToPerform);
281 $results[] = $schemaMigrationService->performUpdateQueries($addCreateChange[
'change'], $statementHashesToPerform);
282 $results[] = $schemaMigrationService->performUpdateQueries($addCreateChange[
'create_table'], $statementHashesToPerform);
285 $dropRename = $schemaMigrationService->getDatabaseExtra($currentSchema, $expectedSchema);
286 $dropRename = $schemaMigrationService->getUpdateSuggestions($dropRename,
'remove');
287 $results[] = $schemaMigrationService->performUpdateQueries($dropRename[
'change'], $statementHashesToPerform);
288 $results[] = $schemaMigrationService->performUpdateQueries($dropRename[
'drop'], $statementHashesToPerform);
289 $results[] = $schemaMigrationService->performUpdateQueries($dropRename[
'change_table'], $statementHashesToPerform);
290 $results[] = $schemaMigrationService->performUpdateQueries($dropRename[
'drop_table'], $statementHashesToPerform);
293 foreach ($results as $resultSet) {
294 if (is_array($resultSet)) {
295 foreach ($resultSet as $errorMessage) {
297 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
298 $message->setTitle(
'Database update failed');
299 $message->setMessage(
'Error: ' . $errorMessage);
306 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
307 $message->setTitle(
'Executed database updates');
320 protected function databaseAnalyzerAnalyze() {
322 $schemaMigrationService = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService');
324 $expectedSchemaService = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService');
325 $expectedSchema = $expectedSchemaService->getExpectedDatabaseSchema();
327 $currentSchema = $schemaMigrationService->getFieldDefinitions_database();
329 $databaseAnalyzerSuggestion = array();
332 $addCreateChange = $schemaMigrationService->getDatabaseExtra($expectedSchema, $currentSchema);
333 $addCreateChange = $schemaMigrationService->getUpdateSuggestions($addCreateChange);
334 if (isset($addCreateChange[
'create_table'])) {
335 $databaseAnalyzerSuggestion[
'addTable'] = array();
336 foreach ($addCreateChange[
'create_table'] as $hash => $statement) {
337 $databaseAnalyzerSuggestion[
'addTable'][$hash] = array(
339 'statement' => $statement,
343 if (isset($addCreateChange[
'add'])) {
344 $databaseAnalyzerSuggestion[
'addField'] = array();
345 foreach ($addCreateChange[
'add'] as $hash => $statement) {
346 $databaseAnalyzerSuggestion[
'addField'][$hash] = array(
348 'statement' => $statement,
352 if (isset($addCreateChange[
'change'])) {
353 $databaseAnalyzerSuggestion[
'change'] = array();
354 foreach ($addCreateChange[
'change'] as $hash => $statement) {
355 $databaseAnalyzerSuggestion[
'change'][$hash] = array(
357 'statement' => $statement,
359 if (isset($addCreateChange[
'change_currentValue'][$hash])) {
360 $databaseAnalyzerSuggestion[
'change'][$hash][
'current'] = $addCreateChange[
'change_currentValue'][$hash];
366 $dropRename = $schemaMigrationService->getDatabaseExtra($currentSchema, $expectedSchema);
367 $dropRename = $schemaMigrationService->getUpdateSuggestions($dropRename,
'remove');
368 if (isset($dropRename[
'change_table'])) {
369 $databaseAnalyzerSuggestion[
'renameTableToUnused'] = array();
370 foreach ($dropRename[
'change_table'] as $hash => $statement) {
371 $databaseAnalyzerSuggestion[
'renameTableToUnused'][$hash] = array(
373 'statement' => $statement,
375 if (!empty($dropRename[
'tables_count'][$hash])) {
376 $databaseAnalyzerSuggestion[
'renameTableToUnused'][$hash][
'count'] = $dropRename[
'tables_count'][$hash];
380 if (isset($dropRename[
'change'])) {
381 $databaseAnalyzerSuggestion[
'renameTableFieldToUnused'] = array();
382 foreach ($dropRename[
'change'] as $hash => $statement) {
383 $databaseAnalyzerSuggestion[
'renameTableFieldToUnused'][$hash] = array(
385 'statement' => $statement,
389 if (isset($dropRename[
'drop'])) {
390 $databaseAnalyzerSuggestion[
'deleteField'] = array();
391 foreach ($dropRename[
'drop'] as $hash => $statement) {
392 $databaseAnalyzerSuggestion[
'deleteField'][$hash] = array(
394 'statement' => $statement,
398 if (isset($dropRename[
'drop_table'])) {
399 $databaseAnalyzerSuggestion[
'deleteTable'] = array();
400 foreach ($dropRename[
'drop_table'] as $hash => $statement) {
401 $databaseAnalyzerSuggestion[
'deleteTable'][$hash] = array(
403 'statement' => $statement,
405 if (!empty($dropRename[
'tables_count'][$hash])) {
406 $databaseAnalyzerSuggestion[
'deleteTable'][$hash][
'count'] = $dropRename[
'tables_count'][$hash];
411 $this->view->assign(
'databaseAnalyzerSuggestion', $databaseAnalyzerSuggestion);
414 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
415 $message->setTitle(
'Analyzed current database');
static isRunningOnCgiServerApi()
static getRandomHexString($count)
loadExtLocalconfDatabaseAndExtTables()
static getIndpEnv($getEnvName)
getHashedPassword($password)
static clearAllActive($fileAbsPath=NULL)
static redirect($url, $httpStatus=self::HTTP_STATUS_303)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]