[TASK] Doctrine: Migrate OpenidExtractionUpdate
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Updates / OpenidExtractionUpdate.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 use TYPO3\CMS\Core\Database\ConnectionPool;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20 /**
21 * Installs and downloads EXT:openid if needed
22 */
23 class OpenidExtractionUpdate extends AbstractDownloadExtensionUpdate
24 {
25 /**
26 * @var string
27 */
28 protected $title = 'Installs extension "openid" from TER if openid is used.';
29
30 /**
31 * @var string
32 */
33 protected $extensionKey = 'openid';
34
35 /**
36 * @var array
37 */
38 protected $extensionDetails = [
39 'openid' => [
40 'title' => 'OpenID authentication',
41 'description' => 'Adds OpenID authentication to TYPO3',
42 'versionString' => '7.6.0',
43 ]
44 ];
45
46 /**
47 * Checks if an update is needed
48 *
49 * @param string $description The description for the update
50 * @return bool Whether an update is needed (true) or not (false)
51 */
52 public function checkForUpdate(&$description)
53 {
54 $updateNeeded = false;
55
56 if (!$this->isWizardDone()) {
57 $columnsExists = false;
58
59 $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
60 $schemaManager = $connectionPool->getConnectionForTable('fe_users')->getSchemaManager();
61
62 if ($schemaManager->listTableDetails('fe_users')->hasColumn('tx_openid_openid')) {
63 $columnsExists = true;
64 }
65
66 // Reinitialize schemaManager, since be_users could be on another connection
67 $schemaManager = $connectionPool->getConnectionForTable('be_users')->getSchemaManager();
68
69 if ($schemaManager->listTableDetails('be_users')->hasColumn('tx_openid_openid')) {
70 $columnsExists = true;
71 }
72 if ($columnsExists) {
73 $updateNeeded = true;
74 }
75 }
76
77 $description = 'The extension "openid" (OpenID authentication) was extracted into '
78 . 'the TYPO3 Extension Repository. This update checks if openid id used and '
79 . 'downloads the TYPO3 Extension from the TER.';
80
81 return $updateNeeded;
82 }
83
84 /**
85 * Performs the update if EXT:openid is used.
86 *
87 * @param array $databaseQueries Queries done in this update
88 * @param mixed $customMessages Custom messages
89 * @return bool
90 */
91 public function performUpdate(array &$databaseQueries, &$customMessages)
92 {
93 $updateSuccessful = $this->installExtension($this->extensionKey, $customMessages);
94 if ($updateSuccessful) {
95 $this->markWizardAsDone();
96 }
97 return $updateSuccessful;
98 }
99 }