[BUGFIX] Install Tool fatal with Oracle database
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Step / EnvironmentAndFolders.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller\Action\Step;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 use TYPO3\CMS\Install\Controller\Action;
28
29 /**
30 * Very first install step:
31 * - Needs execution if typo3conf/LocalConfiguration.php does not exist
32 * - Renders system environment output
33 * - Creates folders like typo3temp, see FolderStructure/DefaultFactory for details
34 * - Creates typo3conf/LocalConfiguration.php from factory
35 */
36 class EnvironmentAndFolders extends Action\AbstractAction implements StepInterface {
37
38 /**
39 * Execute environment and folder step:
40 * - Create main folder structure
41 * - Create typo3conf/LocalConfiguration.php
42 *
43 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
44 */
45 public function execute() {
46 /** @var $folderStructureFactory \TYPO3\CMS\Install\FolderStructure\DefaultFactory */
47 $folderStructureFactory = $this->objectManager->get('TYPO3\\CMS\\Install\\FolderStructure\\DefaultFactory');
48 /** @var $structureFacade \TYPO3\CMS\Install\FolderStructure\StructureFacade */
49 $structureFacade = $folderStructureFactory->getStructure();
50 $structureFixMessages = $structureFacade->fix();
51 /** @var \TYPO3\CMS\Install\Status\StatusUtility $statusUtility */
52 $statusUtility = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\StatusUtility');
53 $errorsFromStructure = $statusUtility->filterBySeverity($structureFixMessages, 'error');
54
55 if (@is_dir(PATH_typo3conf)) {
56 /** @var \TYPO3\CMS\Core\Configuration\ConfigurationManager $configurationManager */
57 $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
58 $configurationManager->createLocalConfigurationFromFactoryConfiguration();
59
60 // Create a PackageStates.php with all packages activated marked as "part of factory default"
61 if (!file_exists(PATH_typo3conf . 'PackageStates.php')) {
62 /** @var \TYPO3\CMS\Core\Package\FailsafePackageManager $packageManager */
63 $packageManager = \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->getEarlyInstance('TYPO3\\Flow\\Package\\PackageManager');
64 $packages = $packageManager->getAvailablePackages();
65 foreach ($packages as $package) {
66 /** @var $package \TYPO3\CMS\Core\Package\PackageInterface */
67 if ($package instanceof \TYPO3\CMS\Core\Package\PackageInterface
68 && $package->isPartOfFactoryDefault()
69 ) {
70 $packageManager->activatePackage($package->getPackageKey());
71 }
72 }
73 $packageManager->forceSortAndSavePackageStates();
74 }
75
76 // Create enable install tool file after typo3conf & LocalConfiguration were created
77 $installToolService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\EnableFileService');
78 $installToolService->createInstallToolEnableFile();
79 }
80
81 return $errorsFromStructure;
82 }
83
84 /**
85 * Step needs to be executed if LocalConfiguration file does not exist.
86 *
87 * @return boolean
88 */
89 public function needsExecution() {
90 if (@is_file(PATH_typo3conf . 'LocalConfiguration.php')) {
91 return FALSE;
92 } else {
93 return TRUE;
94 }
95 }
96
97 /**
98 * Render this step
99 *
100 * @return string
101 */
102 public function handle() {
103 $this->initializeHandle();
104
105 /** @var \TYPO3\CMS\Install\SystemEnvironment\Check $statusCheck */
106 $statusCheck = $this->objectManager->get('TYPO3\\CMS\\Install\\SystemEnvironment\\Check');
107 $statusObjects = $statusCheck->getStatus();
108 /** @var \TYPO3\CMS\Install\Status\StatusUtility $statusUtility */
109 $statusUtility = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\StatusUtility');
110 $environmentStatus = $statusUtility->sortBySeverity($statusObjects);
111 $this->view->assign('environmentStatus', $environmentStatus);
112
113 /** @var $folderStructureFactory \TYPO3\CMS\Install\FolderStructure\DefaultFactory */
114 $folderStructureFactory = $this->objectManager->get('TYPO3\\CMS\\Install\\FolderStructure\\DefaultFactory');
115 /** @var $structureFacade \TYPO3\CMS\Install\FolderStructure\StructureFacade */
116 $structureFacade = $folderStructureFactory->getStructure();
117 $structureMessages = $structureFacade->getStatus();
118 /** @var $statusUtility \TYPO3\CMS\Install\Status\StatusUtility */
119 $structureErrors = $statusUtility->filterBySeverity($structureMessages, 'error');
120 $this->view->assign('structureErrors', $structureErrors);
121
122 if (count($environmentStatus['error']) > 0
123 || count($environmentStatus['warning']) > 0
124 || count($structureErrors) > 0
125 ) {
126 $this->view->assign('errorsOrWarningsFromStatus', TRUE);
127 }
128
129 return $this->view->render();
130 }
131 }