Project

General

Profile

Actions

Bug #103885

open

foreign_match_fields is ignored in flexforms in Typo3 12

Added by Georgi Mateev 8 months ago. Updated about 2 months ago.

Status:
Accepted
Priority:
Should have
Assignee:
-
Category:
System/Bootstrap/Configuration
Target version:
-
Start date:
2024-05-23
Due date:
% Done:

0%

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

Description

The inline TCA type (also tested for the new file type) does not respect the configuration foreign_match_fields.fieldname when in Flexform context. Up to TYPO3 v11 it would respect it and store the value in the sys_file_reference table. After updating to TYPO3 v12 it does not respect it anymore and writes the name of the TCA Field instead.

Example:

<settings.thumbnailImages>
                        <label>LLL:EXT:sg_vimeo/Resources/Private/Language/locallang.xlf:flexform.thumbnailImages
                        </label>
                        <description>
                            LLL:EXT:sg_vimeo/Resources/Private/Language/locallang.xlf:flexform.thumbnailImages.description
                        </description>
                        <config>
                            <type>inline</type>
                            <foreign_table>sys_file_reference</foreign_table>
                            <foreign_field>uid_foreign</foreign_field>
                            <foreign_table_field>tablenames</foreign_table_field>
                            <foreign_label>uid_local</foreign_label>
                            <foreign_sortby>sorting_foreign</foreign_sortby>
                            <foreign_selector>uid_local</foreign_selector>
                            <foreign_selector_fieldTcaOverride type="array">
                                <config>
                                    <appearance>
                                        <elementBrowserType>file</elementBrowserType>
                                        <elementBrowserAllowed>jpg,png,svg,jpeg,gif,webp</elementBrowserAllowed>
                                    </appearance>
                                </config>
                            </foreign_selector_fieldTcaOverride>
                            <foreign_match_fields type="array">
                                <fieldname>tx_sgvimeo_thumbnail_image</fieldname>
                            </foreign_match_fields>
                            <filter type="array">
                                <userFunc>TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter->filterInlineChildren
                                </userFunc>
                                <parameters>
                                    <allowedFileExtensions>jpg,png,svg,jpeg,gif,webp</allowedFileExtensions>
                                    <disallowedFileExtensions></disallowedFileExtensions>
                                </parameters>
                            </filter>
                            <appearance type="array">
                                <useSortable>1</useSortable>
                                <headerThumbnail>
                                    <field>uid_local</field>
                                    <height>45m</height>
                                </headerThumbnail>
                                <enabledControls>
                                    <info>1</info>
                                    <new>0</new>
                                    <dragdrop>1</dragdrop>
                                    <sort>1</sort>
                                    <hide>1</hide>
                                    <delete>1</delete>
                                </enabledControls>
                            </appearance>
                            <overrideChildTca>
                                <columns type="array">
                                    <uid_local type="array">
                                        <config type="array">
                                            <appearance type="array">
                                                <elementBrowserType>file</elementBrowserType>
                                                <elementBrowserAllowed>jpg,png,svg,jpeg,gif</elementBrowserAllowed>
                                            </appearance>
                                        </config>
                                    </uid_local>
                                    <crop type="array">
                                        <config type="array">
                                            <cropVariants type="array">
                                                <medium type="array">
                                                    <disabled>1</disabled>
                                                </medium>
                                                <small type="array">
                                                    <disabled>1</disabled>
                                                </small>
                                                <extrasmall type="array">
                                                    <disabled>1</disabled>
                                                </extrasmall>
                                            </cropVariants>
                                        </config>
                                    </crop>
                                </columns>
                                <types type="array">
                                    <numIndex index="2">
                                        <showitem>
                                            --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette
                                        </showitem>
                                    </numIndex>
                                </types>
                            </overrideChildTca>
                        </config>
                    </settings.thumbnailImages>

Expected result in the database:
tx_sgvimeo_thumbnail_image

Actual result in the database:
settings.thumbnailImages

You can test this with our sgalinski/sg-vimeo extension in version 7.1.11 when trying to set a custom thumbnail image.

This looks like a bug in TYPO3 12 or an undocumented breaking change.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #99756: Move TcaMigration to FlexFormProcessorClosed2023-01-30

Actions
Actions #1

Updated by Christian Kuhn 8 months ago

  • Related to Bug #99756: Move TcaMigration to FlexFormProcessor added
Actions #2

Updated by Georg Ringer 6 months ago ยท Edited

  • Status changed from New to Accepted

problem is in \TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::migrateFlexField calls $this->tcaMigration->migrate which removes with unset $fieldConfig['config']['foreign_match_fields'] and in \TYPO3\CMS\Core\Configuration\Tca\TcaPreparation::configureFileReferences it is set by default to the fieldname

can be reproduced in v13 in tx_styleguide_flex with

