[BUGFIX] Cast autoload and classAliasMap to Array 56/23456/2
authorMichel Georgy <michel@4eyes.ch>
Thu, 29 Aug 2013 07:34:21 +0000 (09:34 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 29 Aug 2013 12:28:56 +0000 (14:28 +0200)
If you create an empty ext_autoload.php or an empty classAliasMap.php
file or fail to return an array, NULL is merged with the existing
array which results in NULL for the array $classRegistry or
$aliasToClassNameMapping
This patch casts the required Array(which is possibly NULL) to an
Array to prevent array_merge with NULL values.

Fixes: #51474
Releases: 6.2, 6.1, 6.0
Change-Id: I1887da3a942b17e441338a95cb7da49a17535907
Reviewed-on: https://review.typo3.org/23441
Reviewed-by: Kai Ole Hartwig
Tested-by: Kai Ole Hartwig
Reviewed-by: Christoph Dörfel
Tested-by: Christoph Dörfel
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
(cherry picked from commit 8cc7f45526bc8828dada995bc91804038d326eea)
Reviewed-on: https://review.typo3.org/23456

typo3/sysext/core/Classes/Core/ClassLoader.php

index b840947..02e5432 100644 (file)
@@ -230,7 +230,7 @@ class ClassLoader {
                        try {
                                $extensionClassAliasMap = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey, 'Migrations/Code/ClassAliasMap.php');
                                if (@file_exists($extensionClassAliasMap)) {
-                                       $aliasToClassNameMapping = array_merge($aliasToClassNameMapping, require $extensionClassAliasMap);
+                                       $aliasToClassNameMapping = array_merge($aliasToClassNameMapping, (array) require $extensionClassAliasMap);
                                }
                        } catch (\BadFunctionCallException $e) {
                        }
@@ -316,7 +316,7 @@ class ClassLoader {
                        try {
                                $extensionAutoloadFile = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey, 'ext_autoload.php');
                                if (@file_exists($extensionAutoloadFile)) {
-                                       $classRegistry = array_merge($classRegistry, require $extensionAutoloadFile);
+                                       $classRegistry = array_merge($classRegistry, (array) require $extensionAutoloadFile);
                                }
                        } catch (\BadFunctionCallException $e) {