I tried to use your module, and I found some error: Some database tables are double prefixed.

Original taxonomy_csvterm.api.inv function taxonomy_csv_term_find()

function taxonomy_csv_term_find($term, $all_vocabularies = FALSE, $parent_tid = NULL) {
  if (isset($term->tid) && $term->tid) {
    $found_term = taxonomy_term_load($term->tid);
  }
  elseif (isset($term->name)) {
    $name = drupal_strtolower(trim($term->name));

    if (drupal_strlen($name)) {
      // Only term id is selected, because taxonomy_term_load is used next in
      // order to take advantage of taxonomy cache.
      $sql = "
        SELECT t.tid
        FROM {taxonomy_term_data} t
        INNER JOIN {taxonomy_term_hierarchy} h ON t.tid = h.tid
        WHERE :name LIKE LOWER(t.name)
      ";
      $args = array();
      $args[':name'] = $name;

      if (isset($term->vid)
          && $term->vid
          && !$all_vocabularies) {
        $sql .= ' AND {t.vid} = :vid';
        $args[':vid'] = $term->vid;
      }

      if ($parent_tid) {
        $sql .= ' AND {h.parent} = :parent';
        $args[':parent'] = $parent_tid;
      }

      $sql .= ' ORDER BY {t.tid} ASC LIMIT 1';

      $result = db_query($sql, $args);
      // Only zero or one result.
      foreach ($result as $item) {
        $found_term = taxonomy_term_load($item->tid);
      }
    }
  }

  // Complete and internal format term.
  if (isset($found_term)) {
    return taxonomy_csv_term_get_full($found_term);
  }

  // Not found, or error (neither tid nor name).
  return FALSE;
}

If you see, at 3 places, you wrote: {t.vid}, {h.parent}, {t.tid}. The correct function:

function taxonomy_csv_term_find($term, $all_vocabularies = FALSE, $parent_tid = NULL) {
  if (isset($term->tid) && $term->tid) {
    $found_term = taxonomy_term_load($term->tid);
  }
  elseif (isset($term->name)) {
    $name = drupal_strtolower(trim($term->name));

    if (drupal_strlen($name)) {
      // Only term id is selected, because taxonomy_term_load is used next in
      // order to take advantage of taxonomy cache.
      $sql = "
        SELECT t.tid
        FROM {taxonomy_term_data} t
        INNER JOIN {taxonomy_term_hierarchy} h ON t.tid = h.tid
        WHERE :name LIKE LOWER(t.name)
      ";
      $args = array();
      $args[':name'] = $name;

      if (isset($term->vid)
          && $term->vid
          && !$all_vocabularies) {
        $sql .= ' AND t.vid = :vid';
        $args[':vid'] = $term->vid;
      }

      if ($parent_tid) {
        $sql .= ' AND h.parent = :parent';
        $args[':parent'] = $parent_tid;
      }

      $sql .= ' ORDER BY t.tid ASC LIMIT 1';

      $result = db_query($sql, $args);
      // Only zero or one result.
      foreach ($result as $item) {
        $found_term = taxonomy_term_load($item->tid);
      }
    }
  }

  // Complete and internal format term.
  if (isset($found_term)) {
    return taxonomy_csv_term_get_full($found_term);
  }

  // Not found, or error (neither tid nor name).
  return FALSE;
}

Comments

Daniel_KM’s picture

Status: Active » Fixed

Hi,

Thanks for your patch. It has been committed and it will be included in next release.

Sincerely,

Daniel Berthereau
Knowledge manager

Status: Fixed » Closed (fixed)

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