[BUGFIX] Search in Install Tool must find input values
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Updates / BackendUserStartModuleUpdateAboutModule.php
1 <?php
2 namespace TYPO3\CMS\Install\Updates;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Update backend user setting startModule if set to "help_aboutmodules"
19 */
20 class BackendUserStartModuleUpdateAboutModule extends AbstractUpdate
21 {
22 /**
23 * @var string
24 */
25 protected $title = 'Update backend user setting "startModule"';
26
27 /**
28 * Checks if an update is needed
29 *
30 * @param string &$description The description for the update
31 * @return bool Whether an update is needed (TRUE) or not (FALSE)
32 */
33 public function checkForUpdate(&$description)
34 {
35 $backendUsersCount = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', 'be_users');
36 if ($this->isWizardDone() || $backendUsersCount === 0) {
37 return false;
38 }
39
40 $description = 'The backend user setting startModule is changed for the extension aboutmodules. Update all '
41 . 'backend users that use ext:aboutmodules as startModule.';
42
43 return true;
44 }
45
46 /**
47 * Performs the database update if backend user's startmodule is help_aboutmodules
48 *
49 * @param array &$databaseQueries Queries done in this update
50 * @param mixed &$customMessages Custom messages
51 * @return bool
52 */
53 public function performUpdate(array &$databaseQueries, &$customMessages)
54 {
55 $db = $this->getDatabaseConnection();
56 $backendUsers = $db->exec_SELECTgetRows('uid,uc', 'be_users', '1=1');
57 if (!empty($backendUsers)) {
58 foreach ($backendUsers as $backendUser) {
59 if ($backendUser['uc'] !== null) {
60 $userConfig = unserialize($backendUser['uc']);
61 if ($userConfig['startModule'] === 'help_AboutmodulesAboutmodules') {
62 $userConfig['startModule'] = 'help_AboutAboutmodules';
63 $db->exec_UPDATEquery(
64 'be_users',
65 'uid=' . (int)$backendUser['uid'],
66 array(
67 'uc' => serialize($userConfig),
68 )
69 );
70 $databaseQueries[] = $db->debug_lastBuiltQuery;
71 }
72 }
73 }
74 }
75
76 $this->markWizardAsDone();
77 return true;
78 }
79 }