Actions
Bug #104341
closedAdding new backend user setting of type select with numeric keys will result in TypeError
Status:
Closed
Priority:
Should have
Assignee:
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:- 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' );
Actions