From 62dc0bc471ecf8b38df70de366f99c4b5a644bc8 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 27 Dec 2021 13:57:02 +0000 Subject: [PATCH] Issue #3092430 by quietone, shrutidkadam, RdeBoer, bgprior, danflanagan8: Ensure SearchPlugin has a configuration array (cherry picked from commit 331e284ef00b1f907cdbe023f042c4a81b784ce5) --- core/modules/search/migrations/d7_search_page.yml | 3 +++ core/modules/search/migrations/search_page.yml | 3 +++ .../Kernel/Migrate/d6/MigrateSearchPageTest.php | 14 ++++++++++++++ .../Kernel/Migrate/d7/MigrateSearchPageTest.php | 13 +++++++++++++ 4 files changed, 33 insertions(+) diff --git a/core/modules/search/migrations/d7_search_page.yml b/core/modules/search/migrations/d7_search_page.yml index 033bd409d62..cb30ed13470 100644 --- a/core/modules/search/migrations/d7_search_page.yml +++ b/core/modules/search/migrations/d7_search_page.yml @@ -41,6 +41,9 @@ process: - module - 'constants/suffix' path: module + configuration: + plugin: default_value + default_value: [ ] 'configuration/rankings': plugin: search_configuration_rankings destination: diff --git a/core/modules/search/migrations/search_page.yml b/core/modules/search/migrations/search_page.yml index 2847a191ff4..9ab1858c40a 100644 --- a/core/modules/search/migrations/search_page.yml +++ b/core/modules/search/migrations/search_page.yml @@ -21,6 +21,9 @@ process: id: 'constants/id' path: 'constants/path' plugin: 'constants/plugin' + configuration: + plugin: default_value + default_value: [ ] 'configuration/rankings': plugin: search_configuration_rankings destination: diff --git a/core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php b/core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php index 1321943b5e1..e98da3bac60 100644 --- a/core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php +++ b/core/modules/search/tests/src/Kernel/Migrate/d6/MigrateSearchPageTest.php @@ -60,6 +60,20 @@ class MigrateSearchPageTest extends MigrateDrupal6TestBase { $configuration = SearchPage::load($id)->getPlugin()->getConfiguration(); $this->assertSame(4, $configuration['rankings']['comments']); + + // Test that a configurable search without a configuration imports. Do this + // by removing the node rankings from the source database. + Database::getConnection('default', 'migrate') + ->delete('variable') + ->condition('name', 'node_rank_%', 'LIKE') + ->execute(); + + $migration = $this->getMigration('search_page'); + $migration->getIdMap()->prepareUpdate(); + $this->executeMigration($migration); + + $configuration = SearchPage::load($id)->getPlugin()->getConfiguration(); + $this->assertSame([], $configuration['rankings']); } } diff --git a/core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php b/core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php index d3e8ee38ea9..8d353e0a76e 100644 --- a/core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php +++ b/core/modules/search/tests/src/Kernel/Migrate/d7/MigrateSearchPageTest.php @@ -79,6 +79,19 @@ class MigrateSearchPageTest extends MigrateDrupal7TestBase { $this->executeMigration($migration); $configuration['rankings']['comments'] = 4; $this->assertEntity('node_search', 'node', TRUE, $configuration); + + // Test that a configurable search without a configuration imports. Do this + // by removing the node rankings from the source database. + Database::getConnection('default', 'migrate') + ->delete('variable') + ->condition('name', 'node_rank_%', 'LIKE') + ->execute(); + + $migration = $this->getMigration('d7_search_page'); + $migration->getIdMap()->prepareUpdate(); + $this->executeMigration($migration); + $configuration = ['rankings' => []]; + $this->assertEntity('node_search', 'node', TRUE, $configuration); } /**