[BUGFIX] Do not try to download extensions in composer mode 82/56582/9
authorHelmut Hummel <typo3@helhum.io>
Fri, 6 Apr 2018 10:55:08 +0000 (12:55 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Sat, 7 Apr 2018 05:25:27 +0000 (07:25 +0200)
Upgrade wizards that download extensions from TER must
no do so in composer mode as they would create an unusable
system.

But in case the extension is found, in the system, these wizards
still activate them.

Resolves: #82318
Releases: master, 8.7
Change-Id: I5ad1fdfeb81ad809497d8a88db32325639cd236b
Reviewed-on: https://review.typo3.org/56582
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joshua Westerheide <account@jdoubleu.de>
Tested-by: Joshua Westerheide <account@jdoubleu.de>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/install/Classes/Updates/AbstractDownloadExtensionUpdate.php
typo3/sysext/install/Classes/Updates/Compatibility7ExtractionUpdate.php
typo3/sysext/install/Classes/Updates/FormLegacyExtractionUpdate.php
typo3/sysext/install/Classes/Updates/FuncExtractionUpdate.php
typo3/sysext/install/Classes/Updates/RedirectExtractionUpdate.php
typo3/sysext/install/Classes/Updates/RteHtmlAreaExtractionUpdate.php
typo3/sysext/install/Classes/Updates/Typo3DbExtractionUpdate.php
typo3/sysext/install/Tests/Unit/Updates/Compatibility7ExtractionUpdateTest.php

index 45be31f..0a0e9bb 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Updates;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Environment;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Extensionmanager\Utility\Connection\TerUtility;
@@ -58,15 +59,15 @@ abstract class AbstractDownloadExtensionUpdate extends AbstractUpdate
 
         /** @var $extensionListUtility ListUtility */
         $extensionListUtility = $objectManager->get(ListUtility::class);
-
         $availableExtensions = $extensionListUtility->getAvailableExtensions();
-        $availableAndInstalledExtensions = $extensionListUtility->getAvailableAndInstalledExtensions($availableExtensions);
+        $extensionDetails = $this->getExtensionDetails($extensionKey);
+
+        $isExtensionAvailable = !empty($availableExtensions[$extensionKey]);
+        $isComposerMode = Environment::isComposerMode();
 
-        // Extension is not downloaded yet.
-        if (!is_array($availableAndInstalledExtensions[$extensionKey])) {
+        if (!$isComposerMode && !$isExtensionAvailable) {
             /** @var $extensionTerUtility TerUtility */
             $extensionTerUtility = $objectManager->get(TerUtility::class);
-            $extensionDetails = $this->getExtensionDetails($extensionKey);
             if (empty($extensionDetails)) {
                 $updateSuccessful = false;
                 $customMessage .= 'No version information for extension ' . $extensionKey . ' found. Can not install the extension.';
@@ -90,11 +91,20 @@ abstract class AbstractDownloadExtensionUpdate extends AbstractUpdate
             $extensionListUtility->reloadAvailableExtensions();
         }
 
-        if ($updateSuccessful !== false) {
+        if ($isComposerMode && !$isExtensionAvailable) {
+            $updateSuccessful = false;
+            $customMessage .= 'The extension ' . $extensionKey . ' can not be downloaded since ' .
+              'Composer is used for package management. Please require this ' .
+              'extension as package via Composer: ' .
+              '"composer require ' . $extensionDetails['composerName'] . ':^' . $extensionDetails['versionString'] . '"';
+        }
+
+        if ($updateSuccessful) {
             /** @var $extensionInstallUtility InstallUtility */
             $extensionInstallUtility = $objectManager->get(InstallUtility::class);
             $extensionInstallUtility->install($extensionKey);
         }
+
         return $updateSuccessful;
     }
 
index 189bd91..b6aa71b 100644 (file)
@@ -39,7 +39,8 @@ class Compatibility7ExtractionUpdate extends AbstractDownloadExtensionUpdate
             'title' => 'Compatibility Mode for TYPO3 v7',
             'description' => 'Provides an additional backwards-compatibility layer with legacy functionality for sites that haven\'t fully migrated to TYPO3 v8 yet.',
             'versionString' => '8.7.1',
-        ]
+            'composerName' => 'friendsoftypo3/compatibility7',
+        ],
     ];
 
     /**
index 6aeb780..11c9f35 100644 (file)
@@ -42,7 +42,8 @@ class FormLegacyExtractionUpdate extends AbstractDownloadExtensionUpdate
             'title' => 'Legacy form extension for TYPO3 v7 compatibility',
             'description' => 'Provides an additional backwards-compatibility layer with legacy functionality for sites that used the form extension in TYPO3 v7.',
             'versionString' => '8.7.0',
-        ]
+            'composerName' => 'friendsoftypo3/form-legacy',
+        ],
     ];
 
     /**
index 679fca5..19001ca 100644 (file)
@@ -39,7 +39,8 @@ class FuncExtractionUpdate extends AbstractDownloadExtensionUpdate
             'title' => 'Web->Functions module',
             'description' => 'Provides Web->Functions BE module used in previous TYPO3 versions for extensions that still rely on it.',
             'versionString' => '9.0.1',
-        ]
+            'composerName' => 'friendsoftypo3/cms-func',
+        ],
     ];
 
     /**
index ceb0ac7..e31db5d 100644 (file)
@@ -40,7 +40,8 @@ class RedirectExtractionUpdate extends AbstractDownloadExtensionUpdate
             'title' => 'Redirects based on &RDCT parameter',
             'description' => 'Provides redirects based on "cache_md5params" and the GET parameter &RDCT for extensions that still rely on it.',
             'versionString' => '1.0.0',
-        ]
+            'composerName' => 'friendsoftypo3/rdct',
+        ],
     ];
 
     /**
index 0237106..e1604d2 100644 (file)
@@ -39,7 +39,8 @@ class RteHtmlAreaExtractionUpdate extends AbstractDownloadExtensionUpdate
             'title' => 'RTE HTMLArea for TYPO3',
             'description' => 'Provides the well-known RTE used in previous TYPO3 versions, if handling of images or custom configurations are necessary.',
             'versionString' => '8.7.0',
-        ]
+            'composerName' => 'friendsoftypo3/rtehtmlarea',
+        ],
     ];
 
     /**
index 64ef559..a96ac13 100644 (file)
@@ -39,7 +39,8 @@ class Typo3DbExtractionUpdate extends AbstractDownloadExtensionUpdate
             'title' => '$GLOBALS[\'TYPO3_DB\'] compatibility layer',
             'description' => 'Provides the well-known database API $GLOBALS[\'TYPO3_DB\'] used in previous TYPO3 versions for extensions that still rely on it.',
             'versionString' => '1.0.1',
-        ]
+            'composerName' => 'friendsoftypo3/typo3db-legacy',
+        ],
     ];
 
     /**
index d61447b..d50c107 100644 (file)
@@ -114,7 +114,7 @@ class Compatibility7ExtractionUpdateTest extends UnitTestCase
         $installUtility = $this->prophesize(InstallUtility::class);
         $objectManager->get(InstallUtility::class)->willReturn($installUtility->reveal());
         $objectManager->get(ListUtility::class)->willReturn($listUtility->reveal());
-        $extensionList = ['compatibility7' => []];
+        $extensionList = ['compatibility7' => ['foo' => 'bar']];
         $listUtility->getAvailableExtensions()->willReturn($extensionList);
         $listUtility->getAvailableAndInstalledExtensions($extensionList)->willReturn($extensionList);
         $installUtility->install('compatibility7')->shouldBeCalled();