#103885foreign_match_fields is ignored in flexforms in Typo3 12
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.
Reviews 3
Related issues 1
History 1417
-
Christian Kuhn changed Related to #99756 <span data-processor="relativetime" data-value="2024-05-27T14:01:46+00:00" > 05/27/24, 14:01 </span>
-
Georg Ringer commented and changed status
NewAccepted <span data-processor="relativetime" data-value="2024-07-12T18:41:43+00:00" > 07/12/24, 18:41 </span> -
Garvin Hicking changed category <span data-processor="relativetime" data-value="2024-07-31T09:03:48+00:00" > 07/31/24, 09:03 </span>
-
Lorenz Ulrich commented <span data-processor="relativetime" data-value="2024-11-13T10:27:32+00:00" > 11/13/24, 10:27 </span>
@just2b As you also seem to have this problem, do you know what the way forward would be here?
-
Mike Street commented <span data-processor="relativetime" data-value="2024-11-25T14:38:34+00:00" > 11/25/24, 14:38 </span>
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\FlexFormToolsSpecifically, in the `prepareFileFields` method – at lines 1026-1039 GitHub link(on the 12.4 branch)
It seems that this
array_replace_recursivereplaces 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 updatingExample 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]'; -
Lorenz Ulrich commented <span data-processor="relativetime" data-value="2025-01-19T21:11:03+00:00" > 01/19/25, 21:11 </span>
obartsch andbenni: Since you are the creators of the code in question here: Can I assume that the possibility to use `foreign_match_fields` in a FlexForm of type file was just removed (which would be an undocumented breaking change) or do you consider it a bug? -
Loon Buster commented and changed priority
Should haveMust have <span data-processor="relativetime" data-value="2025-01-24T19:33:17+00:00" > 01/24/25, 19:33 </span>BUG.
-
Loon Buster commented <span data-processor="relativetime" data-value="2025-01-27T20:18:54+00:00" > 01/27/25, 20:18 </span>
In TYPO3 v12, the foreign_match_fields configuration in FlexForms is removed during the TCA migration. This happens in the TcaMigration::migrate method, where the field is deleted using unset($fieldConfig[‘config’][‘foreign_match_fields’]);. Additionally, the value is no longer stored in the fieldname field of the sys_file_reference table. This results in the loss of custom mappings that previously played a crucial role in FlexForm and file assignments.
The functionality of foreign_match_fields or fieldname allowed for specific and unique mappings to be stored in the sys_file_reference table. These mappings are essential for maintaining a robust and flexible data structure—independent of extensions or modifications to the FlexForm files. The removal of this configuration leads to significant limitations, especially in scenarios that require flexibility and adaptability. It also complicates the visibility and traceability of mappings within the database.
Why isn’t the fieldname field offered as an alternative option? Such a choice would allow developers to decide between using the standard automation or a customized flexibility. This would not only secure existing use cases but also significantly enhance developer-friendliness and transparency.
.loon
-
Cyril Janody commented <span data-processor="relativetime" data-value="2025-05-29T17:35:55+00:00" > 05/29/25, 17:35 </span>
Hi guys,
Is there a plan to solve this issue or is this a breaking change?
Thank you :)
-
Gerrit Code Review pushed patch set 1 for main to change 89593 status
AcceptedUnder Review <span data-processor="relativetime" data-value="2025-05-30T07:55:17+00:00" > 05/30/25, 07:55 </span> -
Garvin Hicking commented <span data-processor="relativetime" data-value="2025-05-30T08:05:00+00:00" > 05/30/25, 08:05 </span>
Please check out https://review.typo3.org/c/Packages/TYPO3.CMS/+/89593 if that works for you (thanks to Oli!)
-
Oliver Bartsch commented <span data-processor="relativetime" data-value="2025-05-30T16:12:42+00:00" > 05/30/25, 16:12 </span>
Hi,
I’m really sorry for the late reply. You’re absolutely right — this does appear to be a bug, and I’ve now provided a fix for it. Thanks a lot for reporting it! I’d be grateful if you could take a moment to review the patch.
Best,
Oli -
Cyril Janody commented <span data-processor="relativetime" data-value="2025-05-30T16:42:16+00:00" > 05/30/25, 16:42 </span>
Hi,
Looks good to me.
Thank you very much for the patch.
Have a nice weekend!
Cyril
-
Gerrit Code Review pushed patch set 1 for 13.4 to change 89599 <span data-processor="relativetime" data-value="2025-05-31T08:43:10+00:00" > 05/31/25, 08:43 </span>
-
Gerrit Code Review pushed patch set 1 for 12.4 to change 89600 <span data-processor="relativetime" data-value="2025-05-31T08:50:23+00:00" > 05/31/25, 08:50 </span>
-
Oliver Bartsch commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2025-05-31T09:35:08+00:00" > 05/31/25, 09:35 </span>Applied in changeset commit:15ebc9787d1839679c179433423b76de03412f89.
-
Benni Mack changed status
ResolvedClosed <span data-processor="relativetime" data-value="2025-12-02T14:33:23+00:00" > 12/02/25, 14:33 </span>
problem is in
\TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools::migrateFlexFieldcalls$this->tcaMigration->migratewhich removes with unset$fieldConfig['config']['foreign_match_fields']and in\TYPO3\CMS\Core\Configuration\Tca\TcaPreparation::configureFileReferencesit is set by default to the fieldnamecan be reproduced in v13 in
tx_styleguide_flexwith'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> ', ], ], ],