Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.375
diff -u -p -r1.375 menu.inc
--- includes/menu.inc	14 Jan 2010 13:45:33 -0000	1.375
+++ includes/menu.inc	20 Jan 2010 01:26:15 -0000
@@ -2070,14 +2070,10 @@ function menu_set_active_trail($new_trai
     $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;
+      $found = db_query("SELECT menu_name FROM {menu_links} ml WHERE ml.link_path = :link_path AND ml.menu_name IN (:menu_names)", array(':link_path' => $item['href'], ':menu_names' => $menu_names))->fetchCol();
+      if (empty($found)) {
+        // If $item['href'] didn't work, try $item['path'].
+        $found = db_query("SELECT menu_name FROM {menu_links} ml WHERE ml.link_path = :link_path AND ml.menu_name IN (:menu_names)", array(':link_path' => $item['path'], ':menu_names' => $menu_names))->fetchCol();
       }
       // The $menu_names array is ordered, so take the first one that matches.
       $name = current(array_intersect($menu_names, $found));
