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

Also available in: Atom PDF