User warning: Unknown column 'n.type'

idiotech - December 22, 2008 - 19:13
Project:Drigg
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hi, thanks a lot for the module, I'm gonna have fun with this ;)
I installed Drigg manually over Drupal 6.8, following the procedure from drigg-code.org/pages/download_and_install.
When I go, as admin, in Administer - Taxonomy - List terms for Tags, I get this error:

user warning: Unknown column 'n.type' in 'where clause' query: SELECT count(*) FROM term_data t INNER JOIN term_hierarchy h ON t.tid = h.tid LEFT JOIN drigg_node dn2 ON dn2.dnid = n.nid WHERE ( 1=1 AND !(n.type='drigg' AND dn2.killed = 1 ) ) AND ( t.vid = 100) in /home/myuser/public_html/drigg/modules/taxonomy/taxonomy.admin.inc on line 282.

The problem seems to come from the file /modules/drigg/drigg/drigg.module :

$return['where'] .=  " AND !(n.type='drigg' AND dn2.killed = 1 ) ";
$return['join']  .= " LEFT JOIN {drigg_node} dn2 ON dn2.dnid = n.nid ";

The problem arises only for Tags (taxonomy/2). No problem with Category (taxonomy/1).

Any help would be appreciated. Thanks.

#1

mercmobily - December 23, 2008 - 03:32

Hi,

This is _strange_.
I have this in the rewrite:

<?php
 
// This will only filter node lists
 
if ($primary_table == 'n' && $primary_field == 'nid') {
?>

This means that the rewrite should really only happen when a query with a node is done.
At the same time, why would Drupal core make such a silly mistake?

Can you tell me which URL you are visiting precisely when you get this error?

I am looking for that query but I can't find it:

root@merc-laptop:/home/www/drupal/current_6# grep -il "SELECT count(*) FROM {term_data}" `find .`
root@merc-laptop:/home/www/drupal/current_6#

I am confused!

Merc.

#2

idiotech - December 23, 2008 - 16:55

The exact url where I get the error is: /admin/content/taxonomy/2
And the count(*) query is in taxonomy.admin.inc.

You know what, I think the drigg_db_rewrite_sql hook receives default values from database.inc :

function db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid',  $args = array())

Can you reproduce the problem ?

#3

mercmobily - December 24, 2008 - 10:35

Hi,

I must be going insane...
Sorry about being inept, but can you tell me where the query is in taxonomy.admin.inc ?

Merc.

#4

idiotech - December 24, 2008 - 18:17

Hehe, working during the holidays can be tough ;) No stress, the bug is not a show stopper.

It's in function "taxonomy_overview_terms", line 282. See the error message in my first post. I'm also running Drupal 6.8.. maybe they changed something recently.

A quick fix in the filter/rewrite (drigg_db_rewrite_sql) could be to check if we're in /admin using the $args parameter.

Merry Christmas :))
Eric

#5

mercmobily - January 12, 2009 - 19:20

Hi,

If you change that line into:

$total_entries = db_query(db_rewrite_sql('SELECT count(*) FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d','t','tid'), $page_increment, 0, NULL, $vocabulary->vid);

Does that fix the problem?
If the answer is "yes", you will need to report the problem to Drupal Core, since this is basically a Drupal Core bug (in the taxonomy module).

Bye,

Merc.

#6

mercmobily - June 2, 2009 - 15:52

Hi,

Can somebody confirm this problem with the latest Drupal?
Or has this gone away?

At the time, I suspected that it could possibly be a core problem...

Merc.

#7

ajayg - October 11, 2009 - 18:48
Status:active» reviewed & tested by the community

I confirm this problem no longer happens on drupal 6.14 and latest 6.x dev version of drigg. This can be closed.

#8

ajayg - November 1, 2009 - 22:08
Status:reviewed & tested by the community» fixed

#9

System Message - November 15, 2009 - 22:10
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.