Bug #32984

ArrayMergeRecursiveOverrule does not override arrays with simple types

Added by Sebastian Kurfuerst almost 10 years ago. Updated almost 10 years ago.

Status:
Resolved
Priority:
Must have
Category:
Utility
Start date:
2012-01-05
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
Yes
Complexity:

Description

While working on some improvements for the Configuration subsystem, I stumbled over the following issue in arrayMergeRecursiveOverrule:

If the first element contains an array, and the second element contains a simple type at a certain position, the ORIGINAL array is used. I think that's a bug, preventing to reset arrays in configuration.

The following test demonstrates this:

'inputArray1' => array(
    'k1' => 'v1',
    'k2' => array(
        'k2.1' => 'v2.1'
    ),
),
'inputArray2' => array(
    'k2' => 'v2a',
    'k3' => 'v3'
),
// That's what SHOULD happen IMHO
'expected' => array(
    'k1' => 'v1',
    'k2' => 'v2a',
    'k3' => 'v3'
)
// That's what happens currently
'actual' => array(
    'k1' => 'v1',
    'k2' => array(
        'k2.1' => 'v2.1'
    ),
    'k3' => 'v3'
)

This has drastical implications on configuration handling, as it makes it impossible to override an array with NULL:

// per-package settings.yaml
Foo:
  Bar:
    Baz: value

// global settings.yaml
Foo:
  Bar: NULL

// Expected:
array('Foo' => array('Bar' => NULL))

// Actual (right now)
array('Foo' => array('Bar' => array('Baz' => 'value')))
#1

Updated by Sebastian Kurfuerst almost 10 years ago

  • Target version set to 1.1
  • Has patch changed from No to Yes
#2

Updated by Sebastian Kurfuerst almost 10 years ago

  • Subject changed from ArrayMergeRecursiveOverrule does not override arrays with string values to ArrayMergeRecursiveOverrule does not override arrays with simple types
#3

Updated by Gerrit Code Review almost 10 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7676

#4

Updated by Gerrit Code Review almost 10 years ago

Patch set 1 for branch FLOW3-1.0 has been pushed to the review server.
It is available at http://review.typo3.org/7716

#5

Updated by Sebastian Kurfuerst almost 10 years ago

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

Also available in: Atom PDF