Commit b2b8aeaa authored by catch's avatar catch

Issue #2750167 by dawehner, alexpott, willwh: Config translation synchronization fails

parent 408330ad
......@@ -95,7 +95,10 @@ protected function filterNestedArray(array $original_data, array &$override_data
elseif (is_array($override_data[$key])) {
if (is_array($original_data[$key])) {
// Do the filtering one level deeper.
$changed = $this->filterNestedArray($original_data[$key], $override_data[$key]);
// Ensure that we track $changed along the way.
if ($this->filterNestedArray($original_data[$key], $override_data[$key])) {
$changed = TRUE;
}
// If no overrides are left under this level, remove the level.
if (empty($override_data[$key])) {
unset($override_data[$key]);
......
<?php
namespace Drupal\Tests\Core\Config;
use Drupal\Core\Config\ConfigCollectionInfo;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigFactoryOverrideBase;
use Drupal\Core\Config\ConfigRenameEvent;
/**
* @coversDefaultClass \Drupal\Core\Config\ConfigFactoryOverrideBase
* @group config
*/
class ConfigFactoryOverrideBaseTest extends \PHPUnit_Framework_TestCase {
/**
* @dataProvider providerTestFilterNestedArray
*/
public function testFilterNestedArray(array $original_data, array $override_data_before, array $override_data_after, $changed) {
$config_factory = new TestConfigFactoryOverrideBase();
$result = $config_factory->doFilterNestedArray($original_data, $override_data_before);
$this->assertEquals($changed, $result);
$this->assertEquals($override_data_after, $override_data_before);
}
public function providerTestFilterNestedArray() {
$data = [];
$data['empty'] = [
[],
[],
[],
FALSE,
];
$data['one-level-no-change'] = [
['key' => 'value'],
[],
[],
FALSE,
];
$data['one-level-override-no-change'] = [
['key' => 'value'],
['key' => 'value2'],
['key' => 'value2'],
FALSE,
];
$data['one-level-override-change'] = [
['key' => 'value'],
['key2' => 'value2'],
[],
TRUE,
];
$data['one-level-multiple-override-change'] = [
['key' => 'value', 'key2' => 'value2'],
['key2' => 'value2', 'key3' => 'value3'],
['key2' => 'value2'],
TRUE,
];
$data['multiple-level-multiple-override-change'] = [
['key' => ['key' => 'value'], 'key2' => ['key' => 'value']],
['key' => ['key2' => 'value2'], 'key2' => ['key' => 'value']],
['key2' => ['key' => 'value']],
TRUE,
];
$data['original-scalar-array-override'] = [
['key' => 'value'],
['key' => ['value1', 'value2']],
[],
TRUE,
];
return $data;
}
}
class TestConfigFactoryOverrideBase extends ConfigFactoryOverrideBase {
public function doFilterNestedArray(array $original_data, array &$override_data) {
return $this->filterNestedArray($original_data, $override_data);
}
public function addCollections(ConfigCollectionInfo $collection_info) {
}
public function onConfigSave(ConfigCrudEvent $event) {
}
public function onConfigDelete(ConfigCrudEvent $event) {
}
public function onConfigRename(ConfigRenameEvent $event) {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment