Bug #90241

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

Added by Daniel Siepmann 9 months ago. Updated 8 months ago.

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

100%

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.

Associated revisions

Revision ae685ef9 (diff)
Added by Daniel Siepmann 9 months ago

[BUGFIX] Avoid PHP warning in ArrayUtility::getValueByPath()

Children of $array in ArrayUtility::getValueByPath() may contain other
datatypes than array, therefore check the datatype by is_array()
before calling array_key_exists() in order to avoid a PHP warning.

Resolves: #90241
Releases: master, 9.5, 8.7
Change-Id: Ibde8f854a28a0aef68ed33ed172299cb4e1ff2ca
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63066
Reviewed-by: Stephan GroƟberndt <>
Reviewed-by: Oliver Klee <>
Reviewed-by: Markus Klein <>
Reviewed-by: Benjamin Franzke <>
Tested-by: TYPO3com <>
Tested-by: Markus Klein <>
Tested-by: Benjamin Franzke <>

Revision 31383526 (diff)
Added by Daniel Siepmann 9 months ago

[BUGFIX] Avoid PHP warning in ArrayUtility::getValueByPath()

Children of $array in ArrayUtility::getValueByPath() may contain other
datatypes than array, therefore check the datatype by is_array()
before calling array_key_exists() in order to avoid a PHP warning.

Resolves: #90241
Releases: master, 9.5, 8.7
Change-Id: Ibde8f854a28a0aef68ed33ed172299cb4e1ff2ca
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62983
Tested-by: TYPO3com <>
Tested-by: Benjamin Franzke <>
Reviewed-by: Benjamin Franzke <>

Revision ddbc5af9 (diff)
Added by Daniel Siepmann 9 months ago

[BUGFIX] Avoid PHP warning in ArrayUtility::getValueByPath()

Children of $array in ArrayUtility::getValueByPath() may contain other
datatypes than array, therefore check the datatype by is_array()
before calling array_key_exists() in order to avoid a PHP warning.

Resolves: #90241
Releases: master, 9.5, 8.7
Change-Id: Ibde8f854a28a0aef68ed33ed172299cb4e1ff2ca
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62984
Tested-by: TYPO3com <>
Tested-by: Benjamin Franzke <>
Reviewed-by: Oliver Klee <>
Reviewed-by: Benjamin Franzke <>

History

#1 Updated by Gerrit Code Review 9 months ago

  • Status changed from New to Under Review

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

#2 Updated by Gerrit Code Review 9 months ago

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

#3 Updated by Gerrit Code Review 9 months ago

Patch set 1 for branch 9.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/+/62983

#4 Updated by Gerrit Code Review 9 months ago

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

#5 Updated by Daniel Siepmann 9 months ago

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

#6 Updated by Benni Mack 8 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF