Investigate route rebuilding problem wrt Search module

Created on 11 August 2017, about 7 years ago
Updated 30 January 2023, over 1 year ago

Problem/Motivation

https://www.drupal.org/SA-2017-001 β†’ (commit: http://cgit.drupalcode.org/drupal/commit/?id=7b55855) introduced changes to SearchConfigSettingsFormTest::testSearchModuleDisabling() wrt route rebuilding. But it shouldn't have needed those changes.

See http://cgit.drupalcode.org/drupal/diff/core/modules/search/src/Tests/Sea.... The problematic hunk is this one:

diff --git a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
index b5021d9..191e0cf 100644
--- a/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
+++ b/core/modules/search/src/Tests/SearchConfigSettingsFormTest.php
@@ -154,8 +154,7 @@ public function testSearchModuleDisabling() {
 
     // Test each plugin if it's enabled as the only search plugin.
     foreach ($entities as $entity_id => $entity) {
-      // Set this as default.
-      $this->drupalGet("admin/config/search/pages/manage/$entity_id/set-default");
+      $this->setDefaultThroughUi($entity_id);
 
       // Run a search from the correct search URL.
       $info = $plugin_info[$entity_id];
@@ -187,13 +186,16 @@ public function testSearchModuleDisabling() {
       $entity->disable()->save();
     }
 
+    // Set the node search as default.
+    $this->setDefaultThroughUi('node_search');
+
     // Test with all search plugins enabled. When you go to the search
     // page or run search, all plugins should be shown.
     foreach ($entities as $entity) {
       $entity->enable()->save();
     }
-    // Set the node search as default.
-    $this->drupalGet('admin/config/search/pages/manage/node_search/set-default');
+
+    \Drupal::service('router.builder')->rebuild();
 
     $paths = [
       ['path' => 'search/node', 'options' => ['query' => ['keys' => 'pizza']]],

That change at the very end shouldn't be necessary.

Quoting @Berdir (who introduced this change to be able to get a security fix committed, without diving into this out-of-scope problem):

The route rebuild doesn't happen anymore when enabling the search pages again. postSave() adds a rebuildIfNeeded() but then I think we need to do that manually. I also moved the default below enabling them, which is what previously probably rebuilt them. But when I do that now, then I get an error about an undefined route, so it already happens there then.

Due to the nature of the bug+work-around, this is NOT just cleaning up a test, this is reproducible on regular Drupal 8 sites too!

Proposed resolution

TBD

Remaining tasks

Investigate.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ“Œ Task
Status

Needs work

Version

10.1 ✨

Component
SearchΒ  β†’

Last updated 1 day ago

  • Maintained by
  • πŸ‡ΊπŸ‡ΈUnited States @pwolanin
Created by

πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

Production build 0.71.5 2024