Project

General

Profile

Actions

Bug #97088

closed

TypeError in EXT:core/Classes/Hooks/TcaItemsProcessorFunctions::populateExplicitAuthValues()

Added by Sabrina Hess over 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2022-03-03
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.0
Tags:
Complexity:
no-brainer
Is Regression:
Sprint Focus:

Description

EXT:core/Classes/Hooks/TcaItemsProcessorFunctions::populateExplicitAuthValues() can't handle integer types.

Steps to reproduce

1. Add an item to a column ($field) defined as $GLOBALS['TCA'][$table]['ctrl']['type'] having $GLOBALS['TCA'][$table]['columns'][$field]['config']['authMode'], e.g. a new CType '12345':

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
    'tt_content',
    'CType',
    [
        'Test item with numeric type',
        '12345',
        'actions-exclamation-triangle-alt'
    ]
);

2. Create or edit a backend user group ...

TypeError preg_replace(): Argument #3 ($subject) must be of type array|string, int given

Error Source

PHP casts keys containing valid decimal ints to INT.
Thus $itemValue passed to preg_replace() on Line 149 of TcaItemsProcessorFunctions.php could be an INT and must be cast to STRING.

                $fieldDefinition['items'][] = [
                    '[' . $allowDenyModeLabel . '] ' . $itemLabel,
                    $groupKey . ':' . preg_replace('/[:|,]/', '', $itemValue) . ':' . $allowDenyMode,
                    $icons[$allowDenyMode],
                ];

Easy Fix

-                    $groupKey . ':' . preg_replace('/[:|,]/', '', $itemValue) . ':' . $allowDenyMode,
+                    $groupKey . ':' . preg_replace('/[:|,]/', '', (string)$itemValue) . ':' . $allowDenyMode,
Actions #1

Updated by Gerrit Code Review over 2 years 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/+/73806

Actions #2

Updated by Gerrit Code Review over 2 years ago

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

Actions #3

Updated by Georg Ringer over 2 years ago

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

Updated by Benni Mack about 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF