diff --git a/core/modules/search/src/Plugin/SearchInterface.php b/core/modules/search/src/Plugin/SearchInterface.php index ab247b3..2eea586 100644 --- a/core/modules/search/src/Plugin/SearchInterface.php +++ b/core/modules/search/src/Plugin/SearchInterface.php @@ -94,8 +94,8 @@ public function execute(); * or an empty array if there are no results. * - cache_tags: An array that holds all the cache tags associated * with the items. - * - cache_contexts: (optional) An array which holds the contexts for the - * search page and all items in the items array. + * - cache_contexts: An array which holds the contexts for the search page + * and all items in the items array. */ public function buildResults(); diff --git a/core/modules/search/src/Plugin/SearchPluginBase.php b/core/modules/search/src/Plugin/SearchPluginBase.php index 425be87..8ebb8a4 100644 --- a/core/modules/search/src/Plugin/SearchPluginBase.php +++ b/core/modules/search/src/Plugin/SearchPluginBase.php @@ -111,12 +111,10 @@ public function buildResults() { '#plugin_id' => $this->getPluginId(), ); $built['cache_tags'] = Cache::mergeTags($built['cache_tags'], $result['cache_tags']); - if (isset($result['cache_contexts'])) { - $built['cache_contexts'] = Cache::mergeContexts( - $built['cache_contexts'], - $result['cache_contexts'] - ); - } + $built['cache_contexts'] = Cache::mergeContexts( + $built['cache_contexts'], + $result['cache_contexts'] + ); } return $built; diff --git a/core/modules/user/src/Plugin/Search/UserSearch.php b/core/modules/user/src/Plugin/Search/UserSearch.php index 0d2b46e..a842c1d 100644 --- a/core/modules/user/src/Plugin/Search/UserSearch.php +++ b/core/modules/user/src/Plugin/Search/UserSearch.php @@ -155,6 +155,8 @@ public function execute() { $result['title'] .= ' (' . $account->getEmail() . ')'; } $result['cache_tags'] = $account->getCacheTags(); + $result['cache_tags'][] = 'user:list'; + $result['cache_contexts'] = array(); $results[] = $result; }