Skip to content
Snippets Groups Projects
Commit bef89809 authored by Helmut Hummel's avatar Helmut Hummel Committed by Georg Ringer
Browse files

[BUGFIX] Remove trailing slash from autoload information files

If an extension defines a classmap in ext_emconf.php or composer.json which points
to a file instead of a directory. The relative path calculation adds
a trailing slash to the file name, which breaks the class loading.

This trailing slash needs to be removed. As a bonus the obsolete trailing slash
is also removed from directories.

Resolves: #70234
Releases: master
Change-Id: Id54c2692e10b8ec3283a4e3447c289dc4319042c
Reviewed-on: http://review.typo3.org/43669


Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: default avatarDaniel Goerz <ervaude@gmail.com>
Tested-by: default avatarDaniel Goerz <ervaude@gmail.com>
Reviewed-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
parent 2571890c
Branches
Tags
No related merge requests found
...@@ -235,7 +235,11 @@ EOF; ...@@ -235,7 +235,11 @@ EOF;
$packageRealPath = GeneralUtility::fixWindowsFilePath(realpath($packagePath)); $packageRealPath = GeneralUtility::fixWindowsFilePath(realpath($packagePath));
$relativePackagePath = rtrim(substr($packagePath, strlen($this->installationRoot)), '/'); $relativePackagePath = rtrim(substr($packagePath, strlen($this->installationRoot)), '/');
if ($relativeToRoot) { if ($relativeToRoot) {
$relativePathToClassFile = $relativePackagePath . '/' . ltrim(substr($realPathOfClassFile, strlen($packageRealPath)), '/'); if ($realPathOfClassFile === $packageRealPath) {
$relativePathToClassFile = $relativePackagePath;
} else {
$relativePathToClassFile = $relativePackagePath . '/' . ltrim(substr($realPathOfClassFile, strlen($packageRealPath)), '/');
}
} else { } else {
$relativePathToClassFile = ltrim(substr($realPathOfClassFile, strlen($packageRealPath)), '/'); $relativePathToClassFile = ltrim(substr($realPathOfClassFile, strlen($packageRealPath)), '/');
} }
......
...@@ -71,7 +71,7 @@ class ClassLoadingInformationGeneratorTest extends UnitTestCase { ...@@ -71,7 +71,7 @@ class ClassLoadingInformationGeneratorTest extends UnitTestCase {
$this->assertArrayHasKey('psr-4File', $files); $this->assertArrayHasKey('psr-4File', $files);
$this->assertArrayHasKey('classMapFile', $files); $this->assertArrayHasKey('classMapFile', $files);
$this->assertContains('\'TYPO3\\\\CMS\\\\TestExtension\\\\\' => array($typo3InstallDir . \'/Fixtures/test_extension/Classes/\')', $files['psr-4File']); $this->assertContains('\'TYPO3\\\\CMS\\\\TestExtension\\\\\' => array($typo3InstallDir . \'/Fixtures/test_extension/Classes\')', $files['psr-4File']);
$this->assertContains('$typo3InstallDir . \'/Fixtures/test_extension/Resources/PHP/Test.php\'', $files['classMapFile']); $this->assertContains('$typo3InstallDir . \'/Fixtures/test_extension/Resources/PHP/Test.php\'', $files['classMapFile']);
} }
......
...@@ -15,6 +15,6 @@ ...@@ -15,6 +15,6 @@
"psr-4": { "psr-4": {
"TYPO3\\CMS\\TestExtension\\": "Classes/" "TYPO3\\CMS\\TestExtension\\": "Classes/"
}, },
"classmap": ["Resources/PHP/"] "classmap": ["Resources/PHP/Test.php"]
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment