[BUGFIX] No exception if uninstalled extension has an invalid key 28/24728/7
authorErnesto Baschny <ernst@cron-it.de>
Mon, 14 Oct 2013 10:02:30 +0000 (12:02 +0200)
committerThomas Maroschik <tmaroschik@dfau.de>
Tue, 15 Oct 2013 11:32:40 +0000 (13:32 +0200)
The loop that scans for packages should skip those whose key is not
valid, in order to avoid an exception later down the road.

Resolves: #52779
Releases: 6.2
Change-Id: Ic9903b7d69fd6c9b9581e85d2f6ea1222ebb8885
Reviewed-on: https://review.typo3.org/24728
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Thomas Maroschik
Tested-by: Thomas Maroschik
typo3/sysext/core/Classes/Package/Package.php
typo3/sysext/core/Classes/Package/PackageManager.php

index 29b1b1a..138916b 100644 (file)
@@ -19,7 +19,7 @@ namespace TYPO3\CMS\Core\Package;
  */
 class Package extends \TYPO3\Flow\Package\Package implements PackageInterface {
 
-       const PATTERN_MATCH_EXTENSIONKEY = '/^[0-9a-z_]+$/i';
+       const PATTERN_MATCH_EXTENSIONKEY = '/^[0-9a-z_-]+$/i';
 
        /**
         * @var array
index a79ef15..9f11edf 100644 (file)
@@ -59,7 +59,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
        protected $packageAliasMap = array();
 
        /**
-        *
+        * Constructor
         */
        public function __construct() {
                $this->packagesBasePaths = array(
@@ -170,7 +170,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
        protected function saveToPackageCache() {
                $cacheEntryIdentifier = $this->getCacheEntryIdentifier();
                if ($cacheEntryIdentifier !== NULL && !$this->coreCache->has($cacheEntryIdentifier)) {
-                       $cacheEntryPath = rtrim($this->coreCache->getBackend()->getCacheDirectory(), '/\\');
+                       $cacheEntryPath = rtrim(\TYPO3\CMS\Core\Utility\GeneralUtility::fixWindowsFilePath($this->coreCache->getBackend()->getCacheDirectory()), '/');
                        // Package objects get their own cache entry, so PHP does not have to parse the serialized string
                        $packageObjectsCacheEntryIdentifier = uniqid('PackageObjects_');
                        // Build cache file
@@ -275,10 +275,11 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                                $this->composerNameToPackageKeyMap[strtolower($composerManifest->name)] = $packageKey;
                                $this->packageStatesConfiguration['packages'][$packageKey]['manifestPath'] = substr($composerManifestPath, strlen($packagePath)) ? : '';
                                $this->packageStatesConfiguration['packages'][$packageKey]['composerName'] = $composerManifest->name;
-                       }
-                       catch (\TYPO3\Flow\Package\Exception\MissingPackageManifestException $exception) {
+                       } catch (\TYPO3\Flow\Package\Exception\MissingPackageManifestException $exception) {
                                $relativePackagePath = substr($packagePath, strlen($packagesBasePath));
                                $packageKey = substr($relativePackagePath, strpos($relativePackagePath, '/') + 1, -1);
+                       } catch (\TYPO3\Flow\Package\Exception\InvalidPackageKeyException $exception) {
+                               continue;
                        }
                        if (!isset($this->packageStatesConfiguration['packages'][$packageKey]['state'])) {
                                $this->packageStatesConfiguration['packages'][$packageKey]['state'] = 'inactive';
@@ -290,7 +291,8 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                        $this->packageStatesConfiguration['packages'][$packageKey]['classesPath'] = \TYPO3\Flow\Package\Package::DIRECTORY_CLASSES;
                }
 
-               $this->registerPackagesFromConfiguration(!empty($this->packages));
+               $registerOnlyNewPackages = !empty($this->packages);
+               $this->registerPackagesFromConfiguration($registerOnlyNewPackages);
                if ($this->packageStatesConfiguration != $previousPackageStatesConfiguration) {
                        $this->sortAndsavePackageStates();
                }
@@ -359,6 +361,9 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
                        } catch (\TYPO3\Flow\Package\Exception\InvalidPackagePathException $exception) {
                                $this->unregisterPackageByPackageKey($packageKey);
                                continue;
+                       } catch (\TYPO3\Flow\Package\Exception\InvalidPackageKeyException $exception) {
+                               $this->unregisterPackageByPackageKey($packageKey);
+                               continue;
                        }
 
                        $this->registerPackage($package, FALSE);