Project

General

Profile

Actions

Bug #95825

closed

"Check TCA" must include ext_localconf.php

Added by Franz Holzinger over 2 years ago. Updated over 1 year ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Install Tool
Target version:
-
Start date:
2021-10-30
Due date:
% Done:

0%

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

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'
        ],
_
Actions #1

Updated by Stefan Bürk over 2 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.

Actions #2

Updated by Franz Holzinger over 2 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?

Actions #3

Updated by Oliver Hader about 2 years ago

  • Description updated (diff)
  • Category changed from Backend User Interface to Install Tool
Actions #4

Updated by Christian Kuhn over 1 year 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.

Actions #5

Updated by Franz Holzinger over 1 year 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?

Actions #6

Updated by Christian Kuhn over 1 year ago

Best bet is to not use constants that should be used within TCA at all.

Actions #7

Updated by Franz Holzinger over 1 year ago

It makes no sense to me to spare constants in PHP code.

Actions #8

Updated by Christian Kuhn over 1 year 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.

Actions #9

Updated by Franz Holzinger over 1 year 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/ .

Actions

Also available in: Atom PDF