diff --git a/core/modules/search/lib/Drupal/search/Controller/SearchController.php b/core/modules/search/lib/Drupal/search/Controller/SearchController.php
index 32a5c54..9966c52 100644
--- a/core/modules/search/lib/Drupal/search/Controller/SearchController.php
+++ b/core/modules/search/lib/Drupal/search/Controller/SearchController.php
@@ -69,8 +69,7 @@ public function view(Request $request, SearchPageInterface $entity, $keys = '')
$plugin = $entity->getPlugin();
$plugin->setSearch($keys, $request->query->all(), $request->attributes->all());
- // Default results output is an empty string.
- $results = array('#markup' => '');
+ $results = array();
// Process the search form. Note that if there is
// \Drupal::request()->request data, search_form_submit() will cause a
@@ -89,9 +88,11 @@ public function view(Request $request, SearchPageInterface $entity, $keys = '')
}
// The form may be altered based on whether the search was run.
$build['search_form'] = $this->entityManager()->getForm($entity, 'search');
- $build['search_results_title'] = array(
- '#markup' => '
' . $this->t('Search Results') . '
',
- );
+ if (count($results)) {
+ $build['search_results_title'] = array(
+ '#markup' => '' . $this->t('Search results') . '
',
+ );
+ }
$build['search_results'] = array(
'#theme' => array('item_list__search_results__' . $plugin->getPluginId(), 'item_list__search_results'),
@@ -104,7 +105,7 @@ public function view(Request $request, SearchPageInterface $entity, $keys = '')
'#attributes' => array(
'class' => array(
'search-results',
- $plugin->getPluginId() . '_search-results',
+ $plugin->getPluginId() . '-results',
),
),
);
diff --git a/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php b/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php
index 8aeb0ce..2ff0ad7 100644
--- a/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php
+++ b/core/modules/search/lib/Drupal/search/Plugin/SearchInterface.php
@@ -75,7 +75,9 @@ public function execute();
* Executes the search and builds render arrays for the result items.
*
* @return array
- * An array of search_result render arrays.
+ * An array of render arrays of search result items (generally each item
+ * has '#theme' set to 'search_result'), or an empty array if there are no
+ * results.
*/
public function buildResults();
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php
index 079e57c..13f5a8d 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchPreprocessLangcodeTest.php
@@ -87,7 +87,7 @@ function testPreprocessStemming() {
$this->drupalPostForm('search/node', $edit, t('Advanced search'));
// Check if the node has been found.
- $this->assertText('Search Results');
+ $this->assertText('Search results');
$this->assertText('we are testing');
// Search for the same node using a different query.
@@ -95,7 +95,7 @@ function testPreprocessStemming() {
$this->drupalPostForm('search/node', $edit, t('Advanced search'));
// Check if the node has been found.
- $this->assertText('Search Results');
+ $this->assertText('Search results');
$this->assertText('we are testing');
}
}