Incompatibility with Revision changes

molenick - July 9, 2008 - 23:09
Project:Taxonomy Menu
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

When a user creates the first node to be associated with a new taxonomy term, it does not create the associated menu item if it's left unpublished and then published by another user.

For example, say I have vocab called "Organizations" with terms "Org A", "Org B", "Org C", etc. I have a CCK type setup called "Org_Data" which requires that a term from the Organizations vocab be associated with it.

Ensure "Hide Empty Terms" is checked in the settings for "Organizations".

1) Create a node of type Org_Data. Title this node "myOrg C" and associate it with term "Org C". Submit it without publishing.
2) Publish the data (with the current user or by logging in as another).
3) Notice that no menu item for "Org C" has been created in the menu under "Organizations."

If you repeat steps 1-3 but publish at the time of original submission, all should work fine.

The only workaround I've found for this so far is to enter into Administer>>Menu after publishing, which somehow magically creates the menu for "Org C".

#1

arlinsandbulte - October 31, 2009 - 22:35
Status:active» postponed (maintainer needs more info)

Is this still valid????

#2

pounard - December 4, 2009 - 12:14

Still valid, got the same bug, in 2.3 version:

array_unique usage check if new terms are attach, but when we publish a node, we do not attach new terms, we just change node state, so the function does not do tis job.

Wrong asumption, array_unique just remove dups.

Also, you do not check if not is published at all (as I see) I might be wrong here, so you might leave an activated menu item without any node published. => Still true I think.

EDIT: remove wrong stuff.

#3

pounard - December 4, 2009 - 12:25

There is an incompatibility with revisioning module which does not fire the hook_nodeapi() hook, this cause taxonomy_menu implementation not to be called.

EDIT: it seems that taxonomy_menu does it job (except I did not see if it checks if node is published or not). To be sure that taxonomy_menu and revisioning work together, people have to implement their own hook_revisioning() implementation and manually call taxonomy_menu hook_nodeapi() with the correct arguments.

Worst than that, it does not run a hook, it only does fire an trigger on which site admin should add actions.

#4

indytechcook - December 4, 2009 - 12:58
Title:New term does not display in menu when created by one user and published by another with Hide Empty Terms on.» Incompatibility with Revision changes
Version:5.x-1.03» 6.x-2.x-dev
Status:postponed (maintainer needs more info)» active

Here is the function used to grab the node count. It does look for published only. Let me see what I can think for this.

<?php
/**
* Count the number of published nodes classified by a term.
*
* @param $tid
*   The term's ID
*
* @param $type
*   The $node->type. If given, taxonomy_term_count_nodes only counts
*   nodes of $type that are classified with the term $tid.
*
* @return int
*   An integer representing a number of nodes.
*   Results are statically cached.
*/
function taxonomy_term_count_nodes($tid, $type = 0) {
  static
$count;

  if (!isset(
$count[$type])) {
   
// $type == 0 always evaluates TRUE if $type is a string
   
if (is_numeric($type)) {
     
$result = db_query(db_rewrite_sql('SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 GROUP BY t.tid'));
    }
    else {
     
$result = db_query(db_rewrite_sql("SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND n.type = '%s' GROUP BY t.tid"), $type);
    }
   
$count[$type] = array();
    while (
$term = db_fetch_object($result)) {
     
$count[$type][$term->tid] = $term->c;
    }
  }
 
$children_count = 0;
  foreach (
_taxonomy_term_children($tid) as $c) {
   
$children_count += taxonomy_term_count_nodes($c, $type);
  }
  return
$children_count + (isset($count[$type][$tid]) ? $count[$type][$tid] : 0);
}
?>

#5

pounard - December 4, 2009 - 18:17

Thanks, did not found it while browsing the code on current stable version. So it's all OK for me there is no bug, the only remaining is the lack of integration with revisioning module, which is due its weird behavior.

 
 

Drupal is a registered trademark of Dries Buytaert.