headless
headless copied to clipboard
Recursion detected error when using some form elements
Describe the bug A error "Recursion detected" occurs when using some form elements.
To Reproduce Steps to reproduce the behavior:
- Go to Form module
- Create a empty form
- Add one of the following form content elements : checkbox, grid row, fieldset, contentelement, radiobutton, singleselet (not an exhautive list)
- Save changes
- Add the form to a page
- Visit page
Expected behavior Expected JSON rendering for these form elements without errors.
Screenshots
TYPO3 version and TYPO3 Headless version TYPO3 11.5.36 EXT:headless 3.4.1
Additional context PHP 8.0
Hi @davidlemaitre, could you provide example yaml file which is causing a crash?
This is the yaml file for a simple form with a text field and a checkbox. asimpleform.form.yaml.txt
I'm able to reproduce with PHP 8.3.4
Hi guys, I am also having this issue in PHP 8.2.
The problem seems to be in "translate" method of https://github.com/TYPO3-Headless/headless/blob/master/Classes/Form/Translator.php
$result['renderables'][] = array_replace_recursive($page, $pageTranslation);
where $page & $pageTranslation arrays are referencing to each other, which is causing the recursion.
The referencing happens in the "translateRenderables" method, where the renderables elements of the resulting array are pointers to renderables elements of the original array.
If I change
foreach ($renderables as &$element)
to
foreach ($renderables as $element)
the recursion error does not happen anymore, but the children renderables are not translated anymore (e.g. fieldset or grid row / column children elements)
Hi @davidlemaitre @dacko-sk , I could not manage to reproduce this error on 3.x or 4.x of headless, but I prepared patch, which possibly will resolve the issue.
Hi @twoldanski, I confirm that this patch solves the issue