diff --git a/boost.module b/boost.module index 8e619a9f558f3470ae4984195bd34a47a35a53af..ed2a576d11fdf70f05c800c19725cf31a27c9730 100644 --- a/boost.module +++ b/boost.module @@ -347,10 +347,10 @@ function boost_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { // get terms and flush their page if (BOOST_FLUSH_NODE_TERMS) { - $terms = taxonomy_node_get_terms(node_load($node->nid)); + $tids = boost_taxonomy_node_get_tids($node->nid); $filenames = array(); - foreach($terms as $term) { - $filenames = array_merge($filenames, boost_get_db_term($term->tid)); + foreach($tids as $tid) { + $filenames = array_merge($filenames, boost_get_db_term($tid)); } foreach($filenames as $filename) { boost_cache_kill($filename); @@ -360,6 +360,22 @@ function boost_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { } } +/** + * Return taxonomy terms given a nid. + * + * Needed because of a weird bug with CCK & node_load() + * http://drupal.org/node/545922 + */ +function boost_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; +} + /** * Implementation of hook_taxonomy(). Acts on taxonomy changes. */