[BUGFIX] Class loader tries to load classes it cannot load 40/22440/4
authorAndreas Wolf <andreas.wolf@typo3.org>
Sat, 20 Jul 2013 10:19:13 +0000 (12:19 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 27 Jul 2013 20:35:50 +0000 (22:35 +0200)
If a class file from a third-party package is loaded which does not
follow the Vendor\Product\Classname convention (e.g. Product\Classname),
the class loader still tries to access the third component of the class
name, leading to a warning (and thus an exception, depending on your
configuration).

To fix this problem, the class loader now checks in advance if it can
possibly load this class (or rather if the classname conforms to the
specification for the CMS universe).

Change-Id: I1cd3964b9486ea591fb373533fd6cef4e9ce3989
Resolves: #50217
Releases: 6.2, 6.1, 6.0
Reviewed-on: https://review.typo3.org/22440
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/core/Classes/Core/ClassLoader.php

index 28cde4d..b840947 100644 (file)
@@ -344,6 +344,13 @@ class ClassLoader {
                        $delimiter = '\\';
                }
                $classNameParts = explode($delimiter, $tempClassName, 4);
+
+               // we only handle classes that follow the convention Vendor\Product\Classname or is longer
+               // so we won't deal with class names that only have one or two parts
+               if (count($classNameParts) <= 2) {
+                       return;
+               }
+
                if (isset($classNameParts[0]) && $classNameParts[0] === 'TYPO3' && (isset($classNameParts[1]) && $classNameParts[1] === 'CMS')) {
                        $extensionKey = GeneralUtility::camelCaseToLowerCaseUnderscored($classNameParts[2]);
                        $classNameWithoutVendorAndProduct = $classNameParts[3];