[BUGFIX] Resolve class name from aliases managed by composer 15/37915/3
authorHelmut Hummel <helmut.hummel@typo3.org>
Fri, 13 Mar 2015 15:27:02 +0000 (16:27 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Wed, 18 Mar 2015 10:13:47 +0000 (11:13 +0100)
The old class loader has API to return the original class name
when given an alias. This API was not respected when implementing
composer class loading with #64361 with the result that it was
broken for all classes and aliases managed by the composer class loader.

To address this issue, the composer class loader is now injected into
the old class alias map, so that it can resolve class names from aliases
managed by it.

Related: #64361
Resolves: #65667
Releases: 6.2, master
Change-Id: If0b5098d72147fe7d76e97ee61c81d87cad72b4b
Reviewed-on: http://review.typo3.org/37915
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/contrib/vendor/composer/autoload_classmap.php
typo3/contrib/vendor/helhum/class-alias-loader/Classes/Composer/ClassAliasLoader.php
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Core/ClassAliasMap.php

index 090ccf5..304f53a 100644 (file)
@@ -12,11 +12,14 @@ return array(
     'Psr\\Log\\LoggerInterface' => $baseDir . '/typo3/contrib/Psr/Log/LoggerInterface.php',
     'RemoveXSS' => $baseDir . '/typo3/sysext/core/Resources/PHP/RemoveXSS.php',
     'TYPO3\\CMS\\Backend\\AjaxLoginHandler' => $baseDir . '/typo3/sysext/backend/Classes/AjaxLoginHandler.php',
+    'TYPO3\\CMS\\Backend\\AjaxRequestHandler' => $baseDir . '/typo3/sysext/backend/Classes/AjaxRequestHandler.php',
+    'TYPO3\\CMS\\Backend\\BackendModuleRequestHandler' => $baseDir . '/typo3/sysext/backend/Classes/BackendModuleRequestHandler.php',
     'TYPO3\\CMS\\Backend\\Backend\\ToolbarItems\\ClearCacheToolbarItem' => $baseDir . '/typo3/sysext/backend/Classes/Backend/ToolbarItems/ClearCacheToolbarItem.php',
     'TYPO3\\CMS\\Backend\\Backend\\ToolbarItems\\HelpToolbarItem' => $baseDir . '/typo3/sysext/backend/Classes/Backend/ToolbarItems/HelpToolbarItem.php',
     'TYPO3\\CMS\\Backend\\Backend\\ToolbarItems\\LiveSearchToolbarItem' => $baseDir . '/typo3/sysext/backend/Classes/Backend/ToolbarItems/LiveSearchToolbarItem.php',
     'TYPO3\\CMS\\Backend\\Backend\\ToolbarItems\\ShortcutToolbarItem' => $baseDir . '/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php',
     'TYPO3\\CMS\\Backend\\Backend\\ToolbarItems\\UserToolbarItem' => $baseDir . '/typo3/sysext/backend/Classes/Backend/ToolbarItems/UserToolbarItem.php',
+    'TYPO3\\CMS\\Backend\\CliRequestHandler' => $baseDir . '/typo3/sysext/backend/Classes/CliRequestHandler.php',
     'TYPO3\\CMS\\Backend\\ClickMenu\\ClickMenu' => $baseDir . '/typo3/sysext/backend/Classes/ClickMenu/ClickMenu.php',
     'TYPO3\\CMS\\Backend\\Clipboard\\Clipboard' => $baseDir . '/typo3/sysext/backend/Classes/Clipboard/Clipboard.php',
     'TYPO3\\CMS\\Backend\\Configuration\\TranslationConfigurationProvider' => $baseDir . '/typo3/sysext/backend/Classes/Configuration/TranslationConfigurationProvider.php',
@@ -100,6 +103,7 @@ return array(
     'TYPO3\\CMS\\Backend\\RecordList\\AbstractRecordList' => $baseDir . '/typo3/sysext/backend/Classes/RecordList/AbstractRecordList.php',
     'TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList' => $baseDir . '/typo3/sysext/backend/Classes/RecordList/ElementBrowserRecordList.php',
     'TYPO3\\CMS\\Backend\\RecordList\\RecordListGetTableHookInterface' => $baseDir . '/typo3/sysext/backend/Classes/RecordList/RecordListGetTableHookInterface.php',
+    'TYPO3\\CMS\\Backend\\RequestHandler' => $baseDir . '/typo3/sysext/backend/Classes/RequestHandler.php',
     'TYPO3\\CMS\\Backend\\Rte\\AbstractRte' => $baseDir . '/typo3/sysext/backend/Classes/Rte/AbstractRte.php',
     'TYPO3\\CMS\\Backend\\Search\\LiveSearch\\ExtDirect\\LiveSearchDataProvider' => $baseDir . '/typo3/sysext/backend/Classes/Search/LiveSearch/ExtDirect/LiveSearchDataProvider.php',
     'TYPO3\\CMS\\Backend\\Search\\LiveSearch\\LiveSearch' => $baseDir . '/typo3/sysext/backend/Classes/Search/LiveSearch/LiveSearch.php',
@@ -237,6 +241,7 @@ return array(
     'TYPO3\\CMS\\Core\\Core\\ClassAliasMap' => $baseDir . '/typo3/sysext/core/Classes/Core/ClassAliasMap.php',
     'TYPO3\\CMS\\Core\\Core\\ClassLoader' => $baseDir . '/typo3/sysext/core/Classes/Core/ClassLoader.php',
     'TYPO3\\CMS\\Core\\Core\\CliBootstrap' => $baseDir . '/typo3/sysext/core/Classes/Core/CliBootstrap.php',
+    'TYPO3\\CMS\\Core\\Core\\RequestHandlerInterface' => $baseDir . '/typo3/sysext/core/Classes/Core/RequestHandlerInterface.php',
     'TYPO3\\CMS\\Core\\Core\\SystemEnvironmentBuilder' => $baseDir . '/typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php',
     'TYPO3\\CMS\\Core\\DataHandling\\DataHandler' => $baseDir . '/typo3/sysext/core/Classes/DataHandling/DataHandler.php',
     'TYPO3\\CMS\\Core\\DataHandling\\DataHandlerCheckModifyAccessListHookInterface' => $baseDir . '/typo3/sysext/core/Classes/DataHandling/DataHandlerCheckModifyAccessListHookInterface.php',
@@ -966,6 +971,7 @@ return array(
     'TYPO3\\CMS\\Fluid\\ViewHelpers\\Form\\ValidationResultsViewHelper' => $baseDir . '/typo3/sysext/fluid/Classes/ViewHelpers/Form/ValidationResultsViewHelper.php',
     'TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\AbstractEncodingViewHelper' => $baseDir . '/typo3/sysext/fluid/Classes/ViewHelpers/Format/AbstractEncodingViewHelper.php',
     'TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\BytesViewHelper' => $baseDir . '/typo3/sysext/fluid/Classes/ViewHelpers/Format/BytesViewHelper.php',
+    'TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\CaseViewHelper' => $baseDir . '/typo3/sysext/fluid/Classes/ViewHelpers/Format/CaseViewHelper.php',
     'TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\CdataViewHelper' => $baseDir . '/typo3/sysext/fluid/Classes/ViewHelpers/Format/CdataViewHelper.php',
     'TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\CropViewHelper' => $baseDir . '/typo3/sysext/fluid/Classes/ViewHelpers/Format/CropViewHelper.php',
     'TYPO3\\CMS\\Fluid\\ViewHelpers\\Format\\CurrencyViewHelper' => $baseDir . '/typo3/sysext/fluid/Classes/ViewHelpers/Format/CurrencyViewHelper.php',
@@ -1067,8 +1073,8 @@ return array(
     'TYPO3\\CMS\\Frontend\\Controller\\ShowImageController' => $baseDir . '/typo3/sysext/frontend/Classes/Controller/ShowImageController.php',
     'TYPO3\\CMS\\Frontend\\Controller\\TranslationStatusController' => $baseDir . '/typo3/sysext/frontend/Classes/Controller/TranslationStatusController.php',
     'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController' => $baseDir . '/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php',
+    'TYPO3\\CMS\\Frontend\\EidRequestHandler' => $baseDir . '/typo3/sysext/frontend/Classes/EidRequestHandler.php',
     'TYPO3\\CMS\\Frontend\\Exception' => $baseDir . '/typo3/sysext/frontend/Classes/Exception.php',
-    'TYPO3\\CMS\\Frontend\\FrontendRequestHandler' => $baseDir . '/typo3/sysext/frontend/Classes/FrontendRequestHandler.php',
     'TYPO3\\CMS\\Frontend\\Hooks\\FrontendHooks' => $baseDir . '/typo3/sysext/frontend/Classes/Hooks/FrontendHooks.php',
     'TYPO3\\CMS\\Frontend\\Hooks\\MediaItemHooks' => $baseDir . '/typo3/sysext/frontend/Classes/Hooks/MediaItemHooks.php',
     'TYPO3\\CMS\\Frontend\\Hooks\\TableColumnHooks' => $baseDir . '/typo3/sysext/frontend/Classes/Hooks/TableColumnHooks.php',
@@ -1086,6 +1092,7 @@ return array(
     'TYPO3\\CMS\\Frontend\\Page\\PageRepositoryGetRecordOverlayHookInterface' => $baseDir . '/typo3/sysext/frontend/Classes/Page/PageRepositoryGetRecordOverlayHookInterface.php',
     'TYPO3\\CMS\\Frontend\\Page\\PageRepositoryInitHookInterface' => $baseDir . '/typo3/sysext/frontend/Classes/Page/PageRepositoryInitHookInterface.php',
     'TYPO3\\CMS\\Frontend\\Plugin\\AbstractPlugin' => $baseDir . '/typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php',
+    'TYPO3\\CMS\\Frontend\\RequestHandler' => $baseDir . '/typo3/sysext/frontend/Classes/RequestHandler.php',
     'TYPO3\\CMS\\Frontend\\Utility\\CompressionUtility' => $baseDir . '/typo3/sysext/frontend/Classes/Utility/CompressionUtility.php',
     'TYPO3\\CMS\\Frontend\\Utility\\EidUtility' => $baseDir . '/typo3/sysext/frontend/Classes/Utility/EidUtility.php',
     'TYPO3\\CMS\\Frontend\\View\\AdminPanelView' => $baseDir . '/typo3/sysext/frontend/Classes/View/AdminPanelView.php',
@@ -1180,6 +1187,7 @@ return array(
     'TYPO3\\CMS\\Install\\Report\\EnvironmentStatusReport' => $baseDir . '/typo3/sysext/install/Classes/Report/EnvironmentStatusReport.php',
     'TYPO3\\CMS\\Install\\Report\\InstallStatusReport' => $baseDir . '/typo3/sysext/install/Classes/Report/InstallStatusReport.php',
     'TYPO3\\CMS\\Install\\Report\\SecurityStatusReport' => $baseDir . '/typo3/sysext/install/Classes/Report/SecurityStatusReport.php',
+    'TYPO3\\CMS\\Install\\RequestHandler' => $baseDir . '/typo3/sysext/install/Classes/RequestHandler.php',
     'TYPO3\\CMS\\Install\\Service\\CachingFrameworkDatabaseSchemaService' => $baseDir . '/typo3/sysext/install/Classes/Service/CachingFrameworkDatabaseSchemaService.php',
     'TYPO3\\CMS\\Install\\Service\\ClearCacheService' => $baseDir . '/typo3/sysext/install/Classes/Service/ClearCacheService.php',
     'TYPO3\\CMS\\Install\\Service\\ContextService' => $baseDir . '/typo3/sysext/install/Classes/Service/ContextService.php',
index f394d4b..358c060 100644 (file)
@@ -70,6 +70,17 @@ class ClassAliasLoader {
        }
 
        /**
+        * Get final class name of alias
+        *
+        * @param string $alias
+        * @return string
+        */
+       public function getClassNameForAlias($alias) {
+               $lookUpClassName = strtolower($alias);
+               return isset($this->aliasMap['aliasToClassNameMapping'][$lookUpClassName]) ? $this->aliasMap['aliasToClassNameMapping'][$lookUpClassName] : $alias;
+       }
+
+       /**
         * Main class loading method registered with spl_autoload_register()
         *
         * @param string $className
index 18f80f8..daf3b09 100644 (file)
@@ -417,6 +417,7 @@ class Bootstrap {
                $this->setEarlyInstance(\TYPO3\CMS\Core\Core\ClassLoader::class, $classLoader);
                $classAliasMap = new ClassAliasMap();
                $classAliasMap->injectClassLoader($classLoader);
+               $classAliasMap->injectComposerClassLoader($this->getEarlyInstance(\Composer\Autoload\ClassLoader::class));
                $this->setEarlyInstance(\TYPO3\CMS\Core\Core\ClassAliasMap::class, $classAliasMap);
                $classLoader->injectClassAliasMap($classAliasMap);
                spl_autoload_register(array($classLoader, 'loadClass'), TRUE, FALSE);
index 58c9c39..ef07da3 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Core;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Helhum\ClassAliasLoader\Composer\ClassAliasLoader;
+
 /**
  * This class is responsible for setting and containing class aliases
  */
@@ -49,6 +51,11 @@ class ClassAliasMap implements \TYPO3\CMS\Core\SingletonInterface {
        protected $classLoader;
 
        /**
+        * @var ClassAliasLoader
+        */
+       protected $composerClassLoader;
+
+       /**
         * @var \TYPO3\Flow\Package\Package[]
         */
        protected $packages = array();
@@ -75,6 +82,13 @@ class ClassAliasMap implements \TYPO3\CMS\Core\SingletonInterface {
        }
 
        /**
+        * @param ClassAliasLoader $composerClassLoader
+        */
+       public function injectComposerClassLoader(ClassAliasLoader $composerClassLoader) {
+               $this->composerClassLoader = $composerClassLoader;
+       }
+
+       /**
         * Set packages
         *
         * @param array $packages
@@ -214,11 +228,12 @@ class ClassAliasMap implements \TYPO3\CMS\Core\SingletonInterface {
         * Get final class name of alias
         *
         * @param string $alias
-        * @return mixed
+        * @return string
         */
        public function getClassNameForAlias($alias) {
                $lookUpClassName = strtolower($alias);
-               return isset($this->aliasToClassNameMapping[$lookUpClassName]) ? $this->aliasToClassNameMapping[$lookUpClassName] : $alias;
+               $className = $this->composerClassLoader->getClassNameForAlias($alias);
+               return isset($this->aliasToClassNameMapping[$lookUpClassName]) ? $this->aliasToClassNameMapping[$lookUpClassName] : $className;
        }