Skip to content
Snippets Groups Projects
Commit 967c8897 authored by Susanne Moog's avatar Susanne Moog
Browse files

[TASK] Streamline upgrade wizards that install extensions

Let the adminpanel and redirect upgrade wizards make use of
the abstract wizard for installing extensions,
which includes handling composer based installations.

Resolves: #84660
Releases: master
Change-Id: Iab7f3ed44945362a315a7f4d32497c6a1c70d779
Reviewed-on: https://review.typo3.org/56559


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarMathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: default avatarMathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: default avatarSusanne Moog <susanne.moog@typo3.org>
Tested-by: default avatarSusanne Moog <susanne.moog@typo3.org>
parent 6a3b6a5e
Branches
Tags
No related merge requests found
......@@ -17,15 +17,11 @@ namespace TYPO3\CMS\Install\Updates;
*/
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
use TYPO3\CMS\Extensionmanager\Utility\InstallUtility;
/**
* Installs EXT:adminpanel
*/
class AdminPanelInstall extends AbstractUpdate
class AdminPanelInstall extends AbstractDownloadExtensionUpdate
{
/**
* @var string
......@@ -37,6 +33,15 @@ class AdminPanelInstall extends AbstractUpdate
*/
protected $extensionKey = 'adminpanel';
protected $extensionDetails = [
'adminpanel' => [
'title' => 'TYPO3 Admin Panel',
'description' => 'The TYPO3 admin panel provides a panel with additional functionality in the frontend (Debugging, Caching, Preview...)',
'versionString' => '9.2',
'composerName' => 'typo3/cms-adminpanel',
],
];
/**
* Checks if an update is needed
*
......@@ -67,14 +72,9 @@ class AdminPanelInstall extends AbstractUpdate
*/
public function performUpdate(array &$databaseQueries, &$customMessage): bool
{
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$extensionInstallUtility = $objectManager->get(InstallUtility::class);
try {
$extensionInstallUtility->install('adminpanel');
$updateSuccessful = true;
$updateSuccessful = $this->installExtension($this->extensionKey, $customMessage);
if ($updateSuccessful) {
$this->markWizardAsDone();
} catch (ExtensionManagerException $e) {
$updateSuccessful = false;
}
return $updateSuccessful;
}
......
......@@ -19,16 +19,12 @@ use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
use TYPO3\CMS\Extensionmanager\Utility\InstallUtility;
use TYPO3\CMS\Extensionmanager\Utility\ListUtility;
/**
* Installs EXT:redirect if sys_domain.redirectTo is filled, and migrates the values from redirectTo
* to a proper sys_redirect entry.
*/
class RedirectsExtensionUpdate extends AbstractUpdate implements LoggerAwareInterface
class RedirectsExtensionUpdate extends AbstractDownloadExtensionUpdate implements LoggerAwareInterface
{
use LoggerAwareTrait;
......@@ -38,9 +34,16 @@ class RedirectsExtensionUpdate extends AbstractUpdate implements LoggerAwareInte
protected $title = 'Install system extension "redirects" if a sys_domain entry with redirectTo is necessary';
/**
* @var string
* @var array
*/
protected $extensionKey = 'redirects';
protected $extensionDetails = [
'redirects' => [
'title' => 'Redirects',
'description' => 'Manage redirects for your TYPO3-based website',
'versionString' => '9.2',
'composerName' => 'typo3/cms-redirects',
],
];
/**
* Checks if an update is needed
......@@ -76,7 +79,7 @@ class RedirectsExtensionUpdate extends AbstractUpdate implements LoggerAwareInte
public function performUpdate(array &$databaseQueries, &$customMessage): bool
{
// Install the EXT:redirects extension if not happened yet
$installationSuccessful = $this->installExtension($this->extensionKey);
$installationSuccessful = $this->installExtension('redirects', $customMessage);
if ($installationSuccessful) {
// Migrate the database entries
$this->migrateRedirectDomainsToSysRedirect();
......@@ -114,41 +117,6 @@ class RedirectsExtensionUpdate extends AbstractUpdate implements LoggerAwareInte
return false;
}
/**
* This method can be called to install an extension following all proper processes
* (e.g. installing in extList, respecting priority, etc.)
*
* @param string $extensionKey
* @return bool
*/
protected function installExtension(string $extensionKey): bool
{
$extensionInstalled = false;
/** @var $objectManager ObjectManager */
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var $extensionListUtility ListUtility */
$extensionListUtility = $objectManager->get(ListUtility::class);
$availableExtensions = $extensionListUtility->getAvailableExtensions();
$availableAndInstalledExtensions = $extensionListUtility->getAvailableAndInstalledExtensions($availableExtensions);
// Extension is not installed yet, install it
if (!isset($availableAndInstalledExtensions[$extensionKey]['installed']) || $availableAndInstalledExtensions[$extensionKey]['installed'] !== true) {
/** @var $extensionInstallUtility InstallUtility */
$extensionInstallUtility = $objectManager->get(InstallUtility::class);
try {
$extensionInstallUtility->install($extensionKey);
$extensionInstalled = true;
} catch (ExtensionManagerException $e) {
$this->logger->warning($e->getMessage());
}
} else {
$extensionInstalled = true;
}
return $extensionInstalled;
}
/**
* Move all sys_domain records with a "redirectTo" value filled (also deleted) to "sys_redirect" record
*/
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment