headless icon indicating copy to clipboard operation
headless copied to clipboard

Recursion detected error when using some form elements

Open davidlemaitre opened this issue 11 months ago • 5 comments

Describe the bug A error "Recursion detected" occurs when using some form elements.

To Reproduce Steps to reproduce the behavior:

  1. Go to Form module
  2. Create a empty form
  3. Add one of the following form content elements : checkbox, grid row, fieldset, contentelement, radiobutton, singleselet (not an exhautive list)
  4. Save changes
  5. Add the form to a page
  6. Visit page

Expected behavior Expected JSON rendering for these form elements without errors.

Screenshots image

TYPO3 version and TYPO3 Headless version TYPO3 11.5.36 EXT:headless 3.4.1

Additional context PHP 8.0

davidlemaitre avatar Mar 07 '24 16:03 davidlemaitre

Hi @davidlemaitre, could you provide example yaml file which is causing a crash?

twoldanski avatar Mar 13 '24 09:03 twoldanski

This is the yaml file for a simple form with a text field and a checkbox. asimpleform.form.yaml.txt

davidlemaitre avatar Mar 21 '24 18:03 davidlemaitre

I'm able to reproduce with PHP 8.3.4

davidlemaitre avatar Mar 25 '24 11:03 davidlemaitre

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)

dacko-sk avatar Apr 16 '24 11:04 dacko-sk

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.

twoldanski avatar Apr 23 '24 15:04 twoldanski

Hi @twoldanski, I confirm that this patch solves the issue

davidlemaitre avatar Apr 29 '24 15:04 davidlemaitre