This error appears when certain conditions are met:

  • using the page empty text as default value for a missing argument (argdefault=7)
  • SQL rewriting takes place (for example, when making use of the node access system)

When _view_build_query() encounters a missing argument, it returns an empty query "to trigger empty text". However, in views_build_view(), that empty query is then passed to db_rewrite_sql() without further checking. db_rewrite_sql() in turn doesn't check for empty queries, which leads to an incomplete query fragment being returned and queried afterwards, resulting in an error. The solution is to simply move the call to db_rewrite_sql() *after* the check for the non-empty query.

CommentFileSizeAuthor
#6 247420-query.patch1.07 KBagentrickard
views.patch622 bytessmk-ka
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

will_in_wi’s picture

Status: Needs review » Reviewed & tested by the community

I hit this same error and the patch fixed it.

sun’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

agentrickard’s picture

Status: Closed (fixed) » Active

@sun

Any chance you can roll a new 5.x.1.7 release with this in it? I keep having to re-apply the patch....

agentrickard’s picture

I'm seeing this in 6.x.2.6 as well. Odd.

agentrickard’s picture

Version: 5.x-1.x-dev » 6.x-2.8
FileSize
1.07 KB

Checked this in 6.x.2.8 as well.

This case can happen when a views pre_execute function nulls out the query. For example, when an exposed filter returns a null set. The same can happen with arguments.

This new patch was rolled against 6.x.2.6, but should be good for most versions.

dawehner’s picture

Status: Active » Needs work

This wil definitive needs a rerole for 3.x

I think views should fail somewhere when there is a empty query.

esmerel’s picture

if this needs a reroll for 3.x, should it get reassigned? I don't want to close something off that really does need doing.

Letharion’s picture

Version: 6.x-2.8 » 6.x-3.x-dev
Assigned: smk-ka » Unassigned
dawehner’s picture

Status: Needs work » Fixed

A somehow similar patch was already commited to 6.x-3.x

Status: Fixed » Closed (fixed)

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