Bug #95825
closed"Check TCA" must include ext_localconf.php
0%
Description
When I press the button to execute "Check TCA in ext_tables.php" from the Upgrade module, then this results in an error message.
This happens only because the file ext_localconf.php has not been included before the TCA file is executed. The constant TT_BOARD_EXT is defined there.
*(1/1) #1476107295 TYPO3\CMS\Core\Error\Exception PHP Warning: Use of undefined constant TT_BOARD_EXT - assumed 'TT_BOARD_EXT' * _ (this will throw an Error in a future version of PHP) in /var/www/html/develop/typo3conf/ext/tt_board/Configuration/TCA/tt_board.php line 21 in /var/www/html/develop/typo3_src-10.4.17/typo3/sysext/core/Classes/Error/ErrorHandler.php line 134 E_DEPRECATED => 'PHP Runtime Deprecation Notice' ]; $message = $errorLevels[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine; if ($errorLevel & $this->exceptionalErrors) { throw new Exception($message, 1476107295); } switch ($errorLevel) { case E_USER_ERROR: case E_RECOVERABLE_ERROR: at TYPO3\CMS\Core\Error\ErrorHandler->handleError() in /var/www/html/develop/typo3conf/ext/tt_board/Configuration/TCA/tt_board.php line 21 'prependAtCopy' => 'LLL:EXT:lang/locallang_general.php:LGL.prependAtCopy', 'enablecolumns' => [ 'disabled' => 'hidden' ], 'title' => 'LLL:EXT:' . TT_BOARD_EXT . DIV2007_LANGUAGE_SUBPATH . 'locallang_tca.xlf:tt_board', 'typeicon_column' => 'parent', 'typeicons' => [ '0' => 'tt_faq_board_root.gif' ], _
Updated by Stefan Bürk about 3 years ago
That's more an issue of the extension, meaning relay on a defined constant instead of checking if it is really defined.
There are reasons why ext_localconf.php is not loaded there, and that scanner itself is to ensure no TCA is in ext_tables.php. Installtool context do not have fully bootsptrapped extensions, for a good reason. On some places partly using more things are implemented.
Either the ext_tables.php should do proper checks if the used constant is really defined (always best practice), or define that constant in a place where it is loaded in install tool context.
Updated by Franz Holzinger about 3 years ago
Why do you think that the file ext_localconf.php of an extension must not include any constants?
There should be no need to check the constant in the TCA files, if it is made sure it is defined in the file ext_localconf.php.
What do you mean with "a place where it is loaded in install tool context"?
TYPO3 has since 20 years used the file ext_localconf.php to be usable for constants. Did this really change?
Updated by Oliver Hader almost 3 years ago
- Description updated (diff)
- Category changed from Backend User Interface to Install Tool
Updated by Christian Kuhn about 2 years ago
- Status changed from New to Rejected
Hey. Thanks for feedback.
ext_localconf.php and ext_tables.php MUST NOT declare things TCA setup depends on in any way since TCA is loaded and cached before ext_* files are loaded.
Closing.
Updated by Franz Holzinger about 2 years ago
Since when did the behaviour of TYPO3 change that it does not load the files ext_localconf.php before the TCA?
Where must the constants be defined now?
Updated by Christian Kuhn about 2 years ago
Best bet is to not use constants that should be used within TCA at all.
Updated by Franz Holzinger about 2 years ago
It makes no sense to me to spare constants in PHP code.
Updated by Christian Kuhn about 2 years ago
Both ext_localconf and ext_tables are shrinking for a couple of major core versions significantly already. They will be obsoleted entirely at some point.
TCA loading has been changed in v9 if i remember correctly to not depend on ext_tables.php anymore and there is some check within install tool that ext_tables does not change TCA anymore for quite a while (since v9 or even earlier?)?
Please check the documentation changelog for more details on this.
Updated by Franz Holzinger about 2 years ago
But the extension files ext_localconf.php are still included before TCA is generated even in TYPO3 11.5. Otherwise many extension would not be working any more.
So this means that I must invent my own files for the constants which will be included from the TCA files under Configuration/TCA/ .