[BUGFIX] Ignore missing folders from psr-4 definitions 24/54224/2
authorHelmut Hummel <typo3@helhum.io>
Fri, 22 Sep 2017 12:16:49 +0000 (14:16 +0200)
committerNicole Cordes <typo3@cordes.co>
Wed, 27 Sep 2017 14:10:48 +0000 (16:10 +0200)
Even when generating an optimized class map for psr-4
classes, Composer gracefully ignores folders defined
in psr-4 autoload section, if they do not exist.

TYPO3 however fails with an exception.

Also change the logic to always generate a class map
for improved class loading performance. This happened
anyway already when calling the autoload generation twice.

Resolves: #82542
Releases: master, 8.7
Change-Id: I4c3ab8ff7affeba25313d93e40e35f78bb78492d
Reviewed-on: https://review.typo3.org/54224
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/core/Classes/Core/ClassLoadingInformationGenerator.php

index 0a429b1..40aef39 100644 (file)
@@ -80,18 +80,17 @@ class ClassLoadingInformationGenerator
         } else {
             $autoloadPsr4 = $this->getAutoloadSectionFromManifest($manifest, 'psr-4');
             if (!empty($autoloadPsr4)) {
-                $classLoaderPrefixesPsr4 = $this->classLoader->getPrefixesPsr4();
                 foreach ($autoloadPsr4 as $namespacePrefix => $paths) {
                     foreach ((array)$paths as $path) {
                         $namespacePath = $packagePath . $path;
+                        $namespaceRealPath = realpath($namespacePath);
                         if ($useRelativePaths) {
-                            $psr4[$namespacePrefix][] = $this->makePathRelative($namespacePath, realpath($namespacePath));
+                            $psr4[$namespacePrefix][] = $this->makePathRelative($namespacePath, $namespaceRealPath);
                         } else {
                             $psr4[$namespacePrefix][] = $namespacePath;
                         }
-                        if (!empty($classLoaderPrefixesPsr4[$namespacePrefix])) {
-                            // The namespace prefix has been registered already, which means there also might be
-                            // a class map which we need to override
+                        if (!empty($namespaceRealPath) && is_dir($namespaceRealPath)) {
+                            // Add all prs-4 classes to the class map for improved class loading performance
                             $classMap = array_merge($classMap, $this->createClassMap($namespacePath, $useRelativePaths, false, $namespacePrefix));
                         }
                     }