After updating taxonomy_image 5.x-1.0 to 5.x-1.1 the log of the updated website was flooded with several errors like this:
Unknown column 'term_node.name' in 'field list' query: SELECT DISTINCT(node.nid), node.sticky AS node_sticky, node.created AS node_created, node.title AS node_title, node.changed AS node_changed, term_node.name AS term_node_name FROM dp5_node node LEFT JOIN dp5_term_node term_node ON node.nid = term_node.nid LEFT JOIN dp5_term_hierarchy term_hierarchy ON term_node.tid = term_hierarchy.tid WHERE (node.status = '1') AND (term_node.tid = '582') ORDER BY node_sticky DESC, node_created DESC LIMIT 0, 30 [...]
Note: "dp5_" is my database prefix.
There are many similar errors in the log with the same starting text "Unknown Column 'term_node.name' in 'field list'" but different queries.
After a rollback to Version 5.x-1.0 of taxonomy_image all errors disappeared. Is there any fix available to correct this errors?
Bye, Uwe Mindrup
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | taxonomy_images_shown_in_view.jpg | 156.51 KB | uwe mindrup |
Comments
Comment #1
nancydruVery strange indeed. TI does not access the term_node table at all and does nothing that I know of that would cause a module (like access control) to alter the queries. We don't even use db_rewrite_sql to allow such modules to stick their fingers in. This query looks like it has been modified by an access control module (TAC, TAC_Lite, Node Access, etc.). And it looks like it's accessing a node; TI does not do node access of any kind.
I'm guessing you have some other module that is accessing nodes (perhaps just the front page query in node.module) that is also invoking Taxonomy Image. If you can identify which one it is, I'll be happy to work with the owner of that module to find out why this is happening. But I doubt it is Taxonomy Image at fault.
Comment #2
uwe mindrup commentedThank you for your very fast answer. I also was very surprised to see the described errors. Because I can reproduce the errors both on a local testsite and another, completely different site by only updating/downgrading of TI, I hope to find the underlying cause of this over the coming weekend.
Comment #3
nancydruI know there are other people using 5.x-1.1 beside myself, so this problem surprises me. I'd like to get a handle on it so it can be fixed.
Comment #4
uwe mindrup commentedAfter some debugging sessions I found out: the erroneous SQL-statement shown in my first text appears in the function 'pager_query' and this is called within the views module. Therefore it seems the errors appear only on views with enabled Pager.
The problem can be reduced to the new function 'taxonomy_image_views_tables' in the taxonomy_image module. It is called via hook 'views_tables'. When I disable the function (eg. commenting it out), then all errors disappeared (after clearing all caches, specially views cache).
I'm not fully understanding what this function "taxonomy_image_views_tables" should do. So I can't figure out what goes wrong here.
The deleting of the function seems safe to me - my sites are working without this function perfectly (as with the version 5.x-1.0 of TI before).
Comment #5
nancydruI've alerted the person who contributed this code since I am not a Views heavy-weight.
Comment #6
konsumer commentedBasically, taxonomy_image_views_tables is the function that adds view support for taxonomy_image:
You can read more about it here:
http://drupal.org/handbook/modules/views/api
and more specifically (fields, as that is all the function adds):
http://drupal.org/node/99565
The error appears to be showing that it's not using your prefix table, "dp5_" though (in term_node.name.) The table function just tells views module what to query, it doesn't actually do the querying itself. I wonder if the calling function (in views) forgot a {} in the query, or maybe the format for the fields has changed in the table array?
In looking a my term_node table, I don't see a "name" field anyway, though, so maybe it's something else.
I'm afraid I don't have the time to troubleshoot this issue further, right now, but hopefully this will help you get started.
Comment #7
uwe mindrup commentedThank you for your helpful hints.
I'm using a copy of the standard view 'taxonomy_term' that I have completed with three additional fields:
When calling
first the values for the three fields above are generated. Important: the third field 'Taxonomy: All Terms' generates a table entry named 'term_node' with serveral subentries.
Then every hook 'views_tables' is called and their values are merged together. Unfortunately the hook 'taxonomy_image_views_tables' overwrites some parts of the existing 'term_node' (array_merge in module_invoke_all). Now the data of 'term_node' is inconsistent and causes the errors shown.
Futhermore: when I'm now looking into a view definition, the entry 'Taxonomy: All Terms' isn't shown anymore in the 'Add Field'-selectbox and all views with taxonomy fields are broken.
When I delete/comment out the 'term_node' entry from the 'taxonomy_image_views_tables' all (my) problems has been gone. I don't see the necessity of the entry.
Comment #8
konsumer commentedI could be wrong (I think I'd have to really take a closer look at that bit) but I think that is what connects the taxonomy_image reference to the node, so it seems kind of essential to the views working correctly.
Do the views work as expected with that bit taken out (correct taxonomy images attached to the right nodes)?
I'm guessing you mean this part (in taxonomy_image_views_tables):
If I remember correctly, I needed to add both of these to get the JOIN working correctly, but if testing shows that it's not needed (and actually causes problems) then we should totally take it out, or figure out a better way to handle it.
Comment #9
uwe mindrup commentedI made a little test and added a fourth field 'Taxonomy Image: Image' to a view like the described above. The code
has been commented out. And look at File attachment: the taxonomy images were shown. To avoid doubled entries, I had to add the 'disctinct' option to the filters, too.
In my opinion the code above ($tables['term_node']) isn't needed.
Comment #10
konsumer commentedDoes it work ok without the taxonomy term in the view? I am thinking now that may have been my motivation (I think of myself as a good code-commenter, but I can't tell what that bit was for either.) If it does, then I am all for removing it. If not, maybe a conditional in there would help things.
Comment #11
uwe mindrup commentedA very nice idea, but: no - the taxonomy images are only shown (see 4th column 'Taxonomy Images' in screenshot at #9) when the view includes the 'Taxonomy Image: Image' field. The normal taxonomy field (column no. 3 'Taxonomy-Terms') shows only the normal taxonomy term (as text or as link) - the terms are not converted to the approp. image.
Comment #12
konsumer commentedThat's not what I mean.
What I mean is this:
The code in question applies a JOIN on Taxonomy data to link Taxonomy Images with nodes. The reason it is conflicting is that Taxonomy does the same thing. Removing it may make it work when you have taxonomy in another view field (becuase it handles the join for the view), but I'm guessing that it will not work if there is no other taxonomy fields in the view.
I ask for others to test, because as I said, I'm really swamped right now. When I get a little more time, I'd be happy to check it out.
Comment #13
nancydruI can confirm what Uwe reports.
I'm having trouble setting up a view that does what Konsumer suggests.
Comment #14
uwe mindrup commentedOh, sorry, I misunderstood. I have tested it: when I take a view with only a field 'Taxomomy Image' (without any other Taxonomy field), the images are still shown, even after clearing all caches.
Comment #15
nancydruAre we saying, then, that it is correct to remove $tables['term_node'] and that the module will still function correctly?
Comment #16
uwe mindrup commentedYes, I can confirm it. I meanwhile have tested it also with the newest version 5.x-1.2 (with removed $tables['term_node']) and it works as espected for my sites.
Comment #17
nancydruWell, that's simple enough to fix. I would like to have Konsumer or Brenda003 confirm this, as they are more Views-savvy than I.
Comment #18
nancydruRelated: http://drupal.org/node/244644 - According to that user, this does not work.
Comment #19
ThePickwickProject commentedSome more information:
* After uninstalling the Taxonomy Image module (and before installing the latest version), I noticed that the Taxonomy:All terms filter still wasn't there.
Comment #20
nancydru@pawshaker - then this module can hardly be blamed. Perhaps a support issue against Views is in order.
Comment #21
ThePickwickProject commentedHi Nancy, that's where this thread was originally posted?
Comment #22
nancydruI just moved your other thread back to Views with additional information. Since I am not well liked in the Views world, I suggest you ride with it.
Comment #23
uwe mindrup commentedAfter uninstalling the Taxonomy image module it is essential to clear the views cache (example.com/admin/build/views/tools).
Comment #24
nancydruANY change that involves Views means you need to clear the cache.
Comment #25
summit commentedHi,
I have exactly the same problem. My Taxonomy:All terms filters are gone. Especially with the popular_content views.
With a "normal" view I got it back, but on popular_content it didn't work. Do I need to do something any where else with the $tables['term_node']?
I have updated taxonomy image to version 1.2, emptied my cache, but I do not see the filter "Taxonomy:All terms" any more!
Please assist. Thanks in advance for going into this.
EDIT: I can confirm that commenting out:
Is working! I do not know the influence of this on the taxonomy_image module, but my site is giving the correct info now again.
Thanks a lot for this thread!
greetings,
Martijn
greetings,
Martijn
Comment #26
nancydruThank you, Martijn. Can you confirm or deny the concern in #12? There is an issue against Views mentioned in #18; you may want to add your two cents worth on that issue.
Comment #27
summit commentedHi,
I have more than one view, and they are al working now again. I do not know if there is a taxonomy relation in all the views sorry.
Anyone else can confirm Nancy here concerns are correctly interpreted with this commenting out $tables['term_node']?
Greetings,
Martijn
Comment #28
brenda003I don't have time to test but removing the term_node should do it - that was done by me before I understand views very well. I believe any reports of this not working are caching issues.
Comment #29
nancydruThanks, Brenda.
Comment #30
nancydruI have commented out that table and committed this to -dev on both branches.
Comment #31
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.