diff -urpN drupal-7.x-dev.legacy/includes/menu.inc drupal-7.x-dev/includes/menu.inc --- drupal-7.x-dev.legacy/includes/menu.inc 2008-11-17 12:19:25.000000000 +0800 +++ drupal-7.x-dev/includes/menu.inc 2008-11-17 12:19:35.000000000 +0800 @@ -850,7 +850,7 @@ function menu_tree_all_data($menu_name = // If the tree data was not in the cache, $data will be NULL. if (!isset($data)) { // Build and run the query, and build the tree. - $query = db_select('menu_links', 'ml'); + $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC)); $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path'); $query->fields('ml'); $query->fields('m', array( @@ -885,7 +885,6 @@ function menu_tree_all_data($menu_name = } else { // Get all links in this menu. - $args = array(); $parents = array(); } // Select the links from the table, and recursively build the tree. We @@ -997,7 +996,7 @@ function menu_tree_page_data($menu_name // Collect all the links set to be expanded, and then add all of // their children to the list as well. do { - $result = db_select('menu_links') + $result = db_select('menu_links', NULL, array('fetch' => PDO::FETCH_ASSOC)) ->fields('menu_links', array('mlid')) ->condition('menu_name', $menu_name) ->condition('expanded', 1) @@ -1007,7 +1006,7 @@ function menu_tree_page_data($menu_name ->execute(); $num_rows = FALSE; foreach ($result as $item) { - $args[] = $item->mlid; + $args[] = $item['mlid']; $num_rows = TRUE; } } while ($num_rows); @@ -1021,7 +1020,7 @@ function menu_tree_page_data($menu_name // Select the links from the table, and recursively build the tree. We // LEFT JOIN since there is no match in {menu_router} for an external // link. - $query = db_select('menu_links', 'ml'); + $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC)); $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path'); $query->fields('ml'); $query->fields('m', array( @@ -1164,7 +1163,7 @@ function _menu_tree_data($result, $paren $remnant = NULL; $tree = array(); foreach ($result as $item) { - $item = (array) $item; + $item = is_object($item) ? get_object_vars($item) : $item; // We need to determine if we're on the path to root so we can later build // the correct active trail and breadcrumb. $item['in_active_trail'] = in_array($item['mlid'], $parents); @@ -1311,7 +1310,7 @@ function menu_get_names($reset = FALSE) ->distinct() ->fields('menu_links', 'menu_name') ->orderBy('menu_name') - ->execute()->fetchAll(); + ->execute()->fetchCol(); } return $names; } @@ -1922,7 +1921,7 @@ function _menu_navigation_links_rebuild( } } // Find any item whose router path does not exist any more. - $result = db_select('menu_links') + $result = db_select('menu_links', NULL, array('fetch' => PDO::FETCH_ASSOC)) ->fields('menu_links') ->condition('router_path', $paths, 'NOT IN') ->condition('external', 0) @@ -1932,7 +1931,7 @@ function _menu_navigation_links_rebuild( ->execute(); // Remove all such items. Starting from those with the greatest depth will // minimize the amount of re-parenting done by menu_link_delete(). - foreach ($result as $item) { + foreach ($result as $item) { _menu_delete_item($item, TRUE); } } @@ -1947,10 +1946,10 @@ function _menu_navigation_links_rebuild( */ function menu_link_delete($mlid, $path = NULL) { if (isset($mlid)) { - _menu_delete_item(db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $mlid))->fetchAssoc()); + _menu_delete_item(db_query("SELECT * FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $mlid), array('fetch' => PDO::FETCH_ASSOC))->fetchAssoc()); } else { - $result = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => $path)); + $result = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => $path), array('fetch' => PDO::FETCH_ASSOC)); foreach ($result as $link) { _menu_delete_item($link); } @@ -1966,7 +1965,6 @@ function menu_link_delete($mlid, $path = * Forces deletion. Internal use only, setting to TRUE is discouraged. */ function _menu_delete_item($item, $force = FALSE) { - $item = (array) $item; if ($item && ($item['module'] != 'system' || $item['updated'] || $force)) { // Children get re-attached to the item's parent. if ($item['has_children']) { @@ -2205,11 +2203,7 @@ function _menu_clear_page_cache() { * Helper function to update a list of menus with expanded items */ function _menu_set_expanded_menus() { - $names = array(); - $result = db_query("SELECT menu_name FROM {menu_links} WHERE expanded <> 0 GROUP BY menu_name"); - foreach ($result as $n) { - $names[] = $n->menu_name; - } + $names = db_query("SELECT menu_name FROM {menu_links} WHERE expanded <> 0 GROUP BY menu_name")->fetchCol(); variable_set('menu_expanded', $names); }