Project

General

Profile

Actions

Bug #65935

closed

Bug in ArrayUtility::mergeRecursiveWithOverrule

Added by Markus Hölzle over 9 years ago. Updated about 7 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2015-03-23
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:
Remote Sprint

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?

Actions

Also available in: Atom PDF