[BUGFIX] Fix fatal errors upon package installation 44/27544/2
authorThomas Maroschik <tmaroschik@dfau.de>
Tue, 11 Feb 2014 14:26:27 +0000 (15:26 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Tue, 11 Feb 2014 17:57:48 +0000 (18:57 +0100)
During the installation of packages via the extension
manager a fatal error can occur when the ext_localconf
and ext_tables are loaded and use classes from their own
package. This happens because the package is activated
but the class loader is not aware yet of the new package.

This patch adds the extension temporarily to the runtime
activated packages in the class loader.

Fixes: #53795
Releases: 6.2
Change-Id: I195b86284b9a288f4d7c102168ec18ed8683cb07
Reviewed-on: https://review.typo3.org/27544
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/core/Classes/Core/ClassLoader.php
typo3/sysext/core/Classes/Package/PackageManager.php

index 88d15f7..fb03dc2 100644 (file)
@@ -399,11 +399,14 @@ class ClassLoader {
         * @param \TYPO3\Flow\Package\PackageInterface $package
         * @return ClassLoader
         */
-       public function addRuntimeActivatedPackage(\TYPO3\Flow\Package\PackageInterface $package) {
-               $this->packages[] = $package;
-               $this->buildPackageNamespaceAndClassesPath($package);
-               $this->sortPackageNamespaces();
-               $this->loadClassFilesFromAutoloadRegistryIntoRuntimeClassInformationCache(array($package));
+       public function addActivePackage(\TYPO3\Flow\Package\PackageInterface $package) {
+               $packageKey = $package->getPackageKey();
+               if (!isset($this->packages[$packageKey])) {
+                       $this->packages[$packageKey] = $package;
+                       $this->buildPackageNamespaceAndClassesPath($package);
+                       $this->sortPackageNamespaces();
+                       $this->loadClassFilesFromAutoloadRegistryIntoRuntimeClassInformationCache(array($package));
+               }
                return $this;
        }
 
index 00ca8bd..b46867c 100644 (file)
@@ -531,6 +531,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
        public function activatePackage($packageKey) {
                $package = $this->getPackage($packageKey);
                parent::activatePackage($package->getPackageKey());
+               $this->classLoader->addActivePackage($package);
        }
 
        /**
@@ -542,7 +543,7 @@ class PackageManager extends \TYPO3\Flow\Package\PackageManager implements \TYPO
        public function activatePackageDuringRuntime($packageKey) {
                $package = $this->getPackage($packageKey);
                $this->runtimeActivatedPackages[$package->getPackageKey()] = $package;
-               $this->classLoader->addRuntimeActivatedPackage($package);
+               $this->classLoader->addActivePackage($package);
        }