Review main Merged

93540[BUGFIX] Handle non-scalar site settings in detail view

Michael Blunck CR +2 V +2 Easy +12 −1 updated 04/13/26, 15:02

Commit message

The new site settings detail view in the backend crashes when
rendering settings of type 'stringlist'. This happens because
the Fluid template attempts to output the setting value directly,
which results in a "Cannot cast an array to string" exception
when an array is provided.

To resolve this, a new method `getRenderedValue()` is added to the
`EditableSetting` DTO. This method acts as a presenter by
normalizing various data types (arrays, scalars) into
a string representation suitable for the UI.

While `getValueAsScalar()` was considered as a name,
`getRenderedValue()` was chosen instead to better reflect its
purpose for the presentation layer. It ensures that complex types
like arrays are flattened (e.g., via implode) before being
rendered, while maintaining the standard string representation for
scalars.

The Fluid template is updated to use `{setting.renderedValue}` to
leverage this safe string conversion, preventing crashes and
ensuring consistent output.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
    • Benni Mack +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 3

Files 2

Review log 1217

  1. Michael Blunck uploaded patch set 1 04/04/26, 08:49

  2. core-ci voted on patch set 1 V -1 04/04/26, 08:59 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/99601

  3. Garvin Hicking commented on patch set 1 04/04/26, 09:10

    How do you feel about this as an alternative: ``` diff --git a/typo3/sysext/backend/Classes/Dto/Settings/EditableSetting.php b/typo3/sysext/backend/Classes/Dto/Settings/EditableSetting.php index 1059956500b..481ca98523f 100644 --- a/typo3/sysext/backend/Classes/Dto/Settings/EditableSetting.php +++ b/typo3/sysext/backend/Classes/Dto/Settings/EditableSetting.php @@ -17,6 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Backend\Dto\Settings; +use Stringable; use TYPO3\CMS\Core\Settings\SettingDefinition; /** @@ -35,4 +36,17 @@ final readonly class EditableSetting implements \JsonSerializable { return get_object_vars($this); } + + public function getValueAsScalar(): string + { + if (is_array($this->value)) { + return implode(', ', $this->value); + } + if (is_scalar($this->value)) { + return (string)$this->value; + } + if ($this->value instanceof Stringable) { + return $this->value->__toString(); + } + } } diff --git a/typo3/sysext/backend/Resources/Private/Templates/SiteConfiguration/Detail.fluid.html b/typo3/sysext/backend/Resources/Private/Templates/SiteConfiguration/Detail.fluid.html index 41c309456bc..89fc1c274b8 100644 --- a/typo3/sysext/backend/Resources/Private/Templates/SiteConfiguration/Detail.fluid.html +++ b/typo3/sysext/backend/Resources/Private/Templates/SiteConfiguration/Detail.fluid.html @@ -518,7 +518,7 @@ </span> <span class="treelist-operator">=</span> <span class="treelist-value"> - {setting.value} + {setting.valueAsScalar} </span> </span> </li> ```
  4. Garvin Hicking updated the commit message in patch set 2 V -1 04/04/26, 09:13

  5. core-ci voted on patch set 2 V -1 04/04/26, 09:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/99603

  6. Stefan Bürk commented on patch set 2 04/13/26, 00:30

    Reply

    @garvin@hick.ing TBH I would abstain from extending and handling that in the class. Not tried or tested this change out yet, but having a string feeling that this **should** (**could**) be handled in fluid only by making use of the `f:join` ViewHelper with his options - which should be pretty much a use-case here for that ViewHelper. See: https://docs.typo3.org/other/typo3/view-helper-reference/main/en-us/Global/Join.html with a single if-else viewhelper combination (not a switch) for now. What do you think ? @garvin@hick.ing @mi.blunck@gmail.com
  7. core-ci commented on patch set 2 04/13/26, 00:31 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/99603

  8. Garvin Hicking commented on patch set 2 04/13/26, 06:47

    Reply

    I find the fluid solution not good - for me, logic like this does not belong in the presentation side but PHP. I also think the DTO is quite lightweight and the right fit for this sinole abstraction. We definitely need this in LTS so we need to find a solution quickly.
  9. Garvin Hicking uploaded patch set 3 V -1 04/13/26, 11:43

  10. Garvin Hicking uploaded patch set 4 04/13/26, 11:45

  11. core-ci voted on patch set 4 V +1 04/13/26, 11:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100077

  12. Garvin Hicking commented on patch set 4 CR +1 V +1 04/13/26, 12:03

    Reply

    I updated this patch with the alternate approach that was accidentally created (https://review.typo3.org/c/Packages/TYPO3.CMS/+/93547). For me this variant would be quite lightweight and easy to understand/read.
  13. core-ci voted on patch set 3 V -1 04/13/26, 12:20 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100076

  14. Benni Mack commented on patch set 4 CR +1 04/13/26, 13:38

    I'm fine adding it like this, it's a DTO marked as "internal"
  15. Garvin Hicking commented on patch set 4 04/13/26, 15:00

    Reply

    Done
  16. Georg Ringer voted on patch set 4 CR +2 V +2 04/13/26, 15:02

  17. Georg Ringer merged patch set 5 04/13/26, 15:02