Project

General

Profile

Actions

Bug #67221

closed

DataHandler class generates a name collision

Added by Stefan Gruber over 9 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
-
Target version:
-
Start date:
2015-06-01
Due date:
% Done:

0%

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

Description

Under some circumstances class loading fails with the following error:

PHP Fatal error:  Cannot use TYPO3\CMS\Backend\Utility\BackendUtility as BackendUtility because the name is already in use in /var/www/t3_plansee/htdocs/typo3conf/ext/news/Classes/Hooks/DataHandler.php on line 18

This is because of line 18 in the DataHandler.php: use TYPO3\CMS\Backend\Utility\BackendUtility

After removing line 18 and replacing the BackendUtility class with the full qualified name it works.

One way to produce this error is to call l10nmgr import cli with php-cgi:
"php-cgi" -q -e -d register_argc_argv=1 "cli_dispatch.phpsh" l10nmgr_import --task importFile --preview 1 --file trans.xml --server "http://URL/"

The error occures in the TYPO3\CMS\Core\Core\ClassLoader->loadClass() method in line 197 (typo3 6.2.12:

|| (bool)require_once $classLoadingInformation[0];):
        if (!empty($classLoadingInformation)) {
               // The call to class_exists/interface_exists fixes a rare case when early instances need to be aliased
               // but PHP fails to recognize the real path of the class. See #55904
               $loadingSuccessful = class_exists($classLoadingInformation[1], FALSE)
                      || interface_exists($classLoadingInformation[1], FALSE)
                      || (bool)require_once $classLoadingInformation[0];
        }

I think it has something to do with the extensions BackendUtility class.


Files

DataHandler.php (6.33 KB) DataHandler.php Stefan Gruber, 2015-06-01 12:19
Example.zip (3.6 KB) Example.zip Stefan Gruber, 2015-06-01 16:16
Actions #1

Updated by Markus Klein over 9 years ago

  • Description updated (diff)
Actions #2

Updated by Markus Klein over 9 years ago

  • Status changed from New to Needs Feedback

I don't know what l10nmgr_import does, but this seems very strange. Why would a use statement in a separate file of "news" interfere with the one defined in Core?

Actions #3

Updated by Stefan Gruber over 9 years ago

Here is a description of the l10nmgr import cli:
http://docs.typo3.org/typo3cms/extensions/l10nmgr/ExtLocalizationManager/UsersManual/CommandLineInterface%28cli%29/Index.html#cli-for-import
It is used to import translations from e.g. XML files into Typo3.

As far as I understand this error means, that there is a class with the same alias already in use. In this case the namespace GeorgRinger\News\Hooks contains a class BackendUtility. If you now register an alias in the same namespace for a class with the same name from another namespace you will recieve this error.

I think this is a good explanation: http://stackoverflow.com/questions/11988892/php-unusual-fatal-error-with-name-is-already-in-use

Actions #4

Updated by Markus Klein over 9 years ago

We suspect that there is another extension which does dirty stuff, namely using a "use" statement in ext_localconf/ext_tables.
Can you please scan your extensions' ext_localconf/ext_tables for "use" statements?

Actions #5

Updated by Stefan Gruber over 9 years ago

I have checked all the non system extensions, but there is no use statement in one of these files.

I have written a little example which demonstartes the issue by running test.php. In the folder working is a working example.

Actions #6

Updated by Stefan Gruber over 9 years ago

Just saw that the issue was created in the Typo3 core project. It should have been in the news extension. Could you move it please.
I think you can close this issue as it is the same as this one: https://forge.typo3.org/issues/67223

Actions #7

Updated by Georg Ringer over 9 years ago

  • Status changed from Needs Feedback to Resolved

thx for your patch!

Actions #8

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF