Description
FlexFormUserFunctions::getFacetFieldsFromSchema() and FlexFormUserFunctions::getAvailableTemplates() access $parentInformation['flexParentDatabaseRow'] without checking if the key exists, causing PHP warnings:
PHP Warning: Undefined array key "flexParentDatabaseRow" in
Classes/System/UserFunctions/FlexFormUserFunctions.php line 45
PHP Warning: Undefined array key "flexParentDatabaseRow" in
Classes/System/UserFunctions/FlexFormUserFunctions.php line 142
Steps to Reproduce
- Open a content element with a Solr plugin in the TYPO3 backend
- The FlexForm rendering triggers
getFacetFieldsFromSchema() and getAvailableTemplates()
- Under certain conditions (e.g. new content element, or specific TCA context),
flexParentDatabaseRow is not set in $parentInformation
Expected Behavior
No PHP warning. The methods should check for the key's existence before accessing it, similar to the is_array($pageRecord) guard that already exists a few lines later.
Actual Behavior
PHP Warning is logged to sys_log for every affected FlexForm render. In our case, 169 warnings were logged in a single backend session.
Suggested Fix
Add a null-coalescing check before accessing the key:
// Line 45 (getFacetFieldsFromSchema)
$pageRecord = $parentInformation['flexParentDatabaseRow'] ?? null;
// Line 142 (getAvailableTemplates)
$pageRecord = $parentInformation['flexParentDatabaseRow'] ?? null;
The existing if (!is_array($pageRecord)) guards on the subsequent lines would then handle the null case correctly.
Environment
- EXT:solr version: 13.1.1
- TYPO3 version: 13
- PHP version: 8.4
Description
FlexFormUserFunctions::getFacetFieldsFromSchema()andFlexFormUserFunctions::getAvailableTemplates()access$parentInformation['flexParentDatabaseRow']without checking if the key exists, causing PHP warnings:Steps to Reproduce
getFacetFieldsFromSchema()andgetAvailableTemplates()flexParentDatabaseRowis not set in$parentInformationExpected Behavior
No PHP warning. The methods should check for the key's existence before accessing it, similar to the
is_array($pageRecord)guard that already exists a few lines later.Actual Behavior
PHP Warning is logged to
sys_logfor every affected FlexForm render. In our case, 169 warnings were logged in a single backend session.Suggested Fix
Add a null-coalescing check before accessing the key:
The existing
if (!is_array($pageRecord))guards on the subsequent lines would then handle thenullcase correctly.Environment