From ddfcac8d2758c3a7e4ece1b10775e1bb82acfc66 Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Tue, 17 Sep 2019 10:53:33 +0100 Subject: [PATCH] Issue #3012001 by quietone, rkostov, ellenoise: Duplications within migration process plugin --- core/modules/migrate/src/Plugin/Migration.php | 2 +- .../MigrationPluginConfigurationTest.php | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/core/modules/migrate/src/Plugin/Migration.php b/core/modules/migrate/src/Plugin/Migration.php index 7b1e6769cafe..c7d21b22ecac 100644 --- a/core/modules/migrate/src/Plugin/Migration.php +++ b/core/modules/migrate/src/Plugin/Migration.php @@ -278,7 +278,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition $this->destinationPluginManager = $destination_plugin_manager; $this->idMapPluginManager = $idmap_plugin_manager; - foreach (NestedArray::mergeDeep($plugin_definition, $configuration) as $key => $value) { + foreach (NestedArray::mergeDeepArray([$plugin_definition, $configuration], TRUE) as $key => $value) { $this->$key = $value; } } diff --git a/core/modules/migrate/tests/src/Kernel/Plugin/MigrationPluginConfigurationTest.php b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationPluginConfigurationTest.php index 827af91ee61a..56cc1f3acbf5 100644 --- a/core/modules/migrate/tests/src/Kernel/Plugin/MigrationPluginConfigurationTest.php +++ b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationPluginConfigurationTest.php @@ -20,6 +20,7 @@ class MigrationPluginConfigurationTest extends KernelTestBase { 'migrate_drupal', // Test with a simple migration. 'ban', + 'locale', ]; /** @@ -27,9 +28,10 @@ class MigrationPluginConfigurationTest extends KernelTestBase { * * @dataProvider mergeProvider */ - public function testConfigurationMerge($configuration, $expected) { + public function testConfigurationMerge($id, $configuration, $expected) { /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */ - $migration = $this->container->get('plugin.manager.migration')->createInstance('d7_blocked_ips', $configuration); + $migration = $this->container->get('plugin.manager.migration') + ->createInstance($id, $configuration); $source_configuration = $migration->getSourceConfiguration(); $this->assertEquals($expected, $source_configuration); } @@ -42,6 +44,7 @@ public function mergeProvider() { // Tests adding new configuration to a migration. [ // New configuration. + 'd7_blocked_ips', [ 'source' => [ 'constants' => [ @@ -60,6 +63,7 @@ public function mergeProvider() { // Tests overriding pre-existing configuration in a migration. [ // New configuration. + 'd7_blocked_ips', [ 'source' => [ 'plugin' => 'a_different_plugin', @@ -70,6 +74,29 @@ public function mergeProvider() { 'plugin' => 'a_different_plugin', ], ], + // New configuration. + [ + 'locale_settings', + [ + 'source' => [ + 'plugin' => 'variable', + 'variables' => [ + 'locale_cache_strings', + 'locale_js_directory', + ], + 'source_module' => 'locale', + ], + ], + // Expected final source and process configuration. + [ + 'plugin' => 'variable', + 'variables' => [ + 'locale_cache_strings', + 'locale_js_directory', + ], + 'source_module' => 'locale', + ], + ], ]; } -- GitLab