#65935Bug in ArrayUtility::mergeRecursiveWithOverrule
Description
Hello together,
I found a bug in ArrayUtility::mergeRecursiveWithOverrule while merging two arrays. If you merge this:
array(
'key1' => array(
'key2' => 'x'
)
)
with this:
array( 'key1' => 'y' )
I expect:
array( 'key1' => 'y' )
But I got:
array(
'key1' => array(
'key2' => 'x'
)
)
This is because there is a nested “if” without an “else”:
if (isset($original[$key]) && is_array($original[$key])) {
if (is_array($overrule[$key])) {
self::mergeRecursiveWithOverrule($original[$key], $overrule[$key], $addKeys, $includeEmptyValues, $enableUnsetFeature);
}
} elseif ...
this should be:
if (isset($original[$key]) && is_array($original[$key]) && is_array($overrule[$key])) {
self::mergeRecursiveWithOverrule($original[$key], $overrule[$key], $addKeys, $includeEmptyValues, $enableUnsetFeature);
} elseif ...
What do you think?
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.