'flex_4' => [
            'label' => 'flex_4',
            'config' => [
                'type' => 'flex',
                'ds' => [
                    'default' => '
                        <T3DataStructure>
                            <sheets>
                                <sInline>
                                    <ROOT>
                                        <sheetTitle>inline</sheetTitle>
                                        <type>array</type>
                                        <el>
                                          <settings.thumbnailImages>
                        <label>xxxx</label>
                        <description>
                            LLL:EXT:sg_vimeo/Resources/Private/Language/locallang.xlf:flexform.thumbnailImages.description
                        </description>
                        <config>
                            <type>inline</type>
                            <foreign_table>sys_file_reference</foreign_table>
                            <foreign_field>uid_foreign</foreign_field>
                            <foreign_table_field>tablenames</foreign_table_field>
                            <foreign_label>uid_local</foreign_label>
                            <foreign_sortby>sorting_foreign</foreign_sortby>
                            <foreign_selector>uid_local</foreign_selector>
                            <foreign_selector_fieldTcaOverride type="array">
                                <config>
                                    <appearance>
                                        <elementBrowserType>file</elementBrowserType>
                                        <elementBrowserAllowed>jpg,png,svg,jpeg,gif,webp</elementBrowserAllowed>
                                    </appearance>
                                </config>
                            </foreign_selector_fieldTcaOverride>
                            <foreign_match_fields type="array">
                                <fieldname>tx_sgvimeo_thumbnail_image</fieldname>
                            </foreign_match_fields>
                            <filter type="array">
                                <userFunc>TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter->filterInlineChildren
                                </userFunc>
                                <parameters>
                                    <allowedFileExtensions>jpg,png,svg,jpeg,gif,webp</allowedFileExtensions>
                                    <disallowedFileExtensions></disallowedFileExtensions>
                                </parameters>
                            </filter>
                            <appearance type="array">
                                <useSortable>1</useSortable>
                                <headerThumbnail>
                                    <field>uid_local</field>
                                    <height>45m</height>
                                </headerThumbnail>
                                <enabledControls>
                                    <info>1</info>
                                    <new>0</new>
                                    <dragdrop>1</dragdrop>
                                    <sort>1</sort>
                                    <hide>1</hide>
                                    <delete>1</delete>
                                </enabledControls>
                            </appearance>
                            <overrideChildTca>
                                <columns type="array">
                                    <uid_local type="array">
                                        <config type="array">
                                            <appearance type="array">
                                                <elementBrowserType>file</elementBrowserType>
                                                <elementBrowserAllowed>jpg,png,svg,jpeg,gif</elementBrowserAllowed>
                                            </appearance>
                                        </config>
                                    </uid_local>

                                </columns>

                            </overrideChildTca>
                        </config>
                    </settings.thumbnailImages>
                                        </el>
                                    </ROOT>
                                </sInline>

                            </sheets>
                        </T3DataStructure>
                    ',
                ],
            ],
        ],
Actions #3

Updated by Garvin Hicking 6 months ago

  • Category set to System/Bootstrap/Configuration
Actions #4

Updated by Lorenz Ulrich 2 months ago

@Georg Ringer As you also seem to have this problem, do you know what the way forward would be here?

Actions #5

Updated by Mike Street about 2 months ago

I've just encountered the same problem with an upgrade to 12.

I assume code has changed since @just2b's investigations as I wasn't able to find his referenced code, however I was able to locate the issue in

TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools

Specifically, in the `prepareFileFields` method - at lines 1026-1039 [GitHub link the 12.4 branch)

It seems that this array_replace_recursive replaces all the settings in the original config regardless of if it is set. I assume it is providing a fallback to ensure everything is correct.

To solve, it either needs to do a check to see if the array key exists or, with my quick tests, swap the parameters to provide the defaults first:

$fieldConfig['config'] = array_replace_recursive(
    [
        'foreign_table' => 'sys_file_reference',
        'foreign_field' => 'uid_foreign',
        'foreign_sortby' => 'sorting_foreign',
        'foreign_table_field' => 'tablenames',
        'foreign_match_fields' => [
            'fieldname' => $fieldName,
        ],
        'foreign_label' => 'uid_local',
        'foreign_selector' => 'uid_local',
    ],
    $fieldConfig['config']
);

As I say, this was only checked on my specific install with some debug's thrown around so would need verifying.


As an interim solution, I updated my FlexForm field to use the field name (e.g. settings.background) to ensure backwards compatibility once this fix rolls out and then using the following SQL to identify what will be affected and what needs updating

Example SQL - not to be copied and run directly

To get an idea of what items are affected

SELECT sfr.tablenames, sfr.fieldname, ttc.uid, ttc.CType
FROM sys_file_reference AS sfr
LEFT JOIN tt_content AS ttc ON sfr.uid_foreign = ttc.uid
WHERE sfr.fieldname = 'background'
AND sfr.tablenames = 'tt_content'
AND CType = '[your ctype]';
Actions

Also available in: Atom PDF