Project

General

Profile

Actions

Bug #55904

closed

Class loader loads aliased classes twice

Added by Christian Weiske about 10 years ago. Updated over 6 years ago.

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

100%

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

Description

The class loader tries to load files of aliased classes twice if certain strange circumstances are met.

/srv/www/ and /var/www/ are mounts (not symlinks) of the same harddisk. TYPO3 is used via HTTP (Apache), document root /var/www/typo3/. TYPO3 is also used on the CLI via document root /srv/www/typo3/.

The class loading process is as follows:

  1. Apache: TYPO3 gets used, writes caches.
  2. CLI: TYPO3 core gets loaded, /srv/.../GeneralUtility.php is loaded.
  3. Extension configuration gets loaded. Their paths are loaded from /var/... now because of the caches
  4. An extension's ext_localconf.php uses t3lib_div, which is handed to the class loader.
  5. Class loader sees it's an alias to GeneralUtility and tries to load that first. It calculates the path of GeneralUtility to be /var/.../GeneralUtility.php and does a require_once call on it.
  6. PHP loads this file because it does not know that /srv/.../GeneralUtility.php is the same file as /var/.../GeneralUtility.php
  7. Fatal error: Cannot redeclare class TYPO3\CMS\Core\Utility\GeneralUtility

While this is an obscure configuration, the fix is easy: Simply check if the class already exists before requiring the file.

I'll contribute a patch.

This error did not happen with 6.2beta4 and started with 6.2beta5, probably because of 890cdbcf4013b2c870e315cce13400f44d3304b6 (bug #55559).

Actions #1

Updated by Gerrit Code Review about 10 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 https://review.typo3.org/27570

Actions #2

Updated by Christian Weiske about 10 years ago

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

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF