Review main Abandoned

81646[BUGFIX] Fix rendering labels for radio and select field types

Marcin Sągol CR 0 V 0 Normal +63 −17 updated 12/09/23, 10:10

Commit message

With the release of TYPO3 12.3, changes were made that deprecated
indexed array keys for TCA items. Please see:

- https://forge.typo3.org/issues/99739
- deprecation: #99739 - Indexed array keys for TCA items

As a result of these changes, the function responsible for generating
labels for the values of the radio field in the column inside the
records list table returned an empty string when a (deprecated)
indexed array of items was used.

The second issue with the (`BackendUtility::getLabelFromItemlist`)
function was that it ignored the `itemsProcFunc` TCA configuration,
and items defined through a custom function were never used.

To address these issues, we now call the itemsProcFunc (if defined)
to handle items defined by such a custom function. To fetch item
labels respecting deprecated indexed item arrays, we use the method
from the core API `SelectItem::fromTcaItemArray()`, which respects
arrays with keys as well as indexed ones. With these changes, we also
pass the label through the `LanguageService` class to handle labels
with `LLL:...` values.

The reported issue mentioned columns with type `radio`, but a
similar problem existed for columns of type `select`, regarding
rendering their labels on the records list table. This problem was
addressed in the same manner.

Inside `TcaRadioItems` class it was also required to call the
`LanguageService::sl()` function to translate labels for items
which were added through the `itemsProcFunc`.

This changes have impact on the following areas, where
labels for select and radio fields might be rendered:

- records list
- record create/edit form
- record info window

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 5

Review log 1524

  1. Marcin Sągol uploaded patch set 1 11/02/23, 13:15

  2. Marcin Sągol updated the commit message in patch set 2 11/02/23, 13:19

  3. Marcin Sągol updated the commit message in patch set 3 11/02/23, 13:23

  4. Garvin Hicking commented on patch set 2 11/02/23, 13:23

    Good work on this, I only was able to read through it and not test it, so only two smaller comments at this point.

    BackendUtility.php:1282

    Maybe do a more strict check here with `?? null` to prevent warnings on undefined arrays?

    BackendUtility.php:1290

    Might need an array key check here, too - if older userFuncs that have not addapted to named array keys, this might throws errors then?
  5. Marcin Sągol updated the commit message in patch set 4 11/02/23, 13:24

  6. core-ci voted on patch set 1 V -1 11/02/23, 13:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48488

  7. core-ci voted on patch set 2 V -1 11/02/23, 13:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48490

  8. Marcin Sągol uploaded patch set 5 11/02/23, 13:33

  9. Marcin Sągol commented on patch set 5 11/02/23, 13:34

    BackendUtility.php:1282 Reply

    Check added.

    BackendUtility.php:1290 Reply

    I have change the code to operate on SelectItem object.
  10. core-ci voted on patch set 4 V -1 11/02/23, 13:41 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48492

  11. Marcin Sągol rebased onto patch set 6 11/02/23, 13:47

  12. core-ci voted on patch set 5 V -1 11/02/23, 14:13 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48494

  13. core-ci voted on patch set 6 V -1 11/02/23, 14:20 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48497

  14. Marcin Sągol uploaded patch set 7 V -1 11/02/23, 14:46

  15. core-ci voted on patch set 7 V -1 11/02/23, 15:00 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48503

  16. Marcin Sągol uploaded patch set 8 V -1 11/02/23, 16:19

  17. core-ci voted on patch set 8 V -1 11/02/23, 16:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48509

  18. Marcin Sągol uploaded patch set 9 V -1 11/08/23, 13:59

  19. Marcin Sągol updated the commit message in patch set 10 11/08/23, 14:03

  20. core-ci voted on patch set 9 V +1 11/08/23, 14:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48715

  21. Garvin Hicking commented on patch set 10 11/08/23, 14:33

    Thanks for the improvements/work. I couldn't yet test this "for real", but gave some thoughts, maybe those can help.

    BackendUtility.php:1277 Unresolved

    Is || required at this point? Because currently, if items='' but itemsProcFunc is set, it would actually not execute the itemsProcFunc to generate needed items. This also means that in the line below, you would need to check if $columnConfig['items'] is an array, after the itemsProcFunc execution.

    BackendUtility.php:1282 Reply

    Ack

    BackendUtility.php:1290 Reply

    Done

    BackendUtility.php:1346 Unresolved

    Adding a new function argument in the middle of a method would be a serious BC (Breaking Change). A new used field should be added to the end of the list, and get a default like `null`.

    BackendUtility.php:1398 Unresolved

    To reduce review overhead, if possible try to avoid inserting new lines if not needed - this one could maybe removed?

    BackendUtility.php:1589 Unresolved

    This looks like a good idea to me, but I'm not sure if that could maybe break some acceptance tests, did you maybe run the full `Build/Scripts/runTests -s acceptance` suite on this?

    BackendLayoutView.php:211 Unresolved

    Just a sidenote. $parameters is passed by run-time reference, I wonder if we should take the moment and typehint this parameter as reference already? Not 100% sure on the implications of this, though.
  22. core-ci voted on patch set 10 V +1 11/08/23, 15:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48717

  23. Christian Kuhn commented on patch set 10 12/09/23, 10:09

    Hey Marcin. Thanks for the patch! Unfortunately, this one has been superseded by https://review.typo3.org/c/Packages/TYPO3.CMS/+/82148, which is merged by now. I fear Oliver realized a bit too late there was a dupe of the issue and created an own patch. We try to avoid such situations, but this time, I fear all I can do is abandon this one now.
  24. Christian Kuhn abandoned the change 12/09/23, 10:10