[BUGFIX] Prevent sorting incomplete loaded packages 47/39147/2
authorNicole Cordes <typo3@cordes.co>
Fri, 1 May 2015 08:52:43 +0000 (10:52 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 1 May 2015 09:36:37 +0000 (11:36 +0200)
If an extension is defined in PackageStates.php but missing in file
system the package gets unloaded and the PackageStates.php is rewritten.
If a core extension is missing (e.g. extra_page_cm_options) the file
is rewritten with incomplete loaded package information and gets wrongly
sorted.

Releases: master, 6.2
Resolves: #66699
Change-Id: I18e4bb83cf1676537a45ea4b07b9228335e34ec7
Reviewed-on: http://review.typo3.org/39147
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Package/PackageManager.php

index 5e9013b..bcef371 100644 (file)
@@ -433,6 +433,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
         * @throws \TYPO3\Flow\Package\Exception\CorruptPackageException
         */
        protected function registerPackagesFromConfiguration($registerOnlyNewPackages = FALSE) {
+               $packageStatesHasChanged = FALSE;
                foreach ($this->packageStatesConfiguration['packages'] as $packageKey => $stateConfiguration) {
 
                        if ($registerOnlyNewPackages && $this->isPackageAvailable($packageKey)) {
@@ -447,9 +448,11 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                                $package = $this->getPackageFactory()->create($this->packagesBasePath, $packagePath, $packageKey, $classesPath, $manifestPath);
                        } catch (\TYPO3\Flow\Package\Exception\InvalidPackagePathException $exception) {
                                $this->unregisterPackageByPackageKey($packageKey);
+                               $packageStatesHasChanged = TRUE;
                                continue;
                        } catch (\TYPO3\Flow\Package\Exception\InvalidPackageKeyException $exception) {
                                $this->unregisterPackageByPackageKey($packageKey);
+                               $packageStatesHasChanged = TRUE;
                                continue;
                        }
 
@@ -464,6 +467,9 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                                $this->activePackages[$packageKey] = $this->packages[$packageKey];
                        }
                }
+               if ($packageStatesHasChanged) {
+                       $this->sortAndSavePackageStates();
+               }
        }
 
        /**
@@ -501,7 +507,9 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                        }
                } catch (\TYPO3\Flow\Package\Exception\UnknownPackageException $e) {
                }
-               parent::unregisterPackageByPackageKey($packageKey);
+               unset($this->packages[$packageKey]);
+               unset($this->packageKeys[strtolower($packageKey)]);
+               unset($this->packageStatesConfiguration['packages'][$packageKey]);
        }
 
        /**