Issue Bug Rejected

#65803ClassLoader Bug with psr-0 autoload configuration - results in double slashes in filepath!

Frank Rakow 03/18/15, 13:28 updated 10/07/15, 16:10

Description

In an extension configure the composer.json with ‘psr-0’ autoload

  ...
  "autoload": {
    "psr-0": {
      "Vendor\\NameSpace\\": "Classes/"
    }
  }
  ...

Bug is located in class TYPO3\CMS\Core\Core\ClassLoader in method buildClassLoadingInformationForClassFromRegisteredPackages

  ..
  if ($packageData['substituteNamespaceInPath']) {
    // If it's a TYPO3 package, classes don't comply to PSR-0.
    // The namespace part is substituted.
    $classPathAndFilename = '/' . str_replace('\\', '/', ltrim(substr($className, $packageData['namespaceLength']), '\\')) . '.php';
  } else {
  ...
  ...
  } else {
    $classPathAndFilename = $packageData['classesPath'] . $classPathAndFilename;
  }
  ...

$classPathAndFilename is created with a beginning slash – that’s wrong,
because the classesPath in $packageData[‘classesPath’] is always ending with a slash – it’s filtered with Files::getNormalizedPath!

Bugfix

    $classPathAndFilename = str_replace('\\', '/', ltrim(substr($className, $packageData['namespaceLength']), '\\')) . '.php';

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.