Index: modules/search/search.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.pages.inc,v
retrieving revision 1.19
diff -u -r1.19 search.pages.inc
--- modules/search/search.pages.inc	1 May 2010 01:04:24 -0000	1.19
+++ modules/search/search.pages.inc	2 Jun 2010 22:41:59 -0000
@@ -25,6 +25,10 @@
     // Only perform search if there is non-whitespace search term:
     $results = '';
     if (trim($keys)) {
+      // Fix the menu active trail -- due to the non-standard menu setup for
+      // this page, menu_set_active_trail() fails if there are keywords.
+      _search_fix_menu_trail();
+
       // Log the search keys.
       $info = search_get_info();
       watchdog('search', 'Searched %type for %keys.', array('%keys' => $keys, '%type' => $info[$type]['title']), WATCHDOG_NOTICE, l(t('results'), 'search/' . $type . '/' . $keys));
@@ -47,6 +51,69 @@
 }
 
 /**
+ * Fixes the active trail for the search page with keywords.
+ *
+ * Due to the non-standard menu setup for hook_menu() in search_menu(),
+ * when there are keywords, the search page gets the wrong active trail.
+ * This function fixes the active trail.
+ */
+function _search_fix_menu_trail() {
+  // Follow what menu_get_active_trail() does, but knowing that the parent
+  // menu item we're looking for is path 'search'.
+  $trail = array();
+  $trail[] = array('title' => t('Home'), 'href' => '<front>', 'localized_options' => array(), 'type' => 0);
+
+  $item = menu_get_item('search');
+  $menu_names = menu_get_active_menu_names();
+
+  $curr = FALSE;
+  // Determine if the current page is a link in any of the active menus.
+  if ($menu_names) {
+    $query = db_select('menu_links', 'ml');
+    $query->fields('ml', array('menu_name'));
+    $query->condition('ml.link_path', $item['href']);
+    $query->condition('ml.menu_name', $menu_names, 'IN');
+    $result = $query->execute();
+    $found = array();
+    foreach ($result as $menu) {
+      $found[] = $menu->menu_name;
+    }
+    // The $menu_names array is ordered, so take the first one that matches.
+    $found_menu_names = array_intersect($menu_names, $found);
+    $name = current($found_menu_names);
+    if ($name !== FALSE) {
+      $tree = menu_tree_page_data($name);
+      list($key, $curr) = each($tree);
+    }
+  }
+
+  while ($curr) {
+    // Terminate the loop when we find the current path in the active trail.
+    if ($curr['link']['href'] == $item['href']) {
+      $trail[] = $curr['link'];
+      $curr = FALSE;
+    }
+    else {
+      // Add the link if it's in the active trail, then move to the link below.
+      if ($curr['link']['in_active_trail']) {
+        $trail[] = $curr['link'];
+        $tree = $curr['below'] ? $curr['below'] : array();
+      }
+      list($key, $curr) = each($tree);
+    }
+  }
+
+  // Make sure the current page is in the trail (needed for the page title),
+  // but exclude tabs and the front page.
+  $last = count($trail) - 1;
+  if ($trail[$last]['href'] != $item['href'] && !(bool) ($item['type'] & MENU_IS_LOCAL_TASK) && !drupal_is_front_page()) {
+    $trail[] = $item;
+  }
+
+  menu_set_active_trail($trail);
+}
+
+/**
  * Returns HTML for a listing of search results.
  *
  * @param $variables
Index: modules/search/search.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.test,v
retrieving revision 1.63
diff -u -r1.63 search.test
--- modules/search/search.test	12 May 2010 15:53:43 -0000	1.63
+++ modules/search/search.test	2 Jun 2010 22:41:59 -0000
@@ -236,13 +236,16 @@
   }
 }
 
-class SearchBikeShed extends DrupalWebTestCase {
+/**
+ * Tests the bike shed text on no results page, and text on the search page.
+ */
+class SearchPageText extends DrupalWebTestCase {
   protected $searching_user;
 
   public static function getInfo() {
     return array(
-      'name' => 'Bike shed',
-      'description' => 'Tests the bike shed text on the no results page.',
+      'name' => 'Search page text',
+      'description' => 'Tests the bike shed text on the no results page, and various other text on search pages.',
       'group' => 'Search'
     );
   }
@@ -251,18 +254,31 @@
     parent::setUp('search');
 
     // Create user.
-    $this->searching_user = $this->drupalCreateUser(array('search content'));
+    $this->searching_user = $this->drupalCreateUser(array('search content', 'access user profiles'));
   }
 
-  function testFailedSearch() {
+  /**
+   * Tests the failed search text, and various other text on the search page.
+   */
+  function testSearchText() {
     $this->drupalLogin($this->searching_user);
     $this->drupalGet('search/node');
     $this->assertText(t('Enter your keywords'));
+    $this->assertText(t('Search'));
+    $title = t('Search') . ' | Drupal';
+    $this->assertTitle($title, 'Search page title is correct');
 
     $edit = array();
     $edit['keys'] = 'bike shed ' . $this->randomName();
     $this->drupalPost('search/node', $edit, t('Search'));
     $this->assertText(t('Consider loosening your query with OR. bike OR shed will often show more results than bike shed.'), t('Help text is displayed when search returns no results.'));
+    $this->assertText(t('Search'));
+    $this->assertTitle($title, 'Search page title is correct');
+
+    $edit['keys'] = $this->searching_user->name;
+    $this->drupalPost('search/user', $edit, t('Search'));
+    $this->assertText(t('Search'));
+    $this->assertTitle($title, 'Search page title is correct');
   }
 }
 
