2 /***************************************************************
5 * (c) 2010 Michael Stucki <michael@typo3.org>, Benjamin Mack <benni@typo3.org>
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
29 * Displays warnings and information about the database character set
33 class tx_coreupdates_charsetDefaults
extends Tx_Install_Updates_Base
{
34 protected $title = 'Database Character Set';
37 * Checks if the configuration is relying on old default values or not.
38 * If needed, this updater will fix the configuration appropriately.
40 * @param string &$description: The description for the update
41 * @param string &$showUpdate: 0=dont show update; 1=show update and next button; 2=only show description
42 * @return boolean whether an update is needed (true) or not (false)
44 public function checkForUpdate(&$description, &$showUpdate = FALSE) {
45 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] === '-1' ||
46 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] === '-1') {
48 $description = 'The configuration variables $TYPO3_CONF_VARS[\'SYS\'][\'setDBinit\'] and/or
49 $TYPO3_CONF_VARS[\'BE\'][\'forceCharset\'] are relying on empty default values.<br />
50 However, the defaults for both values have changed in TYPO3 4.5.<br /><br />
51 Please click "Next" to write the former default settings to your localconf.php,
52 so that your setup will continue to work like before.';
59 * Write the current configuration to localconf.php
60 * This is needed for any sites that were relying on the former default
61 * values which are going to change in TYPO3 4.5.
63 * @param array &$dbQueries: queries done in this update
64 * @param mixed &$customMessages: custom messages
65 * @return boolean whether the updated was made or not
67 public function performUpdate(array &$dbQueries, &$customMessages) {
68 $localconf = $this->pObj
->writeToLocalconf_control();
70 // Update "setDBinit" setting
71 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] === '-1') {
72 $this->pObj
->setValueInLocalconfFile($localconf, '$TYPO3_CONF_VARS[\'SYS\'][\'setDBinit\']', '');
75 // Update the "forceCharset" setting
76 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] === '-1') {
77 $this->pObj
->setValueInLocalconfFile($localconf, '$TYPO3_CONF_VARS[\'BE\'][\'forceCharset\']', '');
80 $message = $this->pObj
->writeToLocalconf_control($localconf);
81 if ($message == 'continue') {
82 $customMessages[] = 'The configuration was successfully updated.';
85 return FALSE; // something went wrong