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' );
Updated by Gerrit Code Review 4 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
Updated by Gerrit Code Review 4 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
Updated by Daniel Siepmann 4 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset fc34492ba2f6d7ddb8cf589b07d38f4d7e57993e.
Actions