SelectQuery::getArguments()
calls SelectQuery::arguments()
so using arguments()
instead of getArguments()
does fix the problem described in #224. Modified patch from #195 for Drupal 7.31 is attached.
Problems mentioned in #198 remaining, of course.
The patch from #195 prevents Views to substitute (at least) the ***CURRENT_TIME*** placeholder (see views_views_query_substitutions()
and views_query_views_alter()
). I tracked that down to the call to $query->getArguments() which in turn calls $this->compile(). There it somehow will use the query conditions before Views can substitute them using its hook_query_TAG_alter()
.
This can be reproduced by creating a simple node based View with default settings. Add the filter criteria Content: Has new content. As soon as Node Access kicks in the problem occurs. I triggered it using the Content Access modul (default settings) and accessing the Views path as standard authorized user. The resulting SQL code was:
SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created
FROM node node
LEFT JOIN history history ON node.nid = history.nid AND history.uid = '3'
INNER JOIN node_comment_statistics node_comment_statistics ON node.nid = node_comment_statistics.nid
WHERE (( (node.status = '1') AND ((history.timestamp IS NULL AND (node.changed > (***CURRENT_TIME*** - 2592000) OR node_comment_statistics.last_comment_timestamp > (***CURRENT_TIME*** - 2592000))) OR history.timestamp < node.changed OR history.timestamp < node_comment_statistics.last_comment_timestamp) ))AND ( EXISTS (SELECT na.nid AS nid
FROM node_access na
WHERE (( (na.gid = '0') AND (na.realm = 'all') )OR( (na.gid = '3') AND (na.realm = 'content_access_author') )OR( (na.gid = '2') AND (na.realm = 'content_access_rid') ))AND (na.grant_view >= '1') AND (node.nid = na.nid) ))
ORDER BY node_creat
Query without patch looks like this:
SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created
FROM node node
LEFT JOIN history history ON node.nid = history.nid AND history.uid = '3'
INNER JOIN node_comment_statistics node_comment_statistics ON node.nid = node_comment_statistics.nid
WHERE (( (node.status = '1') AND ((history.timestamp IS NULL AND (node.changed > (1412939965 - 2592000) OR node_comment_statistics.last_comment_timestamp > (1412939965 - 2592000))) OR history.timestamp < node.changed OR history.timestamp < node_comment_statistics.last_comment_timestamp) ))AND ( EXISTS (SELECT na.nid AS nid
FROM node_access na
WHERE (( (na.gid = '0') AND (na.realm = 'all') )OR( (na.gid = '3') AND (na.realm = 'content_access_author') )OR( (na.gid = '2') AND (na.realm = 'content_access_rid') ))AND (na.grant_view >= '1') AND (node.nid = na.nid) ))
ORDER BY node_created DESC
LIMIT 10 OFFSET 0