Skip to content

Commit

Permalink
[BUGFIX] Disable translation for TCA field file of sys_file_metadata
Browse files Browse the repository at this point in the history
There is a flaw in the way TYPO3 handle the rendering of the backend edit
forms that leads to fields used as labels always being rendered. This may
lead to an huge amount of html being generated and thrown away without
ever being pushed to the browser.

For most fields, this effort is negligible, since TYPO3 has to render
i.e. the title field once per backend call anyway. For table using a
relation as title, as does `sys_file_metadata`, this means generating
a select with all files in the system that could be related to that
record.

What happens is, that since the label of the sys_file_metadata record is
the field file, the FormDataProvider `TcaColumnsProcessRecordTitle` will
add file to the columnsToProcess for the current record and the
`TcaSelectItems`  will happily work it's way through and generate the
html for the select box. Bare in mind, that this is absolute and utter
dead weight since nowhere in the TCA showItem definition of any type the
file field is referenced. This would not be to big of a problem since
in most systems there are no more than 10k files but in systems with
100'000+ the memory get's used up and it can lead to memory exhausted
errors in PHP (even with as much as 512M memory_limit).

Resolves: #82990
Releases: master, 9.5
Change-Id: I5da8e08b71dfacac0535e4c8e858099d7e307a3e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61970
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog <look@susi.dev>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Susanne Moog <look@susi.dev>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
  • Loading branch information
Tizian Schmidlin authored and ervaude committed Mar 15, 2020
1 parent 8774666 commit 7e1203a
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ public function addData(array $result)
);

// Translate labels
$fieldConfig['config']['items'] = $this->translateLabels($result, $fieldConfig['config']['items'], $table, $fieldName);
// skip file of sys_file_metadata which is not rendered anyway but can use all memory
if ($table !== 'sys_file_metadata' && $fieldName !== 'file') {
$fieldConfig['config']['items'] = $this->translateLabels($result, $fieldConfig['config']['items'], $table, $fieldName);
}

// Keys may contain table names, so a numeric array is created
$fieldConfig['config']['items'] = array_values($fieldConfig['config']['items']);
Expand Down

0 comments on commit 7e1203a

Please sign in to comment.