[TASK] Streamline upgrade wizards that install extensions 59/56559/5
authorSusanne Moog <susanne.moog@typo3.org>
Sun, 8 Apr 2018 07:50:32 +0000 (09:50 +0200)
committerSusanne Moog <susanne.moog@typo3.org>
Sun, 8 Apr 2018 17:47:38 +0000 (19:47 +0200)
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: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/install/Classes/Updates/AdminPanelInstall.php
typo3/sysext/install/Classes/Updates/RedirectsExtensionUpdate.php

index 8239285..105b8a0 100644 (file)
@@ -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;
     }
index 832d0ff..97c08b0 100644 (file)
@@ -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();
@@ -115,41 +118,6 @@ class RedirectsExtensionUpdate extends AbstractUpdate implements LoggerAwareInte
     }
 
     /**
-     * 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
      */
     protected function migrateRedirectDomainsToSysRedirect()