in the "taxonomy_menu_node_presave($node)" function, the terms_old variable is not properly set. it should be the previous term set in the node, but actually, it's the new one, just because the $node var in the function is allready the new node.
A good way to fix it, it's just to load again the node from the database, with a simple node_load(). So the function could be :
/**
* Implementation of hook_node_presave().
*/
function taxonomy_menu_node_presave($node) {
$terms_old = &drupal_static('taxonomy_menu_terms_old');
//get the terms from the database before the changes are made.
//these will be used to update the menu item's name if needed
//we go directly to the db to bypass any caches
$node_old = node_load($node->nid);
$terms_old = _taxonomy_menu_get_node_terms($node_old);
}
Fix this function will fix menu not disappear in the menu_taxonomy tree after node update. If the term has no node, it actually stays in the menu, resulting of an empty taxonomy page (issue http://drupal.org/node/1403332).
Comments
Comment #1
VivienLetang commentedHere is the patch.
Comment #2
johnvThis patch works for me.
When a node was moved from term A to term B, the node count of term B is updated, but node count of term A stayed the same.
Comment #3
VivienLetang commentedSo it's a new issue i think. The first was "Fix this function will fix menu not disappear in the menu_taxonomy tree after node update." and the new one is that the count is not updated.
Don't really know where this count should be updated, but i will look at this this week.
Thanks
Comment #4
johnvVivienLetang,
in -dev version, you'll find the option 'count nodes of taxonomy term'. This shows e.g. "term1 (4)" for a term with 4 nodes.
Comment #5
barrett commentedI get an exception running the module's tests after applying the patch in comment 1 to the latest 7.x-1.x code base.
Comment #6
barrett commentedThe attached patch modifies the one posted in comment 1 to test that a $nid is set before trying to load a node with the matching nid. This corrects the exception reported when running the tests discussed in comment 5.
Comment #7
dstolhttp://drupalcode.org/project/taxonomy_menu.git/commit/71734ae
Comment #8
VivienLetang commentedthx and nice work ;)
Comment #10
johnvMarked the D6-version of this request #999858: parent menu items do not get synchronized as a duplicate.
Comment #10.0
johnvfix code tag