When the default setting for an argument is "Use empty text", any user who does not have administer nodes permission and loads the view without the argument will get an SQL error. This is because db_rewrite_sql() adds join and where clauses even to empty queries.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Darren Oh’s picture

Status: Active » Reviewed & tested by the community
FileSize
590 bytes

The attached patch adds a test for empty queries.

digikami’s picture

-  $query = db_rewrite_sql($info['query'], 'node');
+  if (!empty($query)) {
+    $query = db_rewrite_sql($info['query'], 'node');
+  }

should probably be

-  $query = db_rewrite_sql($info['query'], 'node');
+  if (!empty($info['query'])) {
+    $query = db_rewrite_sql($info['query'], 'node');
+  }
Darren Oh’s picture

FileSize
598 bytes

Good catch.

catch’s picture

Priority: Normal » Critical

Bumping priority since there's a few duplicates around.

dropcube’s picture

If a module that rewrites queries is installed and an empty query is generated by _views_get_query and error is caused due to db_rewrite_sql() generates an incorrect query.
The above patch fixes the issue.

suit4’s picture

Patch views.module-205390.patch works for me, too.

bwong’s picture

I found this the hard way, using the Trace module. This patch works for me.

sun’s picture

Status: Reviewed & tested by the community » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

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