Commit daa26f79 authored by Dries's avatar Dries
Browse files

- Patch #536768 by chx: use the database to do type casting so we can clean up some code. ;-)

parent e66d0b75
...@@ -865,7 +865,7 @@ function menu_tree_all_data($menu_name, $item = NULL) { ...@@ -865,7 +865,7 @@ function menu_tree_all_data($menu_name, $item = NULL) {
// If the tree data was not in the cache, $data will be NULL. // If the tree data was not in the cache, $data will be NULL.
if (!isset($data)) { if (!isset($data)) {
// Build and run the query, and build the tree. // 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->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
$query->fields('ml'); $query->fields('ml');
$query->fields('m', array( $query->fields('m', array(
...@@ -1035,7 +1035,7 @@ function menu_tree_page_data($menu_name) { ...@@ -1035,7 +1035,7 @@ function menu_tree_page_data($menu_name) {
// Select the links from the table, and recursively build the tree. We // 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 // LEFT JOIN since there is no match in {menu_router} for an external
// link. // 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->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
$query->fields('ml'); $query->fields('ml');
$query->fields('m', array( $query->fields('m', array(
...@@ -1188,7 +1188,6 @@ function _menu_tree_data($result, $parents, $depth, $previous_element = '') { ...@@ -1188,7 +1188,6 @@ function _menu_tree_data($result, $parents, $depth, $previous_element = '') {
$remnant = NULL; $remnant = NULL;
$tree = array(); $tree = array();
foreach ($result as $item) { foreach ($result as $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 // We need to determine if we're on the path to root so we can later build
// the correct active trail and breadcrumb. // the correct active trail and breadcrumb.
$item['in_active_trail'] = in_array($item['mlid'], $parents); $item['in_active_trail'] = in_array($item['mlid'], $parents);
......
...@@ -1177,7 +1177,7 @@ function book_menu_subtree_data($item) { ...@@ -1177,7 +1177,7 @@ function book_menu_subtree_data($item) {
// If the subtree data was not in the cache, $data will be NULL. // If the subtree data was not in the cache, $data will be NULL.
if (!isset($data)) { if (!isset($data)) {
$query = db_select('menu_links', 'ml'); $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
$menu_router_alias = $query->join('menu_router', 'm', 'm.path = ml.router_path'); $menu_router_alias = $query->join('menu_router', 'm', 'm.path = ml.router_path');
$book_alias = $query->join('book', 'b', 'ml.mlid = b.mlid'); $book_alias = $query->join('book', 'b', 'ml.mlid = b.mlid');
$query->fields($book_alias); $query->fields($book_alias);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment