Project

General

Profile

Actions

Bug #65803

closed

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

Added by Frank Rakow over 9 years ago. Updated about 9 years ago.

Status:
Rejected
Priority:
Must have
Assignee:
-
Category:
composer
Target version:
-
Start date:
2015-03-18
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.5
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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';

Files

changes.diff (278 Bytes) changes.diff Frank Rakow, 2015-03-18 13:28
Actions

Also available in: Atom PDF