In token_node, a query has been changed to user db_query_range instead of LIMIT 0,1. The rewrite broke the query logic, resulting in query errors:
user warning: Unknown column 'r.vid' in 'where clause' query: SELECT t.tid, t.name FROM term_data t INNER JOIN term_node r ON r.tid = t.tid WHERE t.vid = 16 AND r.vid = 44780 ORDER BY weight LIMIT 0, 1 in /var/www/html/includes/database.mysql.inc on line 174.

The attached patche fixes this.

CommentFileSizeAuthor
#10 485346.patch1.52 KBfgm
token_node.inc_.patch849 bytesabautu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jadwigo’s picture

tested the fix .. works as advertised,

haven't tested the patch itself

Also related to http://drupal.org/node/485210

selfuntitled’s picture

Also tested the fix, no problems so far.

kingandy’s picture

Fix looks good to me.

I'm guessing this is the result of backporting a change from Drupal 6, where the term_node table does include the VID for revisions...

greggles’s picture

Status: Needs review » Fixed

Thanks all for the patch and reviews. This is now fixed http://drupal.org/cvs?commit=223518

I'll make a new release soon.

kardave’s picture

Hi,

I was too carefull, so i tried out some modules that use token. If not, I would break my production site. Thank God I have test site for this :)
Pathauto doesn't work correctly with Token 5.x-1.12 (token [vocab-raw] and [vocab] is empty at nodes)
You should aware users from using this version.

greggles’s picture

We could warn users about this or we could just make a new release :)

Anyone else know of other critical bugs in token?

kardave’s picture

I vote for new release. :)

greggles’s picture

http://drupal.org/node/488728 - will be published in ~5 minutes

Status: Fixed » Closed (fixed)

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

fgm’s picture

Version: 5.x-1.12 » 5.x-1.14
Status: Closed (fixed) » Needs review
FileSize
1.52 KB

Problem has apparently been reintroduced in 5.1.14:

user warning: Unknown column 'r.vid' in 'where clause' query: SELECT t.tid, t.name FROM term_data t INNER JOIN term_node r ON r.tid = t.tid WHERE t.vid = 1 AND r.vid = 15733 ORDER BY t.weight LIMIT 0, 1 in /var/www/drupal-5.22/includes/database.mysql.inc on line 174.

the query appears in token_node.inc#node_token_values(), line 98:

              $term = db_fetch_object(db_query_range("SELECT t.tid, t.name FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.vid = %d ORDER BY t.weight", $vid, $object->vid, 0, 1));

should likely be:

              $term = db_fetch_object(db_query_range("SELECT t.tid, t.name FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.nid = %d ORDER BY t.weight", $vid, $object->nid, 0, 1));
Dave Reid’s picture

It's been fixed already in 5.x-1.x-dev.

Dave Reid’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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