‪TYPO3CMS  9.5
StartModuleUpdate.php
Go to the documentation of this file.
1 <?php
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 
19 
25 {
29  public function ‪getIdentifier(): string
30  {
31  return 'startModuleUpdate';
32  }
33 
37  public function ‪getTitle(): string
38  {
39  return 'Update backend user setting "startModule"';
40  }
41 
45  public function ‪getDescription(): string
46  {
47  return 'The backend user setting startModule is changed for the extensions about/aboutmodules.'
48  . ' Update all backend users that use ext:aboutmodules as startModule.';
49  }
50 
56  public function ‪updateNecessary(): bool
57  {
58  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
59  $queryBuilder->getRestrictions()->removeAll();
60  $statement = $queryBuilder->select('uid', 'uc')->from('be_users')->execute();
61  $needsExecution = false;
62  while ($backendUser = $statement->fetch()) {
63  if ($backendUser['uc'] !== null) {
64  $userConfig = unserialize($backendUser['uc'], ['allowed_classes' => false]);
65  if ($userConfig['startModule'] === 'help_aboutmodules'
66  || $userConfig['startModule'] === 'help_AboutmodulesAboutmodules'
67  || $userConfig['startModule'] === 'help_AboutAboutmodules'
68  ) {
69  $needsExecution = true;
70  break;
71  }
72  }
73  }
74  return $needsExecution;
75  }
76 
80  public function ‪getPrerequisites(): array
81  {
82  return [
83  DatabaseUpdatedPrerequisite::class
84  ];
85  }
86 
93  public function ‪executeUpdate(): bool
94  {
95  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
96  $queryBuilder->getRestrictions()->removeAll();
97  $statement = $queryBuilder->select('uid', 'uc')->from('be_users')->execute();
98  while ($backendUser = $statement->fetch()) {
99  if ($backendUser['uc'] !== null) {
100  $userConfig = unserialize($backendUser['uc'], ['allowed_classes' => false]);
101  if ($userConfig['startModule'] === 'help_aboutmodules'
102  || $userConfig['startModule'] === 'help_AboutmodulesAboutmodules'
103  || $userConfig['startModule'] === 'help_AboutAboutmodules'
104  ) {
105  $userConfig['startModule'] = 'help_AboutAbout';
106  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
107  $queryBuilder->getRestrictions()->removeAll();
108  $queryBuilder->update('be_users')
109  ->where(
110  $queryBuilder->expr()->eq(
111  'uid',
112  $queryBuilder->createNamedParameter($backendUser['uid'], \PDO::PARAM_INT)
113  )
114  )
115  ->set('uc', $queryBuilder->createNamedParameter(serialize($userConfig), \PDO::PARAM_LOB))
116  ->execute();
117  }
118  }
119  }
120  return true;
121  }
122 }
‪TYPO3\CMS\Install\Updates\StartModuleUpdate
Definition: StartModuleUpdate.php:25
‪TYPO3\CMS\Install\Updates\StartModuleUpdate\executeUpdate
‪bool executeUpdate()
Definition: StartModuleUpdate.php:93
‪TYPO3\CMS\Install\Updates\StartModuleUpdate\getIdentifier
‪string getIdentifier()
Definition: StartModuleUpdate.php:29
‪TYPO3\CMS\Install\Updates\StartModuleUpdate\getPrerequisites
‪string[] getPrerequisites()
Definition: StartModuleUpdate.php:80
‪TYPO3\CMS\Install\Updates\StartModuleUpdate\updateNecessary
‪bool updateNecessary()
Definition: StartModuleUpdate.php:56
‪TYPO3\CMS\Install\Updates\StartModuleUpdate\getTitle
‪string getTitle()
Definition: StartModuleUpdate.php:37
‪TYPO3\CMS\Install\Updates
Definition: AbstractDownloadExtensionUpdate.php:3
‪TYPO3\CMS\Install\Updates\StartModuleUpdate\getDescription
‪string getDescription()
Definition: StartModuleUpdate.php:45
‪TYPO3\CMS\Install\Updates\UpgradeWizardInterface
Definition: UpgradeWizardInterface.php:22
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:44
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45