When you have document types with partially the same name (e.g. 'project' and 'projectinfo') the function taxonomy_get_vocabularies() in taxonomy.module returns the wrong vocabulary. I see this happening in 4.3.0 and also within the the current cvs version.

The reason why this is happening is because the required vocabulary is found by using a LIKE statement. Because it's currently a comma-separated list and I have always multiple document types attached to the defined vocabularies I have added a 'comma'-string to the string which is used in the SQL query, but I don't think this is the best solution for this problem.

// return array of vocabularies, as objects
function taxonomy_get_vocabularies($type = '', $key = "vid") {
  if ($type) {
    $result = db_query("SELECT * FROM {vocabulary} WHERE nodes LIKE '%%%s%%' ORDER BY weight, name", $type . ",");
  }
  else {
    $result = db_query("SELECT * FROM {vocabulary} ORDER BY weight, name");
  }
  $vocabularies = array();
  while ($voc = db_fetch_object($result)) {
    $vocabularies[$voc->$key] = $voc;
  }

  return $vocabularies;
}

Comments

jonbob’s picture

This also affects taxonomy_node_form().

See also http://drupal.org/node/view/6847

killes@www.drop.org’s picture