In 4.7 RC2 and RC3, I created a vocabulary to support free tagging.
I created a node and typed in my new tag and received an error. In the error code provided, I used a non-free tagging term and the new one "Common Japanese Difficulties" which, as you can see, is not working.

I guess the text:
AND td.tid IN (45,Common Japanese Difficulties)
should either be a number or in quotes.

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Japanese Difficulties) AND th.tid IS NULL' at line 1 query: SELECT DISTINCT td.tid FROM term_data td LEFT JOIN term_hierarchy th on td.tid = th.parent WHERE td.vid IN (1) AND td.tid IN (45,Common Japanese Difficulties) AND th.tid IS NULL in C:\server\drupal\www\includes\database.mysql.inc on line 120.

Here is the referenced code plus some line numbers on the left...

/**
 * Helper function for db_query().
 */
93: function _db_query($query, $debug = 0) {
  global $active_db, $queries;

  if (variable_get('dev_query', 0)) {
    list($usec, $sec) = explode(' ', microtime());
    $timer = (float)$usec + (float)$sec;
  }

101:  $result = mysql_query($query, $active_db);

  if (variable_get('dev_query', 0)) {
    $bt = debug_backtrace();
    $query = $bt[2]['function'] . "\n" . $query;
    list($usec, $sec) = explode(' ', microtime());
    $stop = (float)$usec + (float)$sec;
    $diff = $stop - $timer;
    $queries[] = array($query, $diff);
  }

  if ($debug) {
    print '<p>query: '. $query .'<br />error:'. mysql_error($active_db) .'</p>';
  }

  if (!mysql_errno($active_db)) {
    return $result;
  }
  else {
120:    trigger_error(check_plain(mysql_error($active_db) ."\nquery: ". $query), E_USER_WARNING);
    return FALSE;
  }
}

any advice?

CommentFileSizeAuthor
#4 tac_free_tag_support.patch2.88 KBmyriad
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

myriad’s picture

yup, if I disable Free Tagging than there is no error when updating a node. However, once Free Tagging is enabled, I get the error after updating a node.

I haven't noticed anything not working.

killes@www.drop.org’s picture

The query you encounter errors with does not seem to be defined in Drupal core. Do you use any contrib modules? Please move this issue to them.

myriad’s picture

Project: Drupal core » Taxonomy Access Control Lite
Version: 4.7.0-rc3 » 7.x-1.x-dev
Component: taxonomy.module » Code

That's right, it is the result of a contrib. After disabling TAC_LITE the problem disappeared. I'll submit a request there, thank you!

myriad’s picture

Assigned: Unassigned » myriad
Status: Active » Needs review
FileSize
2.88 KB

After looking through the source I found the function that needs to be updated, _tac_lite_get_terms(&$node). The author was already aware that free tagging wasn't supported. The comments said the code was borrowed from taxonomy.module, and so I did the same. I added free tagging support and now I don't see any errors with my changes.

Dave Cohen’s picture

Assigned: myriad » Dave Cohen
Status: Needs review » Fixed

I do not like the patch provided because it contains code that belongs in taxonomy.module, not tac_lite. (In fact the code is in taxonomy.module). Instead, I checked in this.

This avoids the error when saving a node with free-tagging. However, we still do not use the free tagging terms for access control. We could, if taxonomy stored the tids that it created for us to see, but it does not. However, this is no big deal, as noone in their right mind will use a free-tagging vocabulary for access control. The reason being that every new tag they type will not have any access control privileges configured, and would therefor be hidden from all users. Who would want that?

Thanks for submitting bug and patch.

Anonymous’s picture

Status: Fixed » Closed (fixed)
bablakely’s picture

Dave, I disagree with #5. I have a site where I have a free tagging environment, but where I have pre-entered a tag of "Public", which I want to use to make nodes viewable by anonymous users. I currently cannot do this, and this is a deal-breaker for me.

bablakely’s picture

Version: 7.x-1.x-dev » 6.x-1.5
Category: bug » feature
Status: Closed (fixed) » Active

Reopening pending further discussion.

Dave Cohen’s picture

Why not put the "Public" term in another, non-free tagging vocabulary?

  • Dave Cohen committed 36a01bf on 8.x-1.x
    Eliminate an error when free-tagging is used.  #60450