Task #66390
closedConflicting "use" namespace in extension extLocalconf.php and extTables.php breaks cache
0%
Description
Using shortened namespaces with "use" in the files extLocalconf.php and extTables.php for an extension breaks the cache. These files are concatenated which might lead to multiple "uses" of the same namespace.
Classic example would be "TYPO3\CMS\Core\Utility\ExtensionManagementUtility".
Solution would be to parse for "use" statements during concatenation, store them in an array, remove them from the code, remove duplicates from the array and then add the whole of it back to the top of the concatenated file.
Updated by Markus Klein over 9 years ago
- Status changed from New to Rejected
- Target version deleted (
6.2.12)
Usage of "use" statement inside those files is strictly forbidden, exactly because of this issue.
It is way more efficient to solve the issue by changing the extension than doing magic rewrites for the cache.
Updated by Philipp Wrann over 9 years ago
Strictly forbidden? I didnt know that and ran into the same problem.
TYPO3 supports php namespaces and should (imo) also respect their usage when concatenating php code.
The solution described by sven seems good enough, it would only cost a few nanoseconds to do that on the very first page hit.
Updated by Markus Klein over 9 years ago
How would you deal with those two ext_localconf.php files?
ext1:
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility as ExtUtil;
ext2:
use TYPO3\CMS\Extbase\Utility\ExtensionUtility as ExtUtil;
If you combine them, you gonna die.
There is more edge-cases than normal cases. So no way to guarantee that we parse the files correctly.