Review main Merged

96975[BUGFIX] Keep the choice of a select bound to a list

Benjamin Kott CR +2 V +2 Normal +139 −0 updated 10/22/26, 20:16

Commit message

A form.select without "multiple" whose current value is an array or an
ObjectStorage rendered a scalar name and submitted one uid. Extbase
mapped that to an empty ObjectStorage, so the choice was lost and
persisting removed all existing relations. The select now appends []
for such a value, as form.checkbox already does.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Matthias Vogel +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Matthias Vogel +1
    • core-ci +1 CI

Issues 1

Files 3

Review log 79

  1. Benjamin Kott uploaded patch set 1 10/21/26, 15:23

  2. core-ci voted on patch set 1 V +1 10/21/26, 15:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112013

  3. Oli Bartsch commented on patch set 1 V -1 10/21/26, 18:27

    SelectViewHelper.php:68

    detection is based on the current value, so forms without a form object or with a null collection still render a scalar name and lose the choice. Please reword the commit message and the RST to "whose current value is an array or `ObjectStorage`", so they don't promise more than the code does.

    SelectViewHelper.php:69

    please don't check for any `\Traversable`. On 14.3 the `LazyLoadingProxy` used for lazy 1:1/n:1 relations implements `\Iterator`, so a single-value select gets the name `[]` append. On submit this would throws an exception. This would be a regression for the most common select case. I suggest to match what the commit message says: `is_array($propertyValue) || $propertyValue instanceof ObjectStorage`. `LazyObjectStorage` extends `ObjectStorage`, so lazy collections stay covered. Excluding `LoadingStrategyInterface` instead would not work, as `LazyObjectStorage` implements it too.

    SelectViewHelperTest.php:739

    please add a test where a single-valued `\Traversable` property keeps the scalar name, as it would have caught the problem above. An empty `ObjectStorage` with `prependOptionLabel` (the setup from the issue) and a mapping test that `x[]=5` ends up as a populated `ObjectStorage` would also be good.
  4. Benjamin Kott uploaded patch set 2 V +1 10/22/26, 10:51

  5. Benjamin Kott commented on patch set 1 10/22/26, 10:51

    SelectViewHelper.php:68 Reply

    Agreed. Patch set 2 rewords the commit message and the RST to "whose current value is an array or ObjectStorage". The RST now also names the case of a form without an object or a null property, and that initializing the property with an empty ObjectStorage avoids it.

    SelectViewHelper.php:69 Reply

    Done in patch set 2: `is_array($propertyValue) || $propertyValue instanceof ObjectStorage`. Thanks, the test for a single-valued \Traversable fails on patch set 1 with the list name and trusted properties [1].

    SelectViewHelperTest.php:739 Reply

    Added both rendering tests in patch set 2: a single-valued \Traversable keeps the scalar name, and an empty ObjectStorage with prependOptionLabel renders the list name. I did not add a mapping test: mapping a [] list into an ObjectStorage is not changed by this patch and is already covered by BlogPostEditingControllerTest::fullyLocalizedFormSubmissionPersistsDataOfSelectedBlogForRequestedTranslation, which also notes that the scalar trusted property does not work. A round trip in the fluid test would need blog_example and a database in a test class that runs without one. Happy to add it if you think it is worth that.
  6. core-ci voted on patch set 2 V +1 10/22/26, 10:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112092

  7. Matthias Vogel voted on patch set 2 CR +1 V +1 10/22/26, 13:20

  8. Oli Bartsch commented on patch set 2 CR +2 V +2 10/22/26, 20:09

    SelectViewHelper.php:68 Reply

    Done

    SelectViewHelper.php:69 Reply

    Done

    SelectViewHelper.php:69 Reply

    Done

    SelectViewHelperTest.php:739 Reply

    Done
  9. Oli Bartsch merged patch set 3 10/22/26, 20:16