Project

General

Profile

Actions

Bug #90241

closed

ArrayUtility "array_key_exists() expects parameter 2 to be array"

Added by Daniel Siepmann almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Start date:
2020-01-29
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Inside \TYPO3\CMS\Core\Utility\ArrayUtility::getValueByPath() no type check is executed when working with array.
This can lead to the PHP warning "array_key_exists() expects parameter 2 to be array".
Example call causing the warning:

\TYPO3\CMS\Core\Utility\ArrayUtility::getValueByPath(
    [                  
        'foo' => [     
            'baz' => 42
        ],             
    ],                 
    'foo/baz/baz'
);

as during 2nd baz, the "array" is an integer.

The expected behaviour would be throw new MissingArrayPathException('Segment ' . $segment . ' of path ' . implode($delimiter, $path) . ' does not exist in array', 1341397869);, just like when the segment does not exist. As it does not exist.


Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #94378: PHP Warning: array_key_exists() expects parameter 2 to be array, null given in /var/www/public/typo3/sysext/core/Classes/Utility/ArrayUtility.php line 297Closed2021-06-18

Actions
Actions

Also available in: Atom PDF