Project

General

Profile

Actions

Bug #104341

closed

Adding new backend user setting of type select with numeric keys will result in TypeError

Added by Daniel Siepmann 5 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Should have
Category:
Backend User Interface
Target version:
-
Start date:
2024-07-10
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Error from 12.4:

(1/1) TypeError

htmlspecialchars(): Argument #1 ($string) must be of type string, int given
in /vendor/typo3/cms-setup/Classes/Controller/SetupModuleController.php line 489

        $html = '<select id="field_' . htmlspecialchars($fieldName) . '" 
            name="data' . $dataAdd . '[' . htmlspecialchars($fieldName) . ']"' .
            $more . '>' . LF;
        foreach ($config['items'] as $key => $optionLabel) {
            $html .= '<option value="' . htmlspecialchars($key) . '"' . ($value == $key ? ' selected="selected"' : '') . '>' . $this->getLabel($optionLabel, '', false) . '</option>' . LF;
        }
        $html .= '</select>';
    }
    break;

According to https://www.php.net/manual/en/language.types.array.php valid decimal ints will be casted to ints. It therefore is not possible to add integer values as strings.

This can be tested via:
  1. Add new custom setting for backend users with integer keys
  2. Go to the backend user settings

An example setup could look like this within ext_tables.php:

$GLOBALS['TYPO3_USER_SETTINGS']['columns']['defaultPreviewType'] = [
    'label' => 'defaultPreviewType',
    'type' => 'select',
    'items' => [
        '0' => 'defaultPreviewType.0',
        '50' => 'defaultPreviewType.50',
        '60' => 'defaultPreviewType.60',
    ],
];

TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToUserSettings(
    'defaultPreviewType',
    'after:copyLevels'
);

Actions #1

Updated by Gerrit Code Review 5 months ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/85190

Actions #2

Updated by Gerrit Code Review 5 months ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/85194

Actions #3

Updated by Daniel Siepmann 5 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #4

Updated by Benni Mack about 1 month ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF