Commit ed614b8a authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #767104 by mgriego, EugenMayer, mkalkbrenner: taxonomy_node_save()...

Issue #767104 by mgriego, EugenMayer, mkalkbrenner: taxonomy_node_save() should refresh the node terms (especially for free tagging vocabularies) when nodes are updated, so they are kept up to date in the same HTTP request
parent 628c91d9
......@@ -629,9 +629,13 @@ function taxonomy_node_get_terms_by_vocabulary($node, $vid, $key = 'tid') {
/**
* Find all terms associated with the given node, ordered by vocabulary and term weight.
*/
function taxonomy_node_get_terms($node, $key = 'tid') {
function taxonomy_node_get_terms($node, $key = 'tid', $reset = FALSE) {
static $terms;
if ($reset) {
unset($terms[$node->vid]);
}
if (!isset($terms[$node->vid][$key])) {
$result = db_query(db_rewrite_sql('SELECT t.* 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'), $node->vid);
$terms[$node->vid][$key] = array();
......@@ -664,7 +668,7 @@ function taxonomy_node_validate(&$node) {
/**
* Save term associations for a given node.
*/
function taxonomy_node_save($node, $terms) {
function taxonomy_node_save(&$node, $terms) {
taxonomy_node_delete_revision($node);
......@@ -721,6 +725,9 @@ function taxonomy_node_save($node, $terms) {
}
}
}
// Flush the term "cache" for this node
$node->taxonomy = taxonomy_node_get_terms($node, 'tid', TRUE);
}
/**
......@@ -1240,7 +1247,7 @@ function taxonomy_render_nodes($result) {
/**
* Implementation of hook_nodeapi().
*/
function taxonomy_nodeapi($node, $op, $arg = 0) {
function taxonomy_nodeapi(&$node, $op, $arg = 0) {
switch ($op) {
case 'load':
$output['taxonomy'] = taxonomy_node_get_terms($node);
......
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