Issue Bug Resolved

#95181FlexForm – String returned for empty sections instead of Array

Pierrick Caillon 09/10/21, 14:40 updated 11/10/26, 06:45

Description

When using the section feature of FlexForm, and empting a section, the result parsed flexform will contain an empty string instead of an empty array.
This behaviour existed before the introduction of FlexFormService.

To reproduce, a contributor must remove all elements in a flexform section and save. The flexform will then contain:

                <field index="my_field">
                    <el index="el"></el>
                </field>

In EXT:core/Classes/Service/FlexFormService.phpL49, when discovering a node named el, the parser is recursively called. When $nodeValue is an empty string, it should return an empty array. Not doing so force developers to test again empty, which can not always be done straightforwardly. It is expected to be able to test with count().

I attached an example flexform to test with.

Reviews 2

Files 4

History 811

  1. Larry Garfield commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2022-04-12T16:56:43+00:00" > 04/12/22, 16:56 </span>

    Hi Pierrick. I’m trying to turn your examples into a test so I can make a patch for this, but I’m not entirely clear on it. There’s no empty section in the XML you provided, is there?

    When I run it through a test (after adding a “data” element wrapper around “sheets”, and adding index attributes to sheets and sDEF to avoid parse errors), I get the same result back both with and without your patch.

    Can you clarify, perhaps with a confirmed test case?

    (I’m testing on `main` currently, so the future v12.)

  2. Pierrick Caillon commented <span data-processor="relativetime" data-value="2022-04-13T16:19:20+00:00" > 04/13/22, 16:19 </span>

    It is not when a section is declared empty in the datastructure. But after removing all elements from a declared section in a flexform instance.

  3. Pierrick Caillon commented and changed attached unexpected result after changes.mp4 attached temp.zip <span data-processor="relativetime" data-value="2022-05-24T17:24:16+00:00" > 05/24/22, 17:24 </span>

    I have created the smallest possible extension to provide necessary configuration.
    In the attached video, I illustrate the reproduction steps using this extension.

    Should I also illustrate transformation service in frontend?

    (Reproduction done using main (e97def2559e6185392d2f3089c51ced2e740327a))

  4. Susanne Moog changed Complexity no-brainer medium Sprint Focus Remote Sprint On Location Sprint <span data-processor="relativetime" data-value="2022-08-05T12:59:52+00:00" > 08/05/22, 12:59 </span>

  5. Gerrit Code Review pushed patch set 1 for main to change 97476 status Needs Feedback Under Review <span data-processor="relativetime" data-value="2026-11-09T21:11:30+00:00" > 11/09/26, 21:11 </span>

  6. Benni Mack commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-11-10T06:05:10+00:00" > 11/10/26, 06:05 </span>

    Applied in changeset commit:0d9a43f713f98999137f7d04d326bf5fe24cadde.

  7. Gerrit Code Review pushed patch set 2 for 14.3 to change 97494 status Resolved Under Review <span data-processor="relativetime" data-value="2026-11-10T06:24:42+00:00" > 11/10/26, 06:24 </span>

  8. Benni Mack commented and changed status Under Review Resolved <span data-processor="relativetime" data-value="2026-11-10T06:45:14+00:00" > 11/10/26, 06:45 </span>

    Applied in changeset commit:5aa4423355950612b94dcf9ae00dac7974e618a4.