It looks like og_vocab only needs to own its vocabularies in order to remove other groups' vocabularies from node forms. Looking at the Organic Groups code, the only thing that requires another module to own their vocabularies is when they want to implement hook_term_path, which og_vocab doesn't do.

Reason I ask is that I'd like to use og_vocab along with nodeorder, which implements hook_term_path.

Is there a way around this, or another reason why og_vocab sets the 'module' field in the vocabulary table?

Thanks,

Marc

CommentFileSizeAuthor
#5 og_vocab-2_0.diff964 bytesdmhouse
#1 og_vocab_vocabulary_patch.patch1.49 KBmarcp

Comments

marcp’s picture

StatusFileSize
new1.49 KB

Attached is a patch that keeps og_vocab from taking ownership of the vocabularies. There should be entries in the og_vocab table that make it unnecessary to set the vocabulary's module name.

Seems like I must be missing something?

marcp’s picture

Status: Active » Needs review

set to "code needs review"

moshe weitzman@drupal.org’s picture

Status: Needs review » Postponed (maintainer needs more info)

these are group specific vocabs and og_vocab module rightfully marks them as such. it sounds like hook_term_path() cares about all system controlled vocabs which sounds pretty dumb at first blush. could you elaborate where the conflict is exactly? i would rather not relinquish ownership of these vocabs. i have no specific reason for that - just principle.

marcp’s picture

Status: Postponed (maintainer needs more info) » Active

Yes, I agree that since these are group-specific vocabs, it makes sense for og_vocab to mark them as such.

hook_term_path() is the only hook called by taxonomy that targets a specific module, as opposed to allowing all modules to return something. taxonomy_term_path() is the only function that calls module_invoke:

function taxonomy_term_path($term) {
  $vocabulary = taxonomy_get_vocabulary($term->vid);
  if ($vocabulary->module != 'taxonomy' && $path = module_invoke($vocabulary->module, 'term_path', $term)) {
    return $path;
  }
  return 'taxonomy/term/'. $term->tid;
}

...and it's the only place where the 'module' field in the vocabulary table is used (by taxonomy.module).

Nodeorder implements hook_term_path() so that taxonomy terms, when gathered via phptemplate's call to $taxonomy = taxonomy_link('taxonomy terms', $node);, link to nodeorder/term/TID instead of taxonomy/term/TID.

There's a lot going on here:

  1. phptemplate.engine calls taxonomy_link directly with 'taxonomy terms' as the type. hook_link says only lists 'node' and 'comment' as possible values for type, which leads me to believe that this dependency between phptemplate.engine and taxonomy was meant as a short-term fix for something.
  2. og_vocab sets the module in its vocabularies, but doesn't take advantage of the one thing that taxonomy uses it for.
  3. taxonomy's method of calling hook_term_path is inconsistent with the rest of the hook calls that are made by the module. A possible solution for this would be to call module_invoke_all('term_path' ...) or something like it, and take the first or last returned value. In my case, where I want og_vocab and nodeorder to work together, this would just work out-of-the-box because og_vocab doesn't implement hook_term_path.

I think I can work around this by branching nodeorder, getting rid of my hook_term_path implementation, and, instead, implement hook_link_alter. I don't have a problem with this, if that's what you think is the best solution. It just seems like this is pointing out some minor inconsistencies in taxonomy's handling of generating term paths, and a possibly unnecessary dependency between phptemplate and taxonomy.

Thanks for taking the time to respond, Moshe.

Marc

dmhouse’s picture

StatusFileSize
new964 bytes

Just reported a duplicate of this bug, http://drupal.org/node/176371 (which I'm closing). My approach (attached) was similar to your patch, but didn't remove the first line of code, so that when you create vocabularies with OG Vocab, they still get a 'module' of 'og_vocab'. My code also swapped from a LEFT JOIN to an INNER JOIN. This should make sure that no rows in {vocabulary} without a row in {og_vocab} get returned. Technically we were okay with the LEFT JOIN, as we were also doing a 'WHERE ov.nid != %', and doing anything with a NULL value, even !=, is always NULL (if I recall correctly). However using an INNER JOIN is more appropriate.

moshe weitzman’s picture

Status: Active » Needs review
amitaibu’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
Category: support » bug
Status: Needs review » Active

I actually didn't handle this case - if one assigns a group via admin/taxonomy it's registered under 'taxonomy' not 'og_vocab'.

@Moshe,
Are you ok with registering everything under 'taxonomy' and use another the query to get all og_vocabs?

moshe weitzman’s picture

I have no particular opinion anymore. This is a half baked section of taxonomy module. If it makes life easier, i am OK with all vocabs being owned by taxonomy.

marcp’s picture

The only taxonomy code that cares about the module field in the vocabulary table is in taxonomy_term_path(). A quick search for taxonomy_term_path gives a decent sized list of issues related to this.

Seems like the new best way to deal with this is probably to call drupal_alter() when generating taxonomy links and get rid of the module field in the vocabulary table.

moshe weitzman’s picture

Taxonomy links on nodes are now added to $node->content and are currently alterable via nodeapi('alter') and even if that goes away (as i have proposed), once can add a #pre_render handler and adjust the links as needed.

amitaibu’s picture

Status: Active » Fixed

Vocabs now belong to 'taxonomy' - http://drupal.org/cvs?commit=160794

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.