[TASK] Use fully qualified name resolution in PHP 5.5
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Step / DatabaseConnect.php
index 43bcdef..9037eae 100644 (file)
@@ -1,30 +1,20 @@
 <?php
 namespace TYPO3\CMS\Install\Controller\Action\Step;
 
-/***************************************************************
- *  Copyright notice
- *
- *  (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
- *  All rights reserved
- *
- *  This script is part of the TYPO3 project. The TYPO3 project is
- *  free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
+/**
+ * This file is part of the TYPO3 CMS project.
  *
- *  The GNU General Public License can be found at
- *  http://www.gnu.org/copyleft/gpl.html.
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
  *
- *  This script is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
  *
- *  This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
+ * The TYPO3 project - inspiring people to share!
+ */
 
-use TYPO3\CMS\Install\Controller\Action;
+use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 
 /**
  * Database connect step:
@@ -33,7 +23,7 @@ use TYPO3\CMS\Install\Controller\Action;
  * - Sets database credentials in LocalConfiguration
  * - Loads / unloads ext:dbal and ext:adodb if requested
  */
-class DatabaseConnect extends Action\AbstractAction implements StepInterface {
+class DatabaseConnect extends AbstractStepAction {
 
        /**
         * Execute database step:
@@ -46,7 +36,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
                $result = array();
 
                /** @var $configurationManager \TYPO3\CMS\Core\Configuration\ConfigurationManager */
-               $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
+               $configurationManager = $this->objectManager->get(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
 
                $postValues = $this->postValues['values'];
                if (isset($postValues['loadDbal'])) {
@@ -101,7 +91,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
                                        $localConfigurationPathValuePairs['DB/username'] = $value;
                                } else {
                                        /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
-                                       $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
+                                       $errorStatus = $this->objectManager->get(\TYPO3\CMS\Install\Status\ErrorStatus::class);
                                        $errorStatus->setTitle('Database username not valid');
                                        $errorStatus->setMessage('Given username must be shorter than fifty characters.');
                                        $result[] = $errorStatus;
@@ -114,7 +104,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
                                        $localConfigurationPathValuePairs['DB/password'] = $value;
                                } else {
                                        /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
-                                       $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
+                                       $errorStatus = $this->objectManager->get(\TYPO3\CMS\Install\Status\ErrorStatus::class);
                                        $errorStatus->setTitle('Database password not valid');
                                        $errorStatus->setMessage('Given password must be shorter than fifty characters.');
                                        $result[] = $errorStatus;
@@ -127,7 +117,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
                                        $localConfigurationPathValuePairs['DB/host'] = $value;
                                } else {
                                        /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
-                                       $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
+                                       $errorStatus = $this->objectManager->get(\TYPO3\CMS\Install\Status\ErrorStatus::class);
                                        $errorStatus->setTitle('Database host not valid');
                                        $errorStatus->setMessage('Given host is not alphanumeric (a-z, A-Z, 0-9 or _-.:) or longer than fifty characters.');
                                        $result[] = $errorStatus;
@@ -140,7 +130,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
                                        $localConfigurationPathValuePairs['DB/port'] = (int)$value;
                                } else {
                                        /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
-                                       $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
+                                       $errorStatus = $this->objectManager->get(\TYPO3\CMS\Install\Status\ErrorStatus::class);
                                        $errorStatus->setTitle('Database port not valid');
                                        $errorStatus->setMessage('Given port is not numeric or within range 1 to 65535.');
                                        $result[] = $errorStatus;
@@ -152,7 +142,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
                                        $localConfigurationPathValuePairs['DB/socket'] = $postValues['socket'];
                                } else {
                                        /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
-                                       $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
+                                       $errorStatus = $this->objectManager->get(\TYPO3\CMS\Install\Status\ErrorStatus::class);
                                        $errorStatus->setTitle('Socket does not exist');
                                        $errorStatus->setMessage('Given socket location does not exist on server.');
                                        $result[] = $errorStatus;
@@ -165,7 +155,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
                                        $localConfigurationPathValuePairs['DB/database'] = $value;
                                } else {
                                        /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
-                                       $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
+                                       $errorStatus = $this->objectManager->get(\TYPO3\CMS\Install\Status\ErrorStatus::class);
                                        $errorStatus->setTitle('Database name not valid');
                                        $errorStatus->setMessage('Given database name must be shorter than fifty characters.');
                                        $result[] = $errorStatus;
@@ -177,19 +167,19 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
 
                                // After setting new credentials, test again and create an error message if connect is not successful
                                // @TODO: This could be simplified, if isConnectSuccessful could be released from TYPO3_CONF_VARS
-                               // and feeded with connect values directly in order to obsolete the bootstrap reload.
+                               // and fed with connect values directly in order to obsolete the bootstrap reload.
                                \TYPO3\CMS\Core\Core\Bootstrap::getInstance()
                                        ->populateLocalConfiguration()
-                                       ->setCoreCacheToNullBackend();
+                                       ->disableCoreAndClassesCache();
                                if ($this->isDbalEnabled()) {
-                                       require(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('dbal') . 'ext_localconf.php');
-                                       $GLOBALS['typo3CacheManager']->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
+                                       require(ExtensionManagementUtility::extPath('dbal') . 'ext_localconf.php');
+                                       \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
                                }
                                if (!$this->isConnectSuccessful()) {
                                        /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
-                                       $errorStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\ErrorStatus');
+                                       $errorStatus = $this->objectManager->get(\TYPO3\CMS\Install\Status\ErrorStatus::class);
                                        $errorStatus->setTitle('Database connect not successful');
-                                       $errorStatus->setMessage('Connecting the database with given settings failed. Please check.');
+                                       $errorStatus->setMessage('Connecting to the database with given settings failed. Please check.');
                                        $result[] = $errorStatus;
                                }
                        }
@@ -202,7 +192,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
         * Step needs to be executed if database connection is not successful.
         *
         * @throws \TYPO3\CMS\Install\Controller\Exception\RedirectException
-        * @return boolean
+        * @return bool
         */
        public function needsExecution() {
                if ($this->isConnectSuccessful() && $this->isConfigurationComplete()) {
@@ -219,13 +209,11 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
        }
 
        /**
-        * Render this step
+        * Executes the step
         *
-        * @return string
+        * @return string Rendered content
         */
-       public function handle() {
-               $this->initializeHandle();
-
+       protected function executeAction() {
                $isDbalEnabled = $this->isDbalEnabled();
                $this->view
                        ->assign('isDbalEnabled', $isDbalEnabled)
@@ -248,6 +236,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
                                ->assign('renderConnectDetailsPort', TRUE)
                                ->assign('renderConnectDetailsSocket', TRUE);
                }
+               $this->assignSteps();
 
                return $this->view->render();
        }
@@ -255,7 +244,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
        /**
         * Render connect port and label
         *
-        * @return integer Configured or default port
+        * @return int Configured or default port
         */
        protected function getConfiguredOrDefaultPort() {
                $configuredPort = (int)$this->getConfiguredPort();
@@ -288,11 +277,12 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
        /**
         * Test connection with given credentials
         *
-        * @return boolean TRUE if connect was successful
+        * @return bool TRUE if connect was successful
         */
        protected function isConnectSuccessful() {
                /** @var $databaseConnection \TYPO3\CMS\Core\Database\DatabaseConnection */
-               $databaseConnection = $this->objectManager->get('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
+               $databaseConnection = $this->objectManager->get(\TYPO3\CMS\Core\Database\DatabaseConnection::class);
+               $databaseConnection->initialize();
 
                if ($this->isDbalEnabled()) {
                        // Set additional connect information based on dbal driver. postgres for example needs
@@ -320,7 +310,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
         * - 'host' is mandatory and must not be empty
         * - 'port' OR 'socket' is mandatory, but may be empty
         *
-        * @return boolean TRUE if host is set
+        * @return bool TRUE if host is set
         */
        protected function isHostConfigured() {
                $hostConfigured = TRUE;
@@ -342,7 +332,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
         * - 'port' OR 'socket' is mandatory, but may be empty
         * - 'username' and 'password' are mandatory, but may be empty
         *
-        * @return boolean TRUE if required settings are present
+        * @return bool TRUE if required settings are present
         */
        protected function isConfigurationComplete() {
                $configurationComplete = $this->isHostConfigured();
@@ -404,7 +394,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
                }
 
                /** @var \TYPO3\CMS\Core\Configuration\ConfigurationManager $configurationManager */
-               $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
+               $configurationManager = $this->objectManager->get(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
                $configurationManager->setLocalConfigurationValuesByPathValuePairs($localConfigurationPathValuePairs);
        }
 
@@ -412,7 +402,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
         * Test if a unix domain socket can be opened. This does not
         * authenticate but only tests if a connect is successful.
         *
-        * @return boolean TRUE on success
+        * @return bool TRUE on success
         */
        protected function isConnectionWithUnixDomainSocketPossible() {
                $result = FALSE;
@@ -564,14 +554,14 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
         * @return \TYPO3\CMS\Install\Status\StatusInterface
         */
        protected function executeLoadDbalExtension() {
-               if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('adodb')) {
-                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtension('adodb');
+               if (!ExtensionManagementUtility::isLoaded('adodb')) {
+                       ExtensionManagementUtility::loadExtension('adodb');
                }
-               if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('dbal')) {
-                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::loadExtension('dbal');
+               if (!ExtensionManagementUtility::isLoaded('dbal')) {
+                       ExtensionManagementUtility::loadExtension('dbal');
                }
                /** @var $errorStatus \TYPO3\CMS\Install\Status\WarningStatus */
-               $warningStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\WarningStatus');
+               $warningStatus = $this->objectManager->get(\TYPO3\CMS\Install\Status\WarningStatus::class);
                $warningStatus->setTitle('Loaded database abstraction layer');
                return $warningStatus;
        }
@@ -582,15 +572,15 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
         * @return \TYPO3\CMS\Install\Status\StatusInterface
         */
        protected function executeUnloadDbalExtension() {
-               if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('adodb')) {
-                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::unloadExtension('adodb');
+               if (ExtensionManagementUtility::isLoaded('adodb')) {
+                       ExtensionManagementUtility::unloadExtension('adodb');
                }
-               if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('dbal')) {
-                       \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::unloadExtension('dbal');
+               if (ExtensionManagementUtility::isLoaded('dbal')) {
+                       ExtensionManagementUtility::unloadExtension('dbal');
                }
                // @TODO: Remove configuration from TYPO3_CONF_VARS['EXTCONF']['dbal']
                /** @var $errorStatus \TYPO3\CMS\Install\Status\WarningStatus */
-               $warningStatus = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\WarningStatus');
+               $warningStatus = $this->objectManager->get(\TYPO3\CMS\Install\Status\WarningStatus::class);
                $warningStatus->setTitle('Removed database abstraction layer');
                return $warningStatus;
        }
@@ -632,7 +622,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
        /**
         * Returns configured port. Gets port from host value if port is not yet set.
         *
-        * @return integer
+        * @return int
         */
        protected function getConfiguredPort() {
                $host = isset($GLOBALS['TYPO3_CONF_VARS']['DB']['host']) ? $GLOBALS['TYPO3_CONF_VARS']['DB']['host'] : '';