Issue Feature New Stale

#110720Add the possibility to restrict TCA overwrites

Daniel Windloff 09/16/26, 10:53 updated 09/16/26, 10:53

Description

Current situation

TYPO3’s main configuration API is TCA. The configuration could be set via
@EXT:<my_extension>/Configuration/TCA/<mytable>.php@</mytable></my_extension>

and could be modified via
- BeforeTcaOverridesEvent
- EXT:<my_extension>/Configuration/TCA/Overrides/<any_table>.php
- AfterTcaCompilationEvent

Any value set in the initial TCA configuration could be modified.
The collection of all TCA related configuration is done via TcaFactory .
In BootService the TCA configuration is handed to the TcaSchemaFactory .
The TcaSchemaFactory saves the `TCA` configuration and has no public API to modify, as the methods load and rebuild are internal.
Therewith, further modifications of $GLOBALS['TCA'] should never change the configuration provided by the TcaSchema.

Problem

Neither the TYPO3 core nor third-party extensions have an option to ensure that a TCA configuration set in EXT:<my_extension>/Configuration/TCA/<mytable>.php will not be modified, even if it is necessary to leave it unchanged.

Suggested feature

Provide the following two configuration options, which can only be set in EXT:<my_extension>/Configuration/TCA/<mytable>.php:

a) denyOverwrites (bool), default false

Denies any overwrites for a specific column configuration via any TCA overwrite.

Example:

EXT:<my_extension>/Configuration/TCA/<mytable>.php
    return [
        'columns' => [
            '<mycolumn>' => [
                'denyOverwrites' => true
                'label' => 'Config must not be changed',
                'config' => [
                    'type' => 'input'
                ]
            ]
        ]
    ];

Any configuration changing this column, like in EXT:<my_extension>/Configuration/TCA/Overrides/<any_table>.php, will not apply.
Furthermore, any change in columnOverwrides for this column will be removed as well.

The following configuration will not change the resulting TCA:
Example:

`EXT:<my_extension>/Configuration/TCA/Overrides/<any_table>.php`
    $GLOBALS['TCA']['<mytable>']['columns']['<mycolumn>']['config']['eval'] = 'trim';

    $GLOBALS['TCA']['<mytable>']['<mytype>']['columnOverrides']['<mycolumn>']['config']['eval'] = 'trim';

Changes via overwrideChildTca remain possible.

b) protectConfigOptions (array), default []

Denies overwrites for a specific list of TCA configuration keys of one column.
Every configuration key in <mycolumn> or <mycolumn> config in this list will be removed.</mycolumn></mycolumn>

Example:

EXT:<my_extension>/Configuration/TCA/<mytable>.php`
    return [
        'columns' => [
            '<mycolumn>' => [
                'protectConfigOptions' => ['type', 'displayCond']
                'displayCond' => 'HIDE_FOR_NON_ADMINS',
                'label' => 'Config must not be changed',
                'config' => [
                    'type' => 'input'
                ]
            ]
        ]
    ];

Results on TCA overwrites:

Example:

EXT:<my_extension>/Configuration/TCA/Overrides/<any_table>.php`
    // TCA modifications will apply
    $GLOBALS['TCA']['<mytable>']['columns']['<mycolumn>']['config']['eval'] = 'trim';

    // TCA modifications will not apply 
    $GLOBALS['TCA']['<mytable>']['columns']['<mycolumn>']['displayCond'] = 'REC:NEW:false';
    $GLOBALS['TCA']['<mytable>']['<mytype>']['columnOverrides']['<mycolumn>']['config']['type'] = 'select';

Benefits

The TYPO3 core and extensions could define TCA configurations, which must stay unchanged to ensure a working and secret environment. This also documents, which parts of the TCA are public API and could be changed.

Implementation

- Collecting denyOverwrites and protectConfigOptions from EXT:<my_extension>/Configuration/TCA in TcaFactory .
- Calculate the difference of every TCA modification.
- Remove protected modifications before applying the TCA overwrites
- Remove denyOverwrites and protectConfigOptions from TCA.

Performance considerations

As the result of TcaFactory is cached, only the first not cached hit will have more execution time. Due to the removal of the new introduced configuration options, no further RAM has been used after caching.
Possible refactoring after the introduction of this feature will increase runtime performance.

Example usages of this feature in the TYPO3 core

Short-term

a) core/Classes/Hooks/PagesTsConfigGuard.php
This hook ensures that only admins are allowed changing TSconfig in pages.
Ensuring that the configuration 'displayCond' => 'HIDE_FOR_NON_ADMINS'
stay unchanged will allow dropping this hook.

b) DataHandler->checkValueForPassword
A special condition ensures that passwords of fe_users and be_users are always hased.
Ensuring that the configuration 'hashed' => true stays unchanged will allow to dropping this special condition.

Mid-term

The page permissions could not be set (except for editlock ) via the usual page edit or creation using the EditDocumentController .
Changing page permissions always needs a context change to another module.
Adding the permissions as typical TCA types will allow streamlining the editing process for admins, streamlining data flow in DataHandler . This also requires a way to keep certain new TCA configurations unchanged.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[FEATURE] Add the possibility to restrict TCA overwrites Resolves: #110720 Releases: main