Bug #98656
closedOverriding ['TCA']['pages']['columns']['categories']['config']['foreign_table_where'] does not work
100%
Description
In one of our extension we're overriding the TCA of the pages colums categories:
extfoobar\Configuration\TCA\Overrides\pages.php
$GLOBALS['TCA']['pages']['columns']['categories']['config']['foreign_table_where'] = " AND sys_category.pid IN (###PAGE_TSCONFIG_IDLIST###) AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.sorting ASC";
But this will allways be override by the core:
typo3_src-11.5.17/typo3/sysext/core/Classes/Preparations/TcaPreparation.php
protected function configureCategoryRelations(array $tca): array
{
....
// Initialize default column configuration and merge it with already defined
$fieldConfig['config']['size'] ??= 20;
// Force foreign_table_* fields for type category
$fieldConfig['config']['foreign_table'] = 'sys_category';
$fieldConfig['config']['foreign_table_where'] = ' AND {#sys_category}.{#sys_language_uid} IN (-1, 0)';
For ['size'] it will be checked if there's already a value defined, but not for ['foreign_table_where'].
Shluld it be like this?
$fieldConfig['config']['foreign_table_where'] = $fieldConfig['config']['foreign_table_where'] ?? ' AND {#sys_category}.{#sys_language_uid} IN (-1, 0)';
Or am I doing something wrong?
Ralph
Updated by Andreas Kießling about 2 years ago
I can confirm this with tt_address. I wanted to limit the selectable categories to the same page with the ###CURRENT_PID### marker --> does not work.
Isn't the order of execution wrong in this case? IMHO the TCA/Overrides should run AFTER the TCA is loaded from extension and the core, and so any generated config can be overriden. Having checks if the field is already defined and thus some fields are overriden, others are appended is not what i would expect
Updated by Oliver Bartsch about 2 years ago
- Related to Feature #94622: Introduce new TCA type "category" added
Updated by Gerrit Code Review about 2 years ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76440
Updated by Gerrit Code Review about 2 years ago
Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76415
Updated by Oliver Bartsch about 2 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 9cb50d9e1aa6a3093c58ffa1774eb3e538d96093.