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.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 2901590-nr-bot.txt | 143 bytes | needs-review-queue-bot |
| #7 | 2901590-7.patch | 1.98 KB | andypost |
| #2 | 2901590-2.patch | 724 bytes | wim leers |
Comments
Comment #2
wim leersIdeally, this patch would simply pass. But it won't.
I spent some time investigating this, but due to time constraints I had to stop. I didn't find the root cause yet.
Comment #6
andypostJust caught the issue with route rebuild when working on #2664830-186: Add search capability to help topics
But it is not reproducible on current core,
TLDR after search page enabled the render of table trying to render link to search results page but the router is not yet rebuild
Comment #7
andypostNot sure this is a right place to rebuild routes... because
- default search could change via config import - help_topics module found too many ways to depect code changes
- the default search page's config could be disabled #3086846: Deprecate ability to disable search pages (no reason for it and causes problems and code complexity)
- there's missed config dependency #3086824: SearchBlock plugins need to add in dependencies on the search page they submit to
Comment #9
andypostThe same failed test + one more from test hack
Comment #14
andypostComment #15
andypostComment #19
needs-review-queue-bot commentedThe 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.
Comment #22
quietone commentedThe Search Module was approved for removal in #3476883: [Policy, no patch] Move Search module to contrib .
This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
The deprecation work is in #3565780: [meta] Tasks to deprecate the Search module and the removal work in #3565783: [meta] Tasks to remove the Search module.
Search will be moved to a contributed project before Drupal 12.0.0 is released.