Posted by bluemaro on February 2, 2013 at 2:44pm
8 followers
| Project: | Domain Access |
| Version: | 7.x-3.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Issue Summary
After upgrading to never version I can't access any node if logged in as system admin user. Following exception is raised:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 'EXISTS (SELECT na.nid AS nid FROM node_access na WHERE (( (na.gid = '0') AND (' at line 2: SELECT COUNT(*) AS expression FROM {comment} c INNER JOIN {node} node ON c.nid = node.nid WHERE (c.nid = :db_condition_placeholder_0) AND (c. 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) )OR( (na.gid = :db_condition_placeholder_7) AND (na.realm = :db_condition_placeholder_8) ))AND (na.grant_view >= :db_condition_placeholder_9) AND (c.nid = na.nid) )) AND (node.language IN (:db_condition_placeholder_10, :db_condition_placeholder_11)) ; Array ( [:db_condition_placeholder_0] => 27 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => all [:db_condition_placeholder_3] => 0 [:db_condition_placeholder_4] => domain_site [:db_condition_placeholder_5] => 1 [:db_condition_placeholder_6] => domain_id [:db_condition_placeholder_7] => 1 [:db_condition_placeholder_8] => domain_unpublished [:db_condition_placeholder_9] => 1 [:db_condition_placeholder_10] => pl [:db_condition_placeholder_11] => und ) w PagerDefault->execute() (linia 74 z /www/includes/pager.inc).I still can access all nodes as anonymous user though.
Comments
#1
Can you please copy the entire, processed query here using Devel module. This is not readable.
It also does not happen for me (nor for most users). So steps to replicate and information about your MySQL version are required.
#2
to I have the same problem since the update version.
Complete information below
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 'EXISTS (SELECT na.nid AS nid FROM node_access na WHERE (( (na.gid = '0')' at line 2: SELECT COUNT(*) AS expression FROM {comment} c INNER JOIN {node} node ON c.nid = node.nid WHERE (c.nid = :db_condition_placeholder_0) AND (c. 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) )OR( (na.gid = :db_condition_placeholder_7) AND (na.realm = :db_condition_placeholder_8) ))AND (na.grant_view >= :db_condition_placeholder_9) AND (c.nid = na.nid) )) AND (node.language IN (:db_condition_placeholder_10, :db_condition_placeholder_11)) ; Array ( [:db_condition_placeholder_0] => 6990 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => all [:db_condition_placeholder_3] => 0 [:db_condition_placeholder_4] => domain_site [:db_condition_placeholder_5] => 1 [:db_condition_placeholder_6] => domain_id [:db_condition_placeholder_7] => 1 [:db_condition_placeholder_8] => domain_unpublished [:db_condition_placeholder_9] => 1 [:db_condition_placeholder_10] => es [:db_condition_placeholder_11] => und ) en PagerDefault->execute() (línea 74 de /pager.inc).
Mysql 5.0.45
Php 5.0.45
Server version: Apache/2.2.9 (Unix)
Server built: Jul 14 2008 15:29:50
#3
Same thing is happening to me.
I suppose it's related to internationalization.
In my logs I get
Menu and taxonomy name mismatch: Proyectos abiertos != open projects
("Proyectos abiertos" is the spanish translation of open projects")
I will try to fix that problem first and see if the error goes away.
#4
fixed by rebuilding the taxonomy menu. The error stays.
#5
And I assume that when you turn off the "Restrict node views for administrators " setting, this goes away?
#6
I cannot replicate the error.
I need a list of steps to reproduce, including the modules being used for translation.
#7
And where this query appears. This looks like a {comment} table query, which might explain the failure.
And PLEASE replace the db_placeholders when reporting a query.
#8
I encountered the same problem, with a new install of domain access module (not an upgrade from 7.x-3.7).
At first everything worked fine but after installing http://drupal.org/project/support (which needs comment module) it was broken. The problem arises when I try to view a node with comments enabled.
Error
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 'EXISTS (SELECT na.nid AS nid FROM node_access na WHERE (( (na.gid = '0') AND (' at line 3: SELECT COUNT(*) AS expression FROM {comment} c INNER JOIN {node} node ON c.nid = node.nid LEFT OUTER JOIN {support_ticket} st ON st.nid = node.nid WHERE (c.nid = :db_condition_placeholder_0) AND (c. 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) )OR( (na.gid = :db_condition_placeholder_7) AND (na.realm = :db_condition_placeholder_8) ))AND (na.grant_view >= :db_condition_placeholder_9) AND (c.nid = na.nid) )) AND (node.language IN (:db_condition_placeholder_10, :db_condition_placeholder_11)) AND( (st.client IN (:db_condition_placeholder_12, :db_condition_placeholder_13)) OR (st.client IS NULL ) ); Array ( [:db_condition_placeholder_0] => 34 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => all [:db_condition_placeholder_3] => 0 [:db_condition_placeholder_4] => domain_site [:db_condition_placeholder_5] => 1 [:db_condition_placeholder_6] => domain_id [:db_condition_placeholder_7] => 1 [:db_condition_placeholder_8] => domain_unpublished [:db_condition_placeholder_9] => 1 [:db_condition_placeholder_10] => en [:db_condition_placeholder_11] => und [:db_condition_placeholder_12] => 1 [:db_condition_placeholder_13] => 2 ) in PagerDefault->execute() (line 74 of /Applications/MAMP/htdocs/atsgroepdemo/www/includes/pager.inc).Used modules: see attachment
#9
I still can't replicate the error. I enabled Support, created a language, create some nodes (some Tickets and some Articles) with content.
No issues.
#10
More information on this issue:
The problem only occurs when logged in with user 1 and when the core 'Domain Access' module is enabled.
#11
Does it only occur when the Domain Access setting for "Restrict node views for administrators" is enabled?
If so the simple fix is the disable that until we pinpoint the issue, which would be in domain_alter_node_query(). But that function is really just a clone of a core function, so the error is curious.
Notice that in the original query, we have these lines throwing the actual error:
AND (c. EXISTS (SELECT na.nWhich means that no column is being added to the query. If we knew which base query this was, it would make things much easier.
#12
It's like you said agentrickard: it only occurs when you've set the Domain Access setting to "Restrict node views for administrators".
#13
Right, so once we know what code is generating the query, we can test a solution.
#14
I'm still inclined to think that this is a bug in another module. The code we are executing is a direct clone of _node_query_node_access_alter(). The only part that changes is that we have removed the logic that skips the query alter if the user can bypass node access.
If you can debug what is happening, take a look inside domain_alter_node_query(). A debug_backtrace() on that function would tell us where the query is coming from.
There is, of course, a workaround in that you can disable this feature, which (ironically) is designed to help administrators debug their sites.
#15
I noticed the error also occurs when I try to view a term page.
Both acktraces attached.
#16
Hi agentrickard
I have the same problem. I'm still debugging but one this is sure for me:
I have a node with enabled comments. The error happens here. On a node without comments it does not happen. And of course, I have panels and ctools enabled and the comment form is on the panel for this node.
Maybe this helps reproducing it. If I disable the list of comments on the panel, the page works without a problem.
It seems, that it has to do with a pager:
"SELECT c.cid AS cid, SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1)) AS torder FROM {comment} c WHERE (c.nid = :db_condition_placeholder_0) ORDER BY torder ASC::node();"
What really scares me is the fact, that the same code works on my live server. The only difference is the php version:
Live Server: PHP Version 5.2.10
Local: PHP Version 5.3.9
With what version did you test agentrickard?
#17
I still cannot reproduce. Here's the comment query I get when viewing the node page:
SELECT COUNT(*) AS expression FROM comment c LEFT OUTER JOIN support_ticket st ON st.nid = c.nid WHERE (c.nid = '51') AND ( EXISTS (SELECT na.nid AS nid FROM node_access na WHERE (( (na.gid = '0') AND (na.realm = 'all') )OR( (na.gid = '0') AND (na.realm = 'domain_site') )OR( (na.gid = '1') AND (na.realm = 'domain_id') )OR( (na.gid = '1') AND (na.realm = 'domain_unpublished') ))AND (na.grant_view >= '1') AND (c.nid = na.nid) )) AND( (st.client IN ('1')) OR (st.client IS NULL ) )The part that I don't seem to be able to reproduce is this section:
LEFT OUTER JOIN {support_ticket} st ON st.nid = node.nid WHERE (c.nid = :db_condition_placeholder_0) AND (c. EXISTSWe need to figure out why that
c.is being added to the EXISTS clause. That's the error. I wonder if Panels has anything to do with it? I'm not testing with Panels.What is the SQL error you get on the taxonomy term page?
#18
FYI. My MAMP has PHP 5.2.17 and 5.4.4 and they both don't work.
#19
This is the executed query on the taxonomy term page.
SELECT t.nid AS nid, t.tid AS tid, t.sticky AS sticky, t.created AS created FROM {taxonomy_index} t 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) )OR( (na.gid = :db_condition_placeholder_7) AND (na.realm = :db_condition_placeholder_8) ))AND (na.grant_view >= :db_condition_placeholder_9) AND (t.nid = na.nid) )) ORDER BY t.sticky DESC, t.created DESCSELECT COUNT(t.nid) AS expression FROM {taxonomy_index} t 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) )OR( (na.gid = :db_condition_placeholder_7) AND (na.realm = :db_condition_placeholder_8) ))AND (na.grant_view >= :db_condition_placeholder_9) AND (t.nid = na.nid) ))#20
Does that actually execute? Or does it error out?
As reported, this part of the query is simply malformed:
ORDER BY t.sticky DESC, t.created DESCSELECT COUNT(t.nid) AS expression FROM {taxonomy_index} t WHERE (tid = :db_condition_placeholder_0) AND ( EXISTS (SELECT naWhat version of Drupal core are you using?
#21
My version of the same taxonomy query:
SELECT t.nid AS nid, t.tid AS tid, t.sticky AS sticky, t.created AS created FROM taxonomy_index t LEFT OUTER JOIN support_ticket st ON st.nid = t.nid WHERE (tid = '1') AND ( EXISTS (SELECT na.nid AS nid FROM node_access na WHERE (( (na.gid = '0') AND (na.realm = 'all') )OR( (na.gid = '0') AND (na.realm = 'domain_site') )OR( (na.gid = '1') AND (na.realm = 'domain_id') )OR( (na.gid = '1') AND (na.realm = 'domain_unpublished') ))AND (na.grant_view >= '1') AND (t.nid = na.nid) )) AND( (st.client IN ('1')) OR (st.client IS NULL ) ) ORDER BY t.sticky DESC, t.created DESC LIMIT 10 OFFSET 0#22
It doesn't execute.
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 'EXISTS (SELECT na.nid AS...
in PagerDefault->execute() (regel 74 van /Applications/MAMP/htdocs/atsgroep/www/includes/pager.inc).I'm using Drupal core version 7.19.
#23
Hi agentrickard
I think it has to do with ctools ot with panels. You should be able to reproduce it this way:
1. Install ctools and panels and activate it
2. activate comments on story node type
3. Create a panel site for node view and override the story node type
4. Add the full node with all addons to the panel
5. Add a comment form to the panel
6. Add a comment flat list to the panel
Then you will be able to see the error as user 1.
#24
If that's the case, I'm very tempted to re-file this as a Panels bug, but I'd like to reproduce it first.
#25
@ayalon
Step 3 in your instructions doesn't make any sense to me. Please export your panel.
Here's the panel layout I created, overriding the default "article" content type. No errors. I still cannot replicate this issue.
Does it occur for anon users or other non-admin users? If so, this is a Panels bug.
#26
Also had this issue and retrograding to 7.x-3.7 solved the issue for me
#27
@Anticosti
Please provide more information. That is not actionable. I have not been able to replicate this bug report.
#28
@ agentrickard
Here's the complete (exhaustive) list of my activated modules:
drupal 7.21
Modules
Sorry for this long list ;(
Kind Regards,
#29
That doesn't help either.
See https://drupal.org/node/73179
I need repeatable steps to reproduce the bug.
#30
Server
Perl
Sendmail /usr/sbin/sendmail
PHP version 5.3.21
Path to PHP /usr/bin/php
Configure Command './configure' '--disable-fileinfo' '--enable-bcmath' '--enable-calendar' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-magic-quotes' '--enable-mbstring' '--enable-pdo=shared' '--enable-soap' '--enable-sockets' '--enable-wddx' '--enable-zip' '--prefix=/usr' '--with-bz2' '--with-curl=/opt/curlssl/' '--with-freetype-dir=/usr' '--with-gd' '--with-gettext' '--with-gmp' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-libexpat-dir=/usr' '--with-libxml-dir=/opt/xml2' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mm=/opt/mm/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre' '--with-pdo-mysql=shared' '--with-pdo-sqlite=shared' '--with-pic' '--with-png-dir=/usr' '--with-pspell' '--with-sqlite=shared' '--with-tidy=/opt/tidy/' '--with-xmlrpc' '--with-xpm-dir=/usr' '--with-xsl=/opt/xslt/' '--with-zlib' '--with-zlib-dir=/usr'
Server API CGI/FastCGI
Ruby 1.8.7
Rails 3.2.11
Python 2.4.3
Python 2.6.1
Python 3.0.1
MySQL 5.1
Repeatable: Always
Steps to repeat:
1. Upgrade to 7.x-3.8 from 7.x-3.7
2. Visit Front page in site
3. Click on an Article's photography (linked to the complete content)
Expected Results:
User suppose to see the complete article content page
Actual Results:
Blank Page returns this error:
PDOException : SQLSTATE[42000]: Syntax error or access violation: 1064 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 'EXISTS (SELECT na.nid AS nid FROM node_access na WHERE (( (na.gid = '0') AND (' at line 2: SELECT COUNT(*) AS expression FROM {comment} c INNER JOIN {node} node ON c.nid = node.nid WHERE (c.nid = :db_condition_placeholder_0) AND (c. 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) )OR( (na.gid = :db_condition_placeholder_7) AND (na.realm = :db_condition_placeholder_8) )OR( (na.gid = :db_condition_placeholder_9) AND (na.realm = :db_condition_placeholder_10) ))AND (na.grant_view >= :db_condition_placeholder_11) AND (c.nid = na.nid) )) AND (node.language IN (:db_condition_placeholder_12, :db_condition_placeholder_13)) ; Array ( [:db_condition_placeholder_0] => 88 [:db_condition_placeholder_1] => 0 [:db_condition_placeholder_2] => all [:db_condition_placeholder_3] => 0 [:db_condition_placeholder_4] => domain_site [:db_condition_placeholder_5] => 1 [:db_condition_placeholder_6] => domain_id [:db_condition_placeholder_7] => 1 [:db_condition_placeholder_8] => domain_unpublished [:db_condition_placeholder_9] => 2 [:db_condition_placeholder_10] => og_access:node [:db_condition_placeholder_11] => 1 [:db_condition_placeholder_12] => fr [:db_condition_placeholder_13] => und ) dans PagerDefault->execute() (ligne 74 dans /home/user/public_html/sitedev/includes/pager.inc).
Kind Regards,
#31
Thanks. That's in line with the other reports, but I can't make my demo site throw that error. The problem is here:
AND (c. EXISTS (SELECT na.nid ASThere is something going on in each instance where the comment id is not being passed properly to the query alter hook.
Is that Article page a Panel? If so, can you export the Panel configuration and attach it here?
In any event, if you can stick a debug_backtrace inside domain_alter_node_query(), we still have to figure out where this query is being generated.
The current solution, btw, is not to downgrade, but to disable the "Restrict content views for administrators" setting of DA.
#32
Interesting. The core version of that query has no JOIN.
SELECT COUNT(*) AS expression FROM comment c WHERE (c.nid = :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) )OR( (na.gid = :db_condition_placeholder_7) AND (na.realm = :db_condition_placeholder_8) ))AND (na.grant_view >= :db_condition_placeholder_9) AND (c.nid = na.nid) ))Is this a Comment list View inside a Panel?
#33
@ agentrickard
I followed your advise:
Result:
No more errors
Answer to your question:
I am not using panels. Even if the module is activated. Not there yet ;-)
Edit: This is just a straight out of the box front page articles' listing with summaries and pictures
Wish I could be of any help so...
To help you: How could I stick a "debug_backtrace inside domain_alter_node_query()" ?
Not familiar with this ;(
Kind Regards,
#34
@ agentrickard
Followup:
1. I just reactivated the "Restrict content views for administrators" setting of DA
Result:
Still... No errors :) :) :)
#35
Ok, that is interesting, and suggests something else may be awry. Have you rebuilt access permissions recently?
#36
@ agentrickard > No, I didn't rebuilt access permissions recently.
BTW: I guess you devs sometime appreciate a little tap on the shoulder...
I love your module. Great & Awesome Job! Could not go without it anymore :)
Cheers,
#37
@ agentrickard
Followup:
De/Reactivated the "Restrict content views for administrators" setting of DA
Just noticed that this issue only happens for me, when I am logged in as administrator.
Hope this may help ;-)
#38
That behavior is consistent for everyone in the thread. However, I can't reproduce it to test it.
What version of Drupal core are you running? I'm testing against 7.21.
#39
Running 7.21
I need to install Forum Access, so, I'll do a test activating it with it's depencies:
ACL and Chain Menu Access API
To follow...
Update: No change
#40
Could it be related to this Views issue: http://drupal.org/node/1055616
(Caches are missed, due to changing :db_condition_placeholder)
I'll do some tests
#41
That Views issue is unrelated.
#42
Seems to be related to this private messaging issue:
http://drupal.org/node/1911132
Cheers,
#43
No, that is a different error as well.
Please concentrate on telling us how to reproduce the error.
#44
It occurs to me that the current stable is 7.x.-3.9, so perhaps that is why I can't replicate this error.
Please, everyone, check your versions.
#45
I'm still investigating...
Restarted with a fesh install using version 7.x-3.9
All was going fine untill i installed a bunch of internationalization / strings / translation modules
Then... Here comes back the issue when I click on forum subject
I will revert and install one by one these last modules and see what I can come up with... ?
Cheers,
#46
Title change.
#47
Today I tried again updating the Domain Access Module.
I have hunted down the error, but I don't what is the reason.
I have a node page panel with a comment list on it.The node has comments enabled.
In the ctools/plugins/content_types/node_context/node_comments.inc
is a function called function ctools_comment_render($node, $conf) {}
There the comments a rendered with this function call:
$cids = comment_get_thread($node, $mode, $comments_per_page);
I went to the core function:
This SQL Statement produces the error:
<?php$query = db_select('comment', 'c')->extend('PagerDefault');
$query->addField('c', 'cid');
$query
->condition('c.nid', $node->nid)
->addTag('node_access')
->addTag('comment_filter')
->addMetaData('node', $node)
->limit($comments_per_page);
$cids = $query->execute()->fetchCol();
?>
I tried a lot of modification. Only commenting out / disabling node access solves the SQL error.
Maybe agentrickard has an idea, because the query is now identified.