Problem/Motivation

If you disable the SearchPage entity used for the default search, then this happens:

At that point, you can only access pages where no search block is placed. That means only pages using a different theme than the front end one. Which also means you cannot log in to your site anymore.

Steps to reproduce

Proposed resolution

Harden the code so this happens instead:

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new1.28 KB
wim leers’s picture

wim leers’s picture

StatusFileSize
new565 bytes
new1.31 KB
wim leers’s picture

Status: Needs review » Needs work

Patch explained, and next steps identified:

  1. +++ b/core/modules/search/src/Form/SearchBlockForm.php
    @@ -94,8 +95,19 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_i
    +    $search_page = SearchPage::load($entity_id);
    

    Technically this needs to be using the entity storage service for accessing the search page.

    It's a pity the SearchPageRepositoryInterface is only so partially solving the problems here.

  2. +++ b/core/modules/search/src/Form/SearchBlockForm.php
    @@ -94,8 +95,19 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_i
    +    $this->renderer->addCacheableDependency($form, $search_page);
    

    Yes … this has been wrong all along. This rendered form should be invalidated whenever the config entity it uses gets changed (e.g. from enabled to disabled or vice versa). That is not the case right now…

  3. +++ b/core/modules/search/src/Form/SearchBlockForm.php
    @@ -94,8 +95,19 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_i
    +    // Because the block config entity does not have a config dependency on the
    +    // search page it is configured to use, it may not exist.
    +    if (!$search_page->status()) {
    

    The real problem to fix here is the missing config dependency.

wim leers’s picture

andypost’s picture

In related there was big discussion about how confusing this kind of messages could be for end-user #3087218: Help searches fail if site is not fully indexed, and users do not know why

+++ b/core/modules/search/src/Form/SearchBlockForm.php
@@ -94,8 +95,19 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_i
+      $form['message'] = [
+        '#markup' => $this->t('Search is currently disabled'),

Personally I find it strange to see this message, maybe instead of it it could hide the block to prevent display "not accessible" feature to visitors

wim leers’s picture

Personally I find it strange to see this message, maybe instead of it it could hide the block to prevent display "not accessible" feature to visitors

I agree … but that's the pattern that already exists. Trying to minimize change here, and only fix the brokenness.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new715 bytes
new1.2 KB
+++ b/core/modules/search/src/Form/SearchBlockForm.php
@@ -94,8 +95,19 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_i
-    $route = 'search.view_' . $entity_id;
...
+    $form['#action'] = $search_page->toUrl()->toString();

Apparently the search.view_* routes are 100% independent of the SearchPage config entity. My bad. But … super weird that the critical functionality that these config entities offer is not accessible in the entity type's link templates 🙃

Status: Needs review » Needs work

The last submitted patch, 9: 3204343-9.patch, failed testing. View results

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wim leers’s picture

I truly have no clue why this would trigger this particular failure. 😔

wim leers’s picture

Issue tags: +migrate

Note that this adversely affects migrations too — because quite a few D7 sites have this disabled, and having that migrated over to D9 causes … well … the problem you can see in the screenshot in the issue summary!

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Status: Needs work » Postponed

The 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.

quietone’s picture

Project: Drupal core » Search (from core)
Version: main » 1.0.0
Component: search.module » Code
Status: Postponed » Needs work

The Search Module has moved from core to contrib,