Issue Bug Closed

#106747Site Settings of type stringlist not saved by Settings Editor

Michael Neumann 05/22/25, 08:00 updated 12/02/25, 13:59

Description

*Description:*
When attempting to save site settings of type stringlist via the Settings Editor in the TYPO3 backend, the values are not stored. This occurs because the validation logic expects an array, while the input provided is a JSON-encoded string. As a result, the data is considered invalid and the save process is aborted.

Steps to Reproduce:
  1. Define a site setting of type stringlist .
  2. Open the Settings Editor in the TYPO3 backend.
  3. Input a list of strings (e.g., ["foo", "bar"] ) as a JSON-encoded string.
  4. Save the settings.
  5. Observe that the values are not saved.

*Expected Behavior:*
The Settings Editor should accept a valid JSON string for stringlist types, decode it, and save it as an array.

*Actual Behavior:*
The JSON-encoded string fails validation because an array is expected directly.

*Possible Fix:*
Update the validation logic to detect if the provided value is a JSON-encoded string and convert it to an array before validation. This could be implemented similar to the existing logic in the transformValue function.

public function validate(mixed $value, SettingDefinition $definition): bool
{
    // Check if given value is a json-encoded string
    if (is_string($value)) {
        // A json-encoded stringlist only needs 2-levels
        $depth = 2;
        try {
            $value = json_decode($value, false, 2, JSON_THROW_ON_ERROR);
        } catch (\JsonException) {
            return false;
        }
    }
    if (!is_array($value)) {
        return false;
    }
    return $this->doValidate(new StringType($this->logger), $value, $definition);
}

Reviews 2

History 37

  1. Gerrit Code Review pushed patch set 1 for main to change 89517 status New Under Review 05/23/25, 11:45

  2. Garvin Hicking commented and changed priority Should have Must have 05/23/25, 11:46

    Thanks for the report, I was able to reproduce this and tried to implement your patch suggestion. Can you have a look if that works for you? I tried to streamline the method to avoid redundancy.

  3. Gerrit Code Review pushed patch set 2 for main to change 89517 05/23/25, 12:03

  4. Gerrit Code Review pushed patch set 3 for main to change 89517 05/23/25, 12:21

  5. Gerrit Code Review pushed patch set 1 for 13.4 to change 89555 05/27/25, 06:06

  6. Garvin Hicking commented and changed status Under Review Resolved done 0 % 100 % 05/27/25, 06:35

    Applied in changeset commit:dbc6dae4de85ede66b129df16eb6dfbe6c2328a1.

  7. Benni Mack changed status Resolved Closed 12/02/25, 13:59