We have a View in our system to show taxonomy terms like a taxonomy browser. It has 3 displays, all using the same filters, contexts, etc. Display 1 is a teaser list, 2 is a grid, and 3 is a list view.
1 displays fine for all users; however 2 & 3 only display to the admin user. For other anonymous and authenticated, they show the header and Items Per Page drop down menu; but the space where the results should be displayed is completely blank.
What does this have to do with the Support Ticketing module, you ask? Well, for displays 2 & 3 (the two displays that are blank for all but admin), the query data includes a reference to the Support Ticketing Module!!!
Display 2 shows that its query to generate the grid view includes the following criteria:
LEFT OUTER JOIN {support_ticket} st ON st.nid = node.nid
...
WHERE ( (tn.tid = '206') ))) ))AND( (st.client IN ('4', '3')) OR (st.client IS NULL ) )Display 3 doe not include the first JOIN, but does include the second reference:
WHERE ( (tn.tid = '206') ))) ))AND( (st.client IN ('4', '3')) OR (st.client IS NULL ) )
This view is a major issue for our site -- as it displays all our products for sale, and right now no one is able to see any of them!!!
Comments
Comment #1
somatics commentedI also did try to disable Support Ticket, which i assumed would then make the Views results reappear. However, I think it would require 1 or more cache flushes for the View to start reflecting the new active module set. However, when I tried to do that, the flush failed on a fatal error:
Shouldn't Support Ticket be able to disabled and not leave a land mine like that that trips up other Drupal activity? I shouldn't have to uninstall it to be temporarily not use it, or (like in this case) even just to troubleshoot it. I can't uninstall it and loose all our support tickets data! So, I just reenabled it, so clear cache and presumably other important functions would not be crippled.
Comment #2
somatics commentedI'm also getting a similar error on two blocks from core: The Active forum topics and New forum topics blocks both appear fine when logged in as admin user.
But if a regular user, anonymous our authenticated, tries to view any pages with those blocks on them return a server error page. The dblogs for these errors are as follows:
Comment #3
jeremy commentedI'm unable to duplicate this; is there anything nonstandard about your installation that could help me duplicate this?
Comment #4
rafaqz commentedI have a similar problem... in this case whenever I attempt to save a node, and this example is not a support ticket node. The node dosnt actually save either so this is a critical bug.
I'm also only using the support module, not the sub-modules.
Here's the error:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'nid' in where clause is ambiguous: SELECT node.nid AS entity_id, node.vid AS revision_id, node.type AS bundle, :entity_type AS entity_type FROM {node} node LEFT OUTER JOIN {support_ticket} st ON st.nid = node.nid WHERE (nid IN (:db_condition_placeholder_0)) AND (type IN (:db_condition_placeholder_1)) AND( (st.client IN (:db_condition_placeholder_2)) OR (st.client IS NULL ) ); Array ( [:db_condition_placeholder_0] => 19 [:db_condition_placeholder_1] => location [:db_condition_placeholder_2] => 1 [:entity_type] => node ) in EntityFieldQuery->execute()
Thanks
Comment #5
rafaqz commentedlooks like the support_node_load db_query is responsible
Comment #6
hephaestus commentedI'm also encountering this on 7.x-1.0-rc1.
It's occuring on all of the term pages for two separate taxonomies (used as categories) when logged in as a user without the "View other users tickets" permission.
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.uid' in 'where clause': SELECT DISTINCT COUNT(t.nid) AS expression FROM {taxonomy_index} t INNER JOIN {node_access} na ON na.nid = t.nid LEFT OUTER JOIN {support_ticket} st ON st.nid = t.nid WHERE (tid = :db_condition_placeholder_0) AND(( (na.gid = :db_condition_placeholder_1) AND (na.realm = :db_condition_placeholder_2) ))AND (na.grant_view >= :db_condition_placeholder_3) AND(( (st.client IN (:db_condition_placeholder_4)) AND (t.uid = :db_condition_placeholder_5) )OR (st.client IS NULL ) ); Array ( [:db_condition_placeholder_0] => 44 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => all [:db_condition_placeholder_3] => 1 [:db_condition_placeholder_4] => 1 [:db_condition_placeholder_5] => 81 ) in PagerDefault->execute() (line 74 of /home/<user>/public_html/includes/pager.inc).Comment #7
Ehud commentedSubscribing. Views has been broken. Cannot edit or create nodes. I get similar error:
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'nid' in where clause is ambiguous: SELECT node.nid AS entity_id, node.vid AS revision_id, node.type AS bundle, :entity_type AS entity_type FROM {node} node LEFT OUTER JOIN {support_ticket} st ON st.nid = node.nid WHERE (nid IN (:db_condition_placeholder_0)) AND (type IN (:db_condition_placeholder_1)) AND (node.language IN (:db_condition_placeholder_2, :db_condition_placeholder_3)) AND( (st.client IN (:db_condition_placeholder_4, :db_condition_placeholder_5)) OR (st.client IS NULL ) ); Array ( [:db_condition_placeholder_0] => 7191 [:db_condition_placeholder_1] => lottery [:db_condition_placeholder_2] => trans_en [:db_condition_placeholder_3] => und [:db_condition_placeholder_4] => 1 [:db_condition_placeholder_5] => 2 [:entity_type] => node ) in EntityFieldQuery->execute() (line 1136 of entity.inc).
Comment #8
sksmithson commentedSame here when an authenticated user views a page created by a view that uses taxonomy. If an anonymous user or admin views the page there is no error. Here's what I get...
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 't.uid' in 'where clause': SELECT COUNT(t.nid) AS expression FROM {taxonomy_index} t LEFT OUTER JOIN {support_ticket} st ON st.nid = t.nid WHERE (tid = :db_condition_placeholder_0) AND ( EXISTS (SELECT na.nid AS nid FROM {node_access} na WHERE (( (na.gid = :db_condition_placeholder_1) AND (na.realm = :db_condition_placeholder_2) )OR( (na.gid = :db_condition_placeholder_3) AND (na.realm = :db_condition_placeholder_4) )OR( (na.gid = :db_condition_placeholder_5) AND (na.realm = :db_condition_placeholder_6) ))AND (na.grant_view >= :db_condition_placeholder_7) AND (t.nid = na.nid) )) AND(( (st.client IN (:db_condition_placeholder_8)) AND (t.uid = :db_condition_placeholder_9) )OR (st.client IS NULL ) ); Array ( [:db_condition_placeholder_0] => 2 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => all [:db_condition_placeholder_3] => 2 [:db_condition_placeholder_4] => content_access_author [:db_condition_placeholder_5] => 2 [:db_condition_placeholder_6] => content_access_rid [:db_condition_placeholder_7] => 1 [:db_condition_placeholder_8] => 1 [:db_condition_placeholder_9] => 2 ) in PagerDefault->execute() (line 74 of /path to drupal/includes/pager.inc).Comment #9
sinasalek commentedSame here with Views, support module injects the following code to any views which relation (doesn't matter to which table)
support_query_alter is responsible for this problem , so if you disable this function things will become fine. But fixing the issue is a bit tricky, we need to know which queries include support ticket nodes and inject the access query only for those queries. However since support ticket is node! (which i think should have been an entity) there isn't any easy way to figure that out.
If we totally disable the query injection , support access control will be partially disabled too which is a security risk, and if leave it active then it causes lots of problem in difference places.
What i came up with so far is to check the query to see if it contains any node type condition , if its does, and support ticket is not among them then we can safely ignore the inject , otherwise it works as before. Thanks to D7 new database api it's possible but not actually easy!! Here is a potential solution :)
As you can see you should copy it at the begining of support_query_alter function on support.module file.
NOTICE : You much clear that cache once after the change for it to work. For views all you have to do is to add node.type filter and limit and exclude support_ticket nodes from result
Comment #10
dewolfe001 commentedThe problem I found was that this function was adding the uid column to SELECT statements with tables that did not have a uid column. My suggestion for how to address this is to put a field test into a try statement in the support_query_alter() function on support.module file.
(amended to include the great comments from sinasalek ).
Comment #11
sinasalek commentedThat easy to fix, instead of using try which kill the performance (It will run for almost all queries on site) you can look in selected tables. For example when there is no node table then support should ignore altering that query.
Also we have tables schema so it's possible to event check the selected tables' fields
Comment #12
dewolfe001 commentedI agree it's a performance hit and a kludge. It's also how query.inc in Drupal 7 assesses if a field exists--
from public function fieldExists($table, $column)
includes\database\mysql\schema.inc, line 524:
$this->connection->queryRange("SELECT $column FROM {" . $table . "}", 0, 1);Comment #13
sinasalek commentedNo wonder Drupal has performance issues :)
So then i think it's better to rely on fieldExists method. if it gets a performance patch this snippet will benefits from that too
There is a standalone function as well http://api.drupal.org/api/drupal/includes%21database%21database.inc/func...
Comment #14
dewolfe001 commentedGreat idea! I edited my code (http://drupal.org/node/1376120#comment-6377448) to put db_field_exists($table, 'uid') into the mix.
Comment #15
rbrownellI too am getting this same issue... If you get Devel to log your individual queries. Even simple ones like display all Published Node of any kind except support tickets, it shows this left join.
I hope a patch gets released for this soon.
-R
Comment #16
somatics commentedI hope so too. I've had multiple problems with this module, and had to discontinue using it. I posted two issues about them, and have yet to hear back about either 9+ months. It's sadly ironic that the developers would be completely unresponsive on this, given that it's a module for providing support.
I'm in no way ungrateful about the contributions of developers to open source, and understand we're all time-constrained. However, the end result is, I have no idea how to proceed with this module or equivalent functionality. I truly and respectfully wish they would respond -- even to acknowledge the issue and say, "we simply just don't have the time to fix it" or something like that, instead of just appearing as if they are no longer around and don't know this module-killing issue is being experienced by a lot of people (there are multiple issues posted about this very same problem all over drupal.org and elsewhere!).
We reeeeeaalllly wanted to use it -- we had a whole plan to build in support services to our site for our customers and members using this; and we've had to scratch it, with no current alternative (other than trying to integrate a separate 3rd party service like ZenDesk, which is not an easy or manageable solution for our particular situation -- so, we haven't done that are struggling along without a help desk or even a dedicated support tracking system).
Comment #17
rbrownellFor me, this isn't breaking views but my server is already maxed out on memory usage and I imagine that this is just one more drop in the bucket.
Not sure why this is set to Maintainer Needs More Information... It is fairly simple to reproduce. Here is how I reproduce it...
Install Views (I have Views 7.x-3.5)
Install Support Ticketing System (I have 7.x-1.0-rc1)
Enable "Show the SQL query" under "Live preview settings" in the Views module settings.
Look at a random View setup to display nodes that don't involve a Support Ticket.
Witness the undesirable existence of the added query add on in the live preview's SQL
LEFT OUTER JOIN {support_ticket} st ON st.nid = node.nid ........... AND( (st.client IN ('2', '1')) OR (st.client IS NULL ) ). This exists for all of my node views whether or not they involve Support Tickets.Disable Support Ticketing System
Go back to the view and live preview again.
The inserted gook is no longer in the query.
Server is running Apache, PHP5.3.5, and MySQL5.1.56-log.
I don't want to throw any rocks or step on any toes but I'm switching this back to active.
Comment #18
jeremy commentedThanks, nfd. That was quite helpful, I'm able to duplicate...
Comment #19
jeremy commentedThere's three issues being discussed in this thread:
http://drupalcode.org/project/support.git/commit/3f197ba
Comment #20
sinasalek commentedJeremy thank's for the commit,
Regarding number 3, even when there is a uid it still shouldn't join with support_ticket when the query does not contain any ticket node. However i'm not sure if my solution in comment #9 is generic enough to fix this issue permanently. I spent alot of time figuring out how to this in safe way , so far this solution is the only one i could come up with
It works well with views though
Comment #21
jeremy commentedI see your proposed solution; my biggest concern is the performance implication this might have for all queries... my recommendation is to create a new ticket that is explicitly about avoiding joins to the support_ticket table when not needed, and putting your patch there so we can review/test/discuss. This ticket was about breaking Views queries, which I hope is now solved.
Comment #22
sinasalek commentedI see, i created a new ticket here #1786696: Avoiding joins to the support_ticket table when not needed