core/modules/node/src/Plugin/Search/NodeSearch.php | 5 +++++ core/modules/search/src/Controller/SearchController.php | 3 +++ core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php | 1 + 3 files changed, 9 insertions(+) diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php index ecd6e86..8956dd9 100644 --- a/core/modules/node/src/Plugin/Search/NodeSearch.php +++ b/core/modules/node/src/Plugin/Search/NodeSearch.php @@ -518,6 +518,11 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) { '#attributes' => array('class' => array('search-advanced')), '#access' => $this->account && $this->account->hasPermission('use advanced search'), '#open' => $used_advanced, + '#cache' => [ + 'contexts' => [ + 'url.query_args', + ], + ], ); $form['advanced']['keywords-fieldset'] = array( '#type' => 'fieldset', diff --git a/core/modules/search/src/Controller/SearchController.php b/core/modules/search/src/Controller/SearchController.php index 4d839d1..9cb364e 100644 --- a/core/modules/search/src/Controller/SearchController.php +++ b/core/modules/search/src/Controller/SearchController.php @@ -73,6 +73,9 @@ public function view(Request $request, SearchPageInterface $entity) { $build = array(); $plugin = $entity->getPlugin(); + // @todo Remove once https://www.drupal.org/node/2464409 lands. + $build['#cache']['max-age'] = 0; + // Build the form first, because it may redirect during the submit, // and we don't want to build the results based on last time's request. $build['#cache']['contexts'][] = 'url.query_args:keys'; diff --git a/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php b/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php index 3650a93..278718c 100644 --- a/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php +++ b/core/modules/search/src/Tests/SearchAdvancedSearchFormTest.php @@ -59,6 +59,7 @@ function testNodeType() { // Search for the title of the node with a POST query. $edit = array('or' => $this->node->label()); $this->drupalPostForm('search/node', $edit, t('Advanced search')); + $this->assertCacheContext('url.query_args'); $this->assertText($this->node->label(), 'Basic page node is found with POST query.'); // Search by node type.