Bug #105131
closedReference Index Updater throws PHP warnings
0%
Description
We encounter a lot of these entries in our syslog table with configured Reference Index Updater Command:
Core: Error handler (BE): PHP Warning: Undefined array key "sheets" in xyz/vendor/typo3/cms-core/Classes/Configuration/FlexForm/FlexFormTools.php line 761
Taking a deeper look to figure out what's going on, I came across Reference Index Updater is checking every flexform data (pi_flexform column in tt_content table) to check references.
Somehow the FlexFormTools traverseFlexFormXMLData method expects 'sheets' key in XML's structures.
I couldn't find any 'sheets' node in my whole database for column pi_flexform - having a lot of plugins and custom CEs with various flexform use cases.
So my conclusion is that this may be a bug in FlexFormTools traverseFlexFormXMLData method.
Updated by Philipp Idler about 2 months ago ยท Edited
Correction: not the pi_flexform field is checked rather defined flexform data structure file.
Anyway, at least accessing 'sheets' key which may not exist should be fail-safe
if (!is_array($dataStructureArray['sheets'] ?? null)) {
Updated by Garvin Hicking about 2 months ago
- Related to Task #102229: Remove FlexFormTools traverser added
Updated by Garvin Hicking about 2 months ago
- Category changed from CLI to FormEngine aka TCEforms
- Status changed from New to Needs Feedback
There are two things here to address:
1. The method has been removed in T3v13 with #102229 and with it an intense refactoring of the refindex tool. This is a non-backportable change to v12, though.
2. The error you're getting should likely point to some flexform DS in your case that is missing '<sheets>' declarations where it is expected to have one. https://github.com/TYPO3/typo3/blob/23fde6520e7679d76b3a9a1cee58bac1cb15ba3c/typo3/sysext/core/Tests/Functional/Configuration/FlexForm/Fixtures/DataStructureOfSingleSheet.xml and https://github.com/TYPO3/typo3/blob/23fde6520e7679d76b3a9a1cee58bac1cb15ba3c/typo3/sysext/core/Tests/Functional/Configuration/FlexForm/Fixtures/DataStructureWithSheet.xml are examples for a file with a <sheets>
declaration and one without.
So maybe you are able to check your datasources (you can search your files for a <T3DataStructure>
) and see if maybe adding in <sheets>
there could fix the issue for you?
The problem is that adding a type check like you proposed will lead to follow-up errors. The place where this happens has follow-up code that definitely needs/wants those 'sheet' definitions, and that code will likely fail to do its intended job then. The right way to fix that would be to ensure that a non-sheet datasource is converted to a sheet-datasource (or vice versa). That however is a huge task and kind of hard to pursue, when TYPO3v13 already has a bright and shiny refactoring....
Updated by Philipp Idler about 2 months ago
Thank's for your support Garvin!
Some flexforms DS in my TYPO3 installation consist only of one sheet, so there is no <sheets> node like the one example file in your first link (DataStructureOfSingleSheet.xml). And that's the cause why mentioned PHP warning is thrown when such flexform DS files are processed by the traverse-function.
I understand that this is a huge task to backport refactored code from v13 to v12 - that's not in my mind either.
The typ3-check (!is_array) is already included in the code - I just added the part to omit PHP warning if key is not set in that array. The code afterwards wouldn't be executed with or without this change.
Updated by Garvin Hicking about 2 months ago
I see, thanks for getting back so quickly. :) So you tried a patch and that seems to work with your installation, do I understand right?
If so, would you like to contribute the patch and we could see to get it into the v12 version then, if you feel confident that it's just a small type-safety check?
Updated by Gerrit Code Review about 2 months ago
- Status changed from Needs Feedback to Under Review
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86366
Updated by Gerrit Code Review about 2 months ago
Patch set 2 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/86366
Updated by Philipp Idler about 2 months ago
While refactoring FlexFormTools to work with single and multi sheet flexform DS, I figured out that this job is already done in GeneralUtility:xml2Array method.
I took another round in debugging with my database and focus on CE's with flexform which trigger those PHP warnings, disovering one CE's with invalid flexform DS - missing <T3DataStructure> node at the beginning of file. By adding this node the reference indexer ran through all content without a single warning.
So this issue is solved and not a single line of code had to be touched.
Updated by Garvin Hicking about 2 months ago
- Status changed from Under Review to Closed
Happy to hear that, thanks for reporting back! :-)