diff --git a/expire.module b/expire.module index cfb5893..f518d83 100644 --- a/expire.module +++ b/expire.module @@ -332,7 +332,7 @@ function expire_node(&$node) { // Get menu and flush related items in the menu. if (variable_get('expire_flush_menu_items', EXPIRE_FLUSH_MENU_ITEMS) !=0) { if (!isset($node->menu['menu_name'])) { - menu_nodeapi($node, 'prepare'); + menu_node_prepare($node); } $menu = menu_tree_all_data($node->menu['menu_name']); $tempa = NULL; @@ -490,13 +490,19 @@ function expire_get_menu_structure($menu, $found, $needle, $first, &$found_globa * http://drupal.org/node/545922 */ function expire_taxonomy_node_get_tids($nid) { - $vid = db_result(db_query("SELECT vid FROM {node} WHERE nid = %d", $nid)); - $result = db_query(db_rewrite_sql("SELECT t.tid FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.vid = %d ORDER BY v.weight, t.weight, t.name", 't', 'tid'), $vid); - $tids = array(); - while ($term = db_result($result)) { - $tids[] = $term; - } - return $tids; + // based on http://drupal.org/node/959984 + $query = db_select('taxonomy_index', 'r'); + $t_alias = $query->join('taxonomy_term_data', 't', 'r.tid = t.tid'); + $v_alias = $query->join('taxonomy_vocabulary', 'v', 't.vid = v.vid'); + $query->fields( $t_alias ); + $query->condition("r.nid", $nid); + $result = $query->execute(); + + $terms = array(); + foreach ($result as $term) { + $terms[] = $term; + } + return $terms; } /** @@ -606,8 +612,8 @@ function expire_path_redirect_load($where = array(), $args = array(), $sort = ar $sql .= ' ORDER BY '. implode(' ,', $sort); } $result = db_query($sql, $args); - while ($redirect = db_fetch_array($result)) { - $redirects[] = $redirect; + foreach ($result as $redirect) { + $redirects[] = (array)$redirect; } return $redirects; } @@ -687,14 +693,14 @@ function expire_get_domains(&$node) { $domains = array(); if ($node->nid) { $result = db_query("SELECT gid FROM {domain_access} WHERE nid = %d", $node->nid); - while ($row = db_fetch_array($result)) { + foreach ($result as $row) { $gid = $row['gid']; $domains[$gid] = $gid; } } elseif ($node->mail && $node->name) { $result = db_query("SELECT domain_id FROM {domain_editor} WHERE uid = %d", $node->uid); - while ($row = db_fetch_array($result)) { + foreach ($result as $row) { $gid = $row['domain_id']; $domains[$gid] = $gid; } @@ -703,10 +709,29 @@ function expire_get_domains(&$node) { } function expire_normal_path_check($path) { +return; $original_map = arg(NULL, $path); $parts = array_slice($original_map, 0, MENU_MAX_PARTS); list($ancestors, $placeholders) = menu_get_ancestors($parts); - $router_item = db_fetch_array(db_query_range('SELECT path FROM {menu_router} WHERE path IN (' . implode(',', $placeholders) . ') ORDER BY fit DESC', $ancestors, 0, 1)); - return $router_item; + $result = db_query_range('SELECT path FROM {menu_router} WHERE path IN (' . implode(',', $placeholders) . ') ORDER BY fit DESC', $ancestors, 0, 1); + $router_item = array_shift($result); + return (array)$router_item; } + +function taxonomy_node_get_terms($node, $key = 'tid') { + static $terms; + if (!isset($terms[$node->vid][$key])) { + $query = db_select('taxonomy_index', 'r'); + $t_alias = $query->join('taxonomy_term_data', 't', 'r.tid = t.tid'); + $v_alias = $query->join('taxonomy_vocabulary', 'v', 't.vid = v.vid'); + $query->fields( $t_alias ); + $query->condition("r.nid", $node->nid); + $result = $query->execute(); + $terms[$node->vid][$key] = array(); + foreach ($result as $term) { + $terms[$node->vid][$key][$term->$key] = $term; + } + } + return $terms[$node->vid][$key]; +} \ No newline at end of file