[FEATURE] Add extension config to produce unique file field names #2171
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TYPO3 has a limitation (one among many) when dealing with with FAL references within FlexForms. The field name saved to sys_file_reference is unique to the DS but not unique to the parent field name context.
Usually we would solve this by extending foreign_match_fields but someone in their infinite wisdom decided that as part of the automatic TCA migration wizard that rewrites type=inline with FAL to type=file, the foreign_match_fields setting should be destroyed and type=file should not have any support whatsoever for this kind of advanced relation criteria.
We are therefore left with only one option: changing the field name of the FAL field to include the parent field name as prefix. This new extension feature enables that behavior.
Unfortunately this means that file references are stored in a completely different way which is not compatible. Changing this extension setting will effectively orphan all existing file relations. You should therefore never change this unless you are setting up a new site, or you plan to migrate all your existing file relations (updating sys_file_reference to set a new fieldname value for every relation matching your set of FAL field names throughout all templates).
Note: the prefix is automatically handled when using transform="file" and other file transform types. But if you use other means of resolving the FAL reference you'll need to manually specify the prefixed version of the fieldname when fetching file relation records.