[BUGFIX] Save PackageStates.php after deletion 41/40041/2
authorNicole Cordes <typo3@cordes.co>
Sat, 6 Jun 2015 10:56:20 +0000 (12:56 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Sat, 6 Jun 2015 14:25:58 +0000 (16:25 +0200)
If you delete an extension in EM, the PackageManager currently saves
a broken PackagesStates.php with invalid extension information.

This patch adds a missing save invocation for the changed
PackageStatesConfiguration. Furthermore a new path check is executed
while restoring the PackageStatesConfiguration because otherwise a
package with a wrong packagePath is registered.

Resolves: #67294
Releases: master
Change-Id: I9ad3b56a382f980e703009f8343ddb151ef4a8b1
Reviewed-on: http://review.typo3.org/40041
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/Package/PackageManager.php

index b908e8b..693befe 100644 (file)
@@ -463,9 +463,14 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface {
                                continue;
                        }
 
-                       $packagePath = isset($stateConfiguration['packagePath']) ? $stateConfiguration['packagePath'] : NULL;
+                       if (!isset($stateConfiguration['packagePath'])) {
+                               $this->unregisterPackageByPackageKey($packageKey);
+                               $packageStatesHasChanged = TRUE;
+                               continue;
+                       }
+
                        try {
-                               $packagePath = PathUtility::sanitizeTrailingSeparator($this->packagesBasePath . $packagePath);
+                               $packagePath = PathUtility::sanitizeTrailingSeparator($this->packagesBasePath . $stateConfiguration['packagePath']);
                                $package = new Package($this, $packageKey, $packagePath);
                        } catch (Exception\InvalidPackagePathException $exception) {
                                $this->unregisterPackageByPackageKey($packageKey);
@@ -536,7 +541,6 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface {
                                foreach ($package->getPackageReplacementKeys() as $packageToReplace => $versionConstraint) {
                                        unset($this->packageAliasMap[strtolower($packageToReplace)]);
                                }
-                               $packageKey = $package->getPackageKey();
                        }
                } catch (Exception\UnknownPackageException $e) {
                }
@@ -725,6 +729,7 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface {
                }
 
                $this->unregisterPackage($package);
+               $this->sortAndSavePackageStates();
 
                $packagePath = $package->getPackagePath();
                $deletion = GeneralUtility::rmdir($packagePath, TRUE);