Project

General

Profile

Actions

Bug #62212

closed

ClassLoader: Check for Interfaces

Added by Dominik J. over 9 years ago. Updated over 5 years ago.

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

100%

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

Description

Today I was faced with an issue with YAG (see here: https://forge.typo3.org/issues/62207). I was able to resolve the issue by changing one line in the Typo3 CMS Core of Version 6.2.5 (which I believe is the most recent one).

The problem is that PHP's require_once doesn't work with relative paths. The SystemEnvironmentBuilder includes the interface SingletonInterface like this:

require_once __DIR__ . '/../SingletonInterface.php';

The ClassLoader (typo3/sysext/core/Classes/Core/ClassLoader.php) uses an absolute path instead. To PHP it seems like two separate files.

In line 182 of the ClassLoader.php it is first checked whether the class is already available, else it will be required (with require_once):

$loadingSuccessful = class_exists($classLoadingInformation[1], FALSE) || (bool)require_once $classLoadingInformation[0];

Unfortunately, SingletonInterface is NOT a class but an interface, and class_exists doesn't check for interfaces. So I added the check manually:

$loadingSuccessful = class_exists($classLoadingInformation[1], FALSE) || interface_exists($classLoadingInformation[1], FALSE) || (bool)require_once $classLoadingInformation[0];

With this change the error of a redeclared "class" is resolved.

Maybe some Core Developer would consider applying my patch into the next update, as it's only a small change that shouldn't break with other code.

Actions #1

Updated by Markus Klein over 9 years ago

Can you supply a patch for Gerrit please?

Actions #2

Updated by Alexander Opitz over 9 years ago

Beside the issue in the core.

The problem is that PHP's require_once doesn't work with relative paths.
The ClassLoader (typo3/sysext/core/Classes/Core/ClassLoader.php) uses an absolute path instead. To PHP it seems like two separate files.

That isn't 100% true, this sounds more like an older version of APC is active. Can you provide some more data about the server environment and used opcode cache?

Actions #3

Updated by Dominik J. over 9 years ago

@Alexander Opitz: The server environment is MAMP (Free) on Mac OS X with PHP 5.5.14 and no PHP Caching activated.

@Markus Klein: I'd rather wait for you guys to process that new information before I do that. Also, I don't know how to do that. I'm kinda new to Typo3.

What also surprises me is that on another installation (which I didn't set up, but I have access to a copy of it) with the same Typo3 Version and same Extension Version it works just fine. I don't know yet it they did something similar as me or if it's a different server environment (they are using Suse Linux).

Actions #4

Updated by Markus Klein over 9 years ago

If you're familiar with GIT already, it shouldn't be too hard for you:
http://wiki.typo3.org/CWT

I will push a quick fix, though.

Actions #5

Updated by Gerrit Code Review over 9 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33309

Actions #6

Updated by Alexander Opitz over 9 years ago

@Dominic Then maybe not all symlink issues are tangled in PHP. Maybe you can create a small testcase and open an issue on PHPs issue tracker.

So different server environment may be the difference that it works there.

Actions #7

Updated by Dominik J. over 9 years ago

@Alexander Opitz: You are right, I tested the require_once method by including a file "ro_test.php", "../localhost/ro_test.php" and "ro_test2.php" (which is a symlink to rotest.php), and it recognized the file each time and hasn't included it.

But I don't think that's the cause. I installed a new clean Typo3, but this time without using symlinks - and it still doesn't work.

@Markus Klein: Thanks alot!

Actions #8

Updated by Markus Klein over 9 years ago

Please see my comment to the patch!

This has to do with the legacy interface stuff.

Actions #9

Updated by Gerrit Code Review over 9 years ago

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/33489

Actions #10

Updated by Markus Klein over 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #11

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF