Project

General

Profile

Actions

Bug #55418

closed

Class Loader requires "wrong" class files if class string matches naming convention

Added by Helmut Hummel about 10 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
Start date:
2014-01-29
Due date:
% Done:

0%

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

Description

If there is a namespaced class \Vendor\Myext\Foo\Bar and the file typo3conf/ext/myext/Classes/Foo/Bar.php are present,
the class loader also requires the file when being called with a class name like "tx_myext_foo_bar" (e.g. triggered by a class_exists() call)

This is a performance overhead but also may lead to duplicate cache entries and may lead to a fatal in certain cases,
especially on case insensitive filesystems.

Instead we should find a solution to not require the file.


Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #54275: ClassLoader creates additional cacheidentifier for same fileClosedHelmut Hummel2013-12-07

Actions
Related to TYPO3 Core - Bug #55256: Invalid class name to file path conversionClosedXavier Perseguers2014-01-22

Actions
Related to TYPO3 Core - Bug #56624: automatic class loading for lowercase extbase-style classes doesn't workClosed2014-03-06

Actions
Actions #1

Updated by Helmut Hummel about 10 years ago

  • Target version set to 6.2.0
Actions #2

Updated by Helmut Hummel about 10 years ago

The real reason why this causes trouble is case sensitivity on case sensitive file systems, while class names in PHP are case insensitive, combined with allowing old style naming conventions like Tx_Foo_Bar

Classes like:
Vendor\Foo\Bar resolve to ext/foo/Classes/Bar.php

Classes like:
Tx_Foo_Bar also resolve to ext/foo/Classes/Bar.php

At this point in time the class loader cannot know if the class defined in that file is using namespaces or not.

When we now instantiate Vendor\Foo\Bar and after that do a class_exists to Tx_Foo_Bar the class loader tries to load the class a second time, but require_once detects that this file has already been loaded.

But when we do a class_exists on tx_foo_bar we get a fatal on case insensitive filesystems as the file ext/foo/Classes/bar.php exists but require_once does not detect it is actually the same file.

Now in this very case the lines I removed would help as it uppercases every word after the separator, but it still fails with class files that have different casing in the filename or directories.

e.g. classes like Tx_Foo_BarBaz or Vendor\Foo\BarBaz still trigger a fatal when instantiating Vendor\Foo\BarBaz and after that call class_exists on tx_foo_barbaz as the fix I removed would convert the path to ext/foo/Classes/Barbaz.php which still differs from ext/foo/Classes/BarBaz.php

All the above was btw. true starting with 6.0 (which started to allow both Tx_ and Vendor\ class names to be resolved to paths

Actions #3

Updated by Markus Klein about 10 years ago

I added Xavier here, since he's the one who brought the case sensitivity problem to my attention.

Actions #4

Updated by Mathias Schreiber about 9 years ago

  • Status changed from New to Closed

will be fixed by composer classloader

Actions

Also available in: Atom PDF