Issue Bug Closed

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

Daniel Siepmann 01/29/20, 12:58 updated 02/27/20, 12:43

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.

Reviews 3