[BUGFIX] Cannot uninstall packages with dependencies in install tool 46/34946/3
authorOliver Hader <oliver@typo3.org>
Tue, 2 Dec 2014 18:23:03 +0000 (19:23 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Tue, 2 Dec 2014 18:40:03 +0000 (19:40 +0100)
Scenario:
* upgrading from Introcuction Package with TYPO3 CMS 6.2
  to TYPO3 CMS 7
* realurl is marked as incompatible extension to be uninstalled
* realurl is a dependency of bootstrap_package which itself is
  dependency of introduction

Result:
* resolving the dependencies does not work and thus the uninstall
  process for realurl fails as well

Solution:
* check whether extension to be removed is a dependency of some
  other extension
* if so, first remove that extension and afterwards to original
  extension

Resolves: #63526
Releases: master
Change-Id: Ie2bbfc1d46f338c42d557ec6d103b7766317cf75
Reviewed-on: http://review.typo3.org/34946
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/core/Classes/Package/PackageManager.php

index 011350b..5b8d078 100644 (file)
@@ -598,6 +598,17 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
         * @param string $packageKey
         */
        public function deactivatePackage($packageKey) {
+               $this->sortAvailablePackagesByDependencies();
+
+               foreach ($this->packageStatesConfiguration['packages'] as $packageStateKey => $packageStateConfiguration) {
+                       if ($packageKey === $packageStateKey || empty($packageStateConfiguration['dependencies']) || $packageStateConfiguration['state'] !== 'active') {
+                               continue;
+                       }
+                       if (in_array($packageKey, $packageStateConfiguration['dependencies'])) {
+                               $this->deactivatePackage($packageStateKey);
+                       }
+               }
+
                $package = $this->getPackage($packageKey);
                parent::deactivatePackage($package->getPackageKey());
        }