[BUGFIX] SQL error in install tool if no root page available
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Updates / CharsetDefaultsUpdate.php
1 <?php
2 namespace TYPO3\CMS\Install\Updates;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2010-2013 Michael Stucki <michael@typo3.org>, Benjamin Mack <benni@typo3.org>
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 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Displays warnings and information about the database character set
32 */
33 class CharsetDefaultsUpdate extends AbstractUpdate {
34
35 /**
36 * @var string
37 */
38 protected $title = 'Database Character Set';
39
40 /**
41 * Checks if the configuration is relying on old default values or not.
42 * If needed, this updater will fix the configuration appropriately.
43 *
44 * @param string &$description The description for the update
45 * @param string &$showUpdate 0=don't show update; 1=show update and next button; 2=only show description
46 * @return boolean Whether an update is needed (TRUE) or not (FALSE)
47 */
48 public function checkForUpdate(&$description, &$showUpdate = FALSE) {
49 if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit'] === '-1') {
50 $description = 'The configuration variables $TYPO3_CONF_VARS[\'SYS\'][\'setDBinit\']
51 is relying on empty default values.<br />
52 However, the default has changed in TYPO3 4.5.<br /><br />
53 Please click "Next" to write the former default settings to your localconf.php,
54 so that your setup will continue to work like before.';
55 $showUpdate = 1;
56 }
57 }
58
59 /**
60 * Write the current configuration to localconf.php
61 * This is needed for any sites that were relying on the former default
62 * values which are going to change in TYPO3 4.5.
63 *
64 * @param array &$dbQueries Queries done in this update
65 * @param mixed &$customMessages Custom messages
66 * @return boolean Whether the updated was made or not
67 */
68 public function performUpdate(array &$dbQueries, &$customMessages) {
69 // Update "setDBinit" setting
70 $result1 = FALSE;
71 if (\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager')->getLocalConfigurationValueByPath('SYS/setDBinit') === '-1') {
72 $result1 = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager')->setLocalConfigurationValueByPath('SYS/setDBinit', '');
73 }
74 if ($result1) {
75 $customMessages[] = 'The configuration was successfully updated.';
76 return TRUE;
77 } else {
78 return FALSE;
79 }
80 }
81
82 }
83
84 ?>