[!!!][TASK] New local configuration handling
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / updates / class.tx_coreupdates_charsetdefaults.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Michael Stucki <michael@typo3.org>, Benjamin Mack <benni@typo3.org>
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 /**
29 * Displays warnings and information about the database character set
30 */
31 class tx_coreupdates_charsetDefaults extends Tx_Install_Updates_Base {
32 protected $title = 'Database Character Set';
33
34 /**
35 * Checks if the configuration is relying on old default values or not.
36 * If needed, this updater will fix the configuration appropriately.
37 *
38 * @param string &$description: The description for the update
39 * @param string &$showUpdate: 0=dont show update; 1=show update and next button; 2=only show description
40 * @return boolean whether an update is needed (TRUE) or not (FALSE)
41 */
42 public function checkForUpdate(&$description, &$showUpdate = FALSE) {
43 if ((isset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'])
44 && $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] != ''
45 && $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] != 'utf-8') ||
46 $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] === '-1') {
47
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.';
53 $showUpdate = 1;
54 }
55 }
56
57
58 /**
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.
62 *
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
66 */
67 public function performUpdate(array &$dbQueries, &$customMessages) {
68 // Update "setDBinit" setting
69 $result1 = FALSE;
70 if (t3lib_Configuration::getLocalConfigurationValueByPath('SYS/setDBinit') === '-1') {
71 $result1 = t3lib_Configuration::setLocalConfigurationValueByPath('SYS/setDBinit', '');
72 }
73
74 // Update the "forceCharset" setting
75 $result2 = FALSE;
76 if (t3lib_Configuration::getLocalConfigurationValueByPath('BE/forceCharset') !== '') {
77 $result2 = t3lib_Configuration::setLocalConfigurationValueByPath('BE/forceCharset', '');
78 }
79
80 if ($result1 && $result2) {
81 $customMessages[] = 'The configuration was successfully updated.';
82 return TRUE;
83 } else {
84 return FALSE; // something went wrong
85 }
86 }
87 }
88
89 ?>