[BUGFIX] Adapt to the new localconf handling
authorHelmut Hummel <helmut.hummel@typo3.org>
Tue, 24 Jul 2012 16:25:26 +0000 (18:25 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 24 Jul 2012 20:48:08 +0000 (22:48 +0200)
Adapt the auto activation feature of DBAL to the
new local configuration handling introduced in #38562

Resolves: #39224
Releases: 6.0

Change-Id: Iaa6ac10a32f9d2d4b59f3272351e626b0ac965df
Reviewed-on: http://review.typo3.org/13027
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/dbal/class.tx_dbal_autoloader.php
typo3/sysext/dbal/class.tx_dbal_installtool.php
typo3/sysext/dbal/res/Templates/install.html

index d780af0..3451920 100644 (file)
@@ -60,7 +60,7 @@ class tx_dbal_autoloader {
                                        }
                                        break;
                                case 3:
-                                       $driver = $instObj->INSTALL['localconf.php']['typo_db_driver'];
+                                       $driver = $instObj->INSTALL['Database']['typo_db_driver'];
                                        if ($driver === 'mysql') {
                                                $this->deactivateDbal();
                                        }
@@ -86,16 +86,12 @@ class tx_dbal_autoloader {
         * @return void
         */
        protected function activateDbal() {
-               $extList = t3lib_div::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList']);
-               if (!t3lib_div::inArray($extList, 'adodb')) {
-                       $extList[] = 'adodb';
+               if (!t3lib_extMgm::isLoaded('adodb')) {
+                       t3lib_extMgm::loadExtension('adodb');
                }
-               if (!t3lib_div::inArray($extList, 'dbal')) {
-                       $extList[] = 'dbal';
+               if (!t3lib_extMgm::isLoaded('dbal')) {
+                       t3lib_extMgm::loadExtension('dbal');
                }
-               $this->updateExtensionList(implode(',', $extList));
-               t3lib_extMgm::removeCacheFiles(t3lib_extMgm::getCacheFilePrefix());
-               $GLOBALS['typo3CacheManager']->getCache('cache_phpcode')->flushByTag('t3lib_autoloader');
        }
 
        /**
@@ -104,56 +100,13 @@ class tx_dbal_autoloader {
         * @return void
         */
        protected function deactivateDbal() {
-               $extList = t3lib_div::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList']);
-               $extList = array_flip($extList);
-
-               // Remove sysext dbal and adodb
-               if (isset($extList['dbal'])) {
-                       unset($extList['dbal']);
+               if (t3lib_extMgm::isLoaded('dbal')) {
+                       t3lib_extMgm::unloadExtension('dbal');
                }
-               if (isset($extList['adodb'])) {
-                       unset($extList['adodb']);
+               if (t3lib_extMgm::isLoaded('adodb')) {
+                       t3lib_extMgm::unloadExtension('adodb');
                }
-               $extList = array_flip($extList);
-
-               $this->updateExtensionList(implode(',', $extList));
        }
-
-       /**
-        * Updates the list of extensions.
-        *
-        * @param string $newExtList
-        * @return void
-        */
-       protected function updateExtensionList($newExtList) {
-               // Instance of install tool
-               $instObj = t3lib_div::makeInstance('t3lib_install');
-               $instObj->allowUpdateLocalConf = 1;
-               $instObj->updateIdentity = 'TYPO3 Core Update Manager';
-
-               try {
-                       // Get lines from localconf file
-                       $lines = $instObj->writeToLocalconf_control();
-                       $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXT\'][\'extList\']', $newExtList);
-                       $result = $instObj->writeToLocalconf_control($lines);
-                       if ($result === 'nochange') {
-                               $message = 'DBAL was not loaded.';
-                               if (!@is_writable(PATH_typo3conf)) {
-                                       $message .= ' ' . PATH_typo3conf . ' is not writable!';
-                               }
-                               throw new Exception($message);
-                       }
-
-                       $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'] = $newExtList;
-                       // Make sure to get cache file for backend, not frontend
-                       $cacheFilePrefix = $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'];
-                       $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'] = str_replace('temp_CACHED_FE', 'temp_CACHED', $cacheFilePrefix);
-                       t3lib_extMgm::removeCacheFiles();
-               } catch (Exception $e) {
-                       throw new RuntimeException($e->getMessage(), 1322415256);
-               }
-       }
-
 }
 
 // Make instance:
index 629615e..900202d 100644 (file)
@@ -113,7 +113,7 @@ class tx_dbal_installtool {
        /**
         * Hooks into Installer to modify lines to be written to localconf.php.
         *
-        * @param array $lines
+        * @param array $lines This parameter is obsolet as of TYPO3 6.0
         * @param integer $step
         * @param tx_install $instObj
         * @return void
@@ -122,7 +122,7 @@ class tx_dbal_installtool {
                switch ($step) {
                        case 3:
                        case 4:
-                               $driver = $instObj->INSTALL['localconf.php']['typo_db_driver'];
+                               $driver = $instObj->INSTALL['Database']['typo_db_driver'];
                                if (!$driver && $this->driver) {
                                        // Driver was already configured
                                        break;
@@ -130,28 +130,32 @@ class tx_dbal_installtool {
                                $driverConfig = '';
                                switch ($driver) {
                                        case 'oci8':
-                                               $driverConfig = '\'driverOptions\' => array(' .
-                                                               '\'connectSID\' => ' . ($instObj->INSTALL['localconf.php']['typo_db_type'] === 'sid' ? 'TRUE' : 'FALSE') .
-                                                               ')';
+                                               $driverConfig = array(
+                                                       'driverOptions' => array(
+                                                               'connectSID' =>  ($instObj->INSTALL['Database']['typo_db_type'] === 'sid' ? TRUE : FALSE)
+                                                       )
+                                               );
                                                break;
                                        case 'mssql':
                                        case 'odbc_mssql':
-                                               $driverConfig = '\'useNameQuote\' => TRUE,'
-                                                               . '\'quoteClob\' => FALSE';
+                                               $driverConfig = array(
+                                                       'useNameQuote' => TRUE,
+                                                       'quoteClob' => FALSE
+                                               );
                                                break;
                                        case 'mysql':
                                                return;
                                }
-                               $config = 'array(' .
-                                               '\'_DEFAULT\' => array(' .
-                                               '\'type\' => \'adodb\',' .
-                                               '\'config\' => array(' .
-                                               '\'driver\' => \'' . $driver . '\',' .
-                                               $driverConfig .
-                                               ')' .
-                                               ')' .
-                                               ');';
-                               $instObj->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'EXTCONF\'][\'dbal\'][\'handlerCfg\']', $config, FALSE);
+                               $config = array(
+                                       '_DEFAULT' => array(
+                                               'type' => 'adodb',
+                                               'config' => array(
+                                                       'driver' =>  $driver,
+                                                       $driverConfig
+                                               )
+                                       )
+                               );
+                               t3lib_Configuration::setLocalConfigurationValuesByPathValuePairs('EXTCONF/dbal/handlerCfg', $config);
                                break;
                }
        }
@@ -186,7 +190,7 @@ class tx_dbal_installtool {
                        // Only MySQL is actually available (PDO support may be compiled in
                        // PHP itself and as such DBAL was activated, behaves as if DBAL were
                        // not activated
-                       $driverSubPart = '<input type="hidden" name="TYPO3_INSTALL[localconf.php][typo_db_driver]" value="mysql" />';
+                       $driverSubPart = '<input type="hidden" name="TYPO3_INSTALL[Database][typo_db_driver]" value="mysql" />';
                } else {
                        $driverTemplate = t3lib_parsehtml::getSubpart(
                                $formSubPart, '###DATABASE_DRIVER###'
index 19925b7..77b0199 100644 (file)
                <ol>
                        <li class="t3-install-hidden">
                                <input type="hidden" value="###STEP###" name="step" />
-                               <input type="hidden" value="###ENCRYPTIONKEY###" name="TYPO3_INSTALL[localconf.php][encryptionKey]" />
-                               <input type="hidden" value="###BRANCH###" name="TYPO3_INSTALL[localconf.php][compat_version]" />
+                               <input type="hidden" value="###ENCRYPTIONKEY###" name="TYPO3_INSTALL[LocalConfiguration][encryptionKey]" />
+                               <input type="hidden" value="###BRANCH###" name="TYPO3_INSTALL[LocalConfiguration][compat_version]" />
                        </li>
                        <!-- ###DATABASE_DRIVER### begin -->
                        <li>
                                <label>###LABELDRIVER###</label>
-                               <select name="TYPO3_INSTALL[localconf.php][typo_db_driver]">
+                               <select name="TYPO3_INSTALL[Database][typo_db_driver]">
                                        <!-- ###ABSTRACTION_LAYER### begin -->
                                        <optgroup label="###LABELABSTRACTIONLAYER###">
                                                <!-- ###VENDOR### begin -->
@@ -64,7 +64,7 @@
                        <li>
                                <label for="t3-install-123-database">###LLOPTION2###</label>
                                <p>###LLREMARK2###</p>
-                               <select id="t3-install-123-database" name="TYPO3_INSTALL[localconf.php][typo_db]">
+                               <select id="t3-install-123-database" name="TYPO3_INSTALL[Database][typo_db]">
                                        <option value="">Select database</option>
                                        <!-- ###DATABASEOPTIONS### begin -->
                                        <option value="###DATABASEVALUE###" ###DATABASESELECTED###>###DATABASENAME###</option>
 <!-- ###DRIVER_MYSQLI### begin -->
 <li>
        <label for="t3-install-form-username">###LABELUSERNAME###</label>
-       <input id="t3-install-form-username" class="t3-install-form-input-text" type="text" value="###USERNAME###" name="TYPO3_INSTALL[localconf.php][typo_db_username]" />
+       <input id="t3-install-form-username" class="t3-install-form-input-text" type="text" value="###USERNAME###" name="TYPO3_INSTALL[Database][typo_db_username]" />
 </li>
 <li>
        <label for="t3-install-form-password">###LABELPASSWORD###</label>
-       <input id="t3-install-form-password" class="t3-install-form-input-text" type="password" value="###PASSWORD###" name="TYPO3_INSTALL[localconf.php][typo_db_password]" />
+       <input id="t3-install-form-password" class="t3-install-form-input-text" type="password" value="###PASSWORD###" name="TYPO3_INSTALL[Database][typo_db_password]" />
 </li>
 <li>
        <label for="t3-install-form-host">###LABELHOST###</label>
-       <input id="t3-install-form-host" class="t3-install-form-input-text" type="text" value="###HOST###" name="TYPO3_INSTALL[localconf.php][typo_db_host]" />
+       <input id="t3-install-form-host" class="t3-install-form-input-text" type="text" value="###HOST###" name="TYPO3_INSTALL[Database][typo_db_host]" />
 </li>
 <!-- ###DRIVER_MYSQLI### end -->
 <!-- ###DRIVER_MYSQL### end -->
 <!-- ###DRIVER_DEFAULT### begin -->
 <li>
        <label for="t3-install-form-username">###LABELUSERNAME###</label>
-       <input id="t3-install-form-username" class="t3-install-form-input-text" type="text" value="###USERNAME###" name="TYPO3_INSTALL[localconf.php][typo_db_username]" />
+       <input id="t3-install-form-username" class="t3-install-form-input-text" type="text" value="###USERNAME###" name="TYPO3_INSTALL[Database][typo_db_username]" />
 </li>
 <li>
        <label for="t3-install-form-password">###LABELPASSWORD###</label>
-       <input id="t3-install-form-password" class="t3-install-form-input-text" type="password" value="###PASSWORD###" name="TYPO3_INSTALL[localconf.php][typo_db_password]" />
+       <input id="t3-install-form-password" class="t3-install-form-input-text" type="password" value="###PASSWORD###" name="TYPO3_INSTALL[Database][typo_db_password]" />
 </li>
 <li>
        <label for="t3-install-form-host">###LABELHOST###</label>
-       <input id="t3-install-form-host" class="t3-install-form-input-text" type="text" value="###HOST###" name="TYPO3_INSTALL[localconf.php][typo_db_host]" />
+       <input id="t3-install-form-host" class="t3-install-form-input-text" type="text" value="###HOST###" name="TYPO3_INSTALL[Database][typo_db_host]" />
 </li>
 <li>
        <label for="t3-install-form-database">###LABELDATABASE###</label>
-       <input id="t3-install-form-database" class="t3-install-form-input-text" type="text" value="###DATABASE###" name="TYPO3_INSTALL[localconf.php][typo_db]" />
+       <input id="t3-install-form-database" class="t3-install-form-input-text" type="text" value="###DATABASE###" name="TYPO3_INSTALL[Database][typo_db]" />
 </li>
 <!-- ###DRIVER_DEFAULT### end -->
 
 <!-- ###DRIVER_MSSQL### begin -->
 <li>
        <label for="t3-install-form-username">###LABELUSERNAME###</label>
-       <input id="t3-install-form-username" class="t3-install-form-input-text" type="text" value="###USERNAME###" name="TYPO3_INSTALL[localconf.php][typo_db_username]" />
+       <input id="t3-install-form-username" class="t3-install-form-input-text" type="text" value="###USERNAME###" name="TYPO3_INSTALL[Database][typo_db_username]" />
 </li>
 <li>
        <label for="t3-install-form-password">###LABELPASSWORD###</label>
-       <input id="t3-install-form-password" class="t3-install-form-input-text" type="password" value="###PASSWORD###" name="TYPO3_INSTALL[localconf.php][typo_db_password]" />
+       <input id="t3-install-form-password" class="t3-install-form-input-text" type="password" value="###PASSWORD###" name="TYPO3_INSTALL[Database][typo_db_password]" />
 </li>
 <li>
        <label for="t3-install-form-host">###LABELHOST###</label>
-       <input id="t3-install-form-host" class="t3-install-form-input-text" type="text" value="###HOST###" name="TYPO3_INSTALL[localconf.php][typo_db_host]" />
+       <input id="t3-install-form-host" class="t3-install-form-input-text" type="text" value="###HOST###" name="TYPO3_INSTALL[Database][typo_db_host]" />
 </li>
 <li>
        <label for="t3-install-form-database">###LABELDATABASE###</label>
-       <input id="t3-install-form-database" class="t3-install-form-input-text" type="text" value="###DATABASE###" name="TYPO3_INSTALL[localconf.php][typo_db]" />
+       <input id="t3-install-form-database" class="t3-install-form-input-text" type="text" value="###DATABASE###" name="TYPO3_INSTALL[Database][typo_db]" />
 </li>
 <!-- ###DRIVER_MSSQL### end -->
 
 <!-- ###DRIVER_ODBC_MSSQL### begin -->
 <li>
        <label for="t3-install-form-username">###LABELUSERNAME###</label>
-       <input id="t3-install-form-username" class="t3-install-form-input-text" type="text" value="###USERNAME###" name="TYPO3_INSTALL[localconf.php][typo_db_username]" />
+       <input id="t3-install-form-username" class="t3-install-form-input-text" type="text" value="###USERNAME###" name="TYPO3_INSTALL[Database][typo_db_username]" />
 </li>
 <li>
        <label for="t3-install-form-password">###LABELPASSWORD###</label>
-       <input id="t3-install-form-password" class="t3-install-form-input-text" type="password" value="###PASSWORD###" name="TYPO3_INSTALL[localconf.php][typo_db_password]" />
+       <input id="t3-install-form-password" class="t3-install-form-input-text" type="password" value="###PASSWORD###" name="TYPO3_INSTALL[Database][typo_db_password]" />
 </li>
 <li>
        <label for="t3-install-form-host">###LABELHOST###</label>
-       <input id="t3-install-form-host" class="t3-install-form-input-text" type="text" value="###HOST###" name="TYPO3_INSTALL[localconf.php][typo_db_host]" />
+       <input id="t3-install-form-host" class="t3-install-form-input-text" type="text" value="###HOST###" name="TYPO3_INSTALL[Database][typo_db_host]" />
 </li>
-<input type="hidden" value="###DATABASE###" name="TYPO3_INSTALL[localconf.php][typo_db]" />
+<input type="hidden" value="###DATABASE###" name="TYPO3_INSTALL[Database][typo_db]" />
 <!-- ###DRIVER_ODBC_MSSQL### end -->
 
 
 <!-- ###DRIVER_OCI8### begin -->
 <li>
        <label for="t3-install-form-username">###LABELUSERNAME###</label>
-       <input id="t3-install-form-username" class="t3-install-form-input-text" type="text" value="###USERNAME###" name="TYPO3_INSTALL[localconf.php][typo_db_username]" />
+       <input id="t3-install-form-username" class="t3-install-form-input-text" type="text" value="###USERNAME###" name="TYPO3_INSTALL[Database][typo_db_username]" />
 </li>
 <li>
        <label for="t3-install-form-password">###LABELPASSWORD###</label>
-       <input id="t3-install-form-password" class="t3-install-form-input-text" type="password" value="###PASSWORD###" name="TYPO3_INSTALL[localconf.php][typo_db_password]" />
+       <input id="t3-install-form-password" class="t3-install-form-input-text" type="password" value="###PASSWORD###" name="TYPO3_INSTALL[Database][typo_db_password]" />
 </li>
 <li>
        <label for="t3-install-form-host">###LABELHOST###</label>
-       <input id="t3-install-form-host" class="t3-install-form-input-text" type="text" value="###HOST###" name="TYPO3_INSTALL[localconf.php][typo_db_host]" />
+       <input id="t3-install-form-host" class="t3-install-form-input-text" type="text" value="###HOST###" name="TYPO3_INSTALL[Database][typo_db_host]" />
 </li>
 <li>
        <label for="t3-install-form-type">###LABELTYPE###</label>
-       <select id="t3-install-form-type" name="TYPO3_INSTALL[localconf.php][typo_db_type]">
+       <select id="t3-install-form-type" name="TYPO3_INSTALL[Database][typo_db_type]">
                <option value="sid">###LABELSID###</option>
                <option value="servicename">###LABELSERVICENAME###</option>
        </select>
 </li>
 <li>
        <label for="t3-install-form-database">###LABELDATABASE###</label>
-       <input id="t3-install-form-database" class="t3-install-form-input-text" type="text" value="###DATABASE###" name="TYPO3_INSTALL[localconf.php][typo_db]" />
+       <input id="t3-install-form-database" class="t3-install-form-input-text" type="text" value="###DATABASE###" name="TYPO3_INSTALL[Database][typo_db]" />
 </li>
 <!-- ###DRIVER_OCI8### end -->