[BUGFIX] Invalid class name to file path conversion 99/26999/3
authorXavier Perseguers <xavier@typo3.org>
Wed, 22 Jan 2014 17:20:54 +0000 (18:20 +0100)
committerXavier Perseguers <xavier@typo3.org>
Sat, 25 Jan 2014 15:46:01 +0000 (16:46 +0100)
The conversion from a class name such as
tx_extensionname_domain_model_somename to its corresponding PHP file
does not take Extbase naming conventions for the file name. This yields
an wrongly-cased file name which will be validated anyway on case
insensitive file systems.

This wrong conversion may lead to a PHP fatal error
Cannot redeclare class VendorName\Extension\Domain\Model\Somename

Fixes: #55256
Releases: 6.2
Change-Id: Ibe512945ac01f53844f790bea9f0d0cf58518c54
Reviewed-on: https://review.typo3.org/26999
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Marcin Sągol
Reviewed-by: Stefan Neufeind
Tested-by: Marcin Sągol
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/core/Classes/Core/ClassLoader.php

index 0c2d841..7ac6c6d 100644 (file)
@@ -333,7 +333,9 @@ class ClassLoader {
                        } else {
                                $classesPath = $this->packageClassesPaths[$extensionKey];
                        }
-                       $classFilePath = $classesPath . strtr($classNameWithoutVendorAndProduct, $delimiter, '/') . '.php';
+                       // Naming convention is to capitalize each part of the path
+                       $classNameWithoutVendorAndProduct = ucwords(strtr($classNameWithoutVendorAndProduct, $delimiter, LF));
+                       $classFilePath = $classesPath . strtr($classNameWithoutVendorAndProduct, LF, '/') . '.php';
                        if (@file_exists($classFilePath)) {
                                return array($classFilePath, $className);
                        }