#109108FilesProcessor: Missing null-coalescing operator for folders.recursive causes TypeError
Description
Problem
The FilesProcessor throws a TypeError when using the folders configuration without explicitly setting folders.recursive , even though folders.recursive is an optional parameter according to the documentation.
TypeError: TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::stdWrapValue():
Argument #2 ($config) must be of type array, null given,
called in vendor/typo3/cms-frontend/Classes/DataProcessing/FilesProcessor.php on line 102
Steps to Reproduce
1. Configure a content element with FilesProcessor using the folders parameter:
tt_content {
tx_example_element {
dataProcessing {
20 = files
20 {
folders = 1:user_upload/my-folder/
as = defaultimages
}
}
}
}
2. Render the content element on the frontend
3. TypeError is thrown at line 102 of FilesProcessor.php
Root Cause
Line 102 in FilesProcessor.php:
$fileCollector->addFilesFromFolders($folders, (bool)$cObj->stdWrapValue('recursive', $processorConfiguration['folders.']));
When folders.recursive is not explicitly set in TypoScript, $processorConfiguration[‘folders.’] is null , causing stdWrapValue() to fail with a TypeError because it expects an array as the second parameter.
Inconsistency in the Same File
Line 110 (correct implementation):
$sortingDirection = $cObj->stdWrapValue(
'direction',
$processorConfiguration['sorting.'] ?? [],
'ascending'
);
Line 110 correctly uses the null-coalescing operator (?? []) to provide an empty array fallback when sorting. doesn’t exist, but line 102 does not follow the same pattern.
Expected Behavior
The folders.recursive parameter should be optional. When not specified, the FilesProcessor should work without throwing errors (defaulting to non-recursive behavior).
Suggested Fix
Add the null-coalescing operator to line 102, consistent with line 110:
$fileCollector->addFilesFromFolders($folders, (bool)$cObj->stdWrapValue('recursive', $processorConfiguration['folders.'] ?? []));
Or provide a default value:
$fileCollector->addFilesFromFolders($folders, (bool)$cObj->stdWrapValue('recursive', $processorConfiguration['folders.'] ?? [], false));
Workaround
Until this is fixed, explicitly set in your TypoScript configuration: `folders.recursive`
20 = files
20 {
folders = 1:user_upload/my-folder/
folders.recursive = 0
as = defaultimages
}
Additional Context
This appears to be a regression introduced in a recent attempt to add stdWrap support to folders.recursive (possibly related to issue #107160). The previous implementation used !empty($processorConfiguration[‘folders.’][‘recursive’]) which handled null values gracefully.
Related Issues
- - Request for stdWrap support in folders.recursive