From 88d586bcfb30a529c8dcefab697d83dbe45e5e3e Mon Sep 17 00:00:00 2001 From: Helmut Hummel <typo3@helhum.io> Date: Fri, 6 Apr 2018 12:55:08 +0200 Subject: [PATCH] [BUGFIX] Do not try to download extensions in composer mode 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> --- .../AbstractDownloadExtensionUpdate.php | 22 ++++++++++++++----- .../Compatibility7ExtractionUpdate.php | 3 ++- .../Updates/FormLegacyExtractionUpdate.php | 3 ++- .../Classes/Updates/FuncExtractionUpdate.php | 3 ++- .../Updates/RedirectExtractionUpdate.php | 3 ++- .../Updates/RteHtmlAreaExtractionUpdate.php | 3 ++- .../Updates/Typo3DbExtractionUpdate.php | 3 ++- .../Compatibility7ExtractionUpdateTest.php | 2 +- 8 files changed, 29 insertions(+), 13 deletions(-) diff --git a/typo3/sysext/install/Classes/Updates/AbstractDownloadExtensionUpdate.php b/typo3/sysext/install/Classes/Updates/AbstractDownloadExtensionUpdate.php index 45be31f8ad01..0a0e9bb3fecc 100644 --- a/typo3/sysext/install/Classes/Updates/AbstractDownloadExtensionUpdate.php +++ b/typo3/sysext/install/Classes/Updates/AbstractDownloadExtensionUpdate.php @@ -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; } diff --git a/typo3/sysext/install/Classes/Updates/Compatibility7ExtractionUpdate.php b/typo3/sysext/install/Classes/Updates/Compatibility7ExtractionUpdate.php index 189bd9112dd4..b6aa71bda280 100644 --- a/typo3/sysext/install/Classes/Updates/Compatibility7ExtractionUpdate.php +++ b/typo3/sysext/install/Classes/Updates/Compatibility7ExtractionUpdate.php @@ -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', + ], ]; /** diff --git a/typo3/sysext/install/Classes/Updates/FormLegacyExtractionUpdate.php b/typo3/sysext/install/Classes/Updates/FormLegacyExtractionUpdate.php index 6aeb7800d9dd..11c9f35447be 100644 --- a/typo3/sysext/install/Classes/Updates/FormLegacyExtractionUpdate.php +++ b/typo3/sysext/install/Classes/Updates/FormLegacyExtractionUpdate.php @@ -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', + ], ]; /** diff --git a/typo3/sysext/install/Classes/Updates/FuncExtractionUpdate.php b/typo3/sysext/install/Classes/Updates/FuncExtractionUpdate.php index 679fca512571..19001ca351c7 100644 --- a/typo3/sysext/install/Classes/Updates/FuncExtractionUpdate.php +++ b/typo3/sysext/install/Classes/Updates/FuncExtractionUpdate.php @@ -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', + ], ]; /** diff --git a/typo3/sysext/install/Classes/Updates/RedirectExtractionUpdate.php b/typo3/sysext/install/Classes/Updates/RedirectExtractionUpdate.php index ceb0ac7e8185..e31db5d22f94 100644 --- a/typo3/sysext/install/Classes/Updates/RedirectExtractionUpdate.php +++ b/typo3/sysext/install/Classes/Updates/RedirectExtractionUpdate.php @@ -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', + ], ]; /** diff --git a/typo3/sysext/install/Classes/Updates/RteHtmlAreaExtractionUpdate.php b/typo3/sysext/install/Classes/Updates/RteHtmlAreaExtractionUpdate.php index 0237106a2436..e1604d22db82 100644 --- a/typo3/sysext/install/Classes/Updates/RteHtmlAreaExtractionUpdate.php +++ b/typo3/sysext/install/Classes/Updates/RteHtmlAreaExtractionUpdate.php @@ -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', + ], ]; /** diff --git a/typo3/sysext/install/Classes/Updates/Typo3DbExtractionUpdate.php b/typo3/sysext/install/Classes/Updates/Typo3DbExtractionUpdate.php index 64ef5592e844..a96ac1367302 100644 --- a/typo3/sysext/install/Classes/Updates/Typo3DbExtractionUpdate.php +++ b/typo3/sysext/install/Classes/Updates/Typo3DbExtractionUpdate.php @@ -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', + ], ]; /** diff --git a/typo3/sysext/install/Tests/Unit/Updates/Compatibility7ExtractionUpdateTest.php b/typo3/sysext/install/Tests/Unit/Updates/Compatibility7ExtractionUpdateTest.php index d61447b23795..d50c10765675 100644 --- a/typo3/sysext/install/Tests/Unit/Updates/Compatibility7ExtractionUpdateTest.php +++ b/typo3/sysext/install/Tests/Unit/Updates/Compatibility7ExtractionUpdateTest.php @@ -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(); -- GitLab