#104341Adding new backend user setting of type select with numeric keys will result in TypeError
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:- Add new custom setting for backend users with integer keys
- 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'
);Reviews 2
History 24
-
Gerrit Code Review pushed patch set 1 for main to change 85190 status
NewUnder Review 07/10/24, 05:53 -
Gerrit Code Review pushed patch set 1 for 12.4 to change 85194 07/10/24, 08:04
-
Daniel Siepmann commented and changed status
Under ReviewResolved done0 %100 % 07/10/24, 08:10 -
Benni Mack changed status
ResolvedClosed 10/15/24, 09:29
Applied in changeset commit:fc34492ba2f6d7ddb8cf589b07d38f4d7e57993e.