See: http://api.drupal.org/api/function/hook_db_rewrite_sql/6

The implementation of hook_db_rewrite_sql() currently in modr8.module is implicitly assuming that if $primary table is not 'n', that there is not another table called 'n' in the query. That is not correct, since you are allowed to be using a different table alias.

Attached patch should fix the code to not have this assumption, and make your module more able to work well with other modules.

Note: I haven't actually tested this patch. It came up because someone using my Search by Page module was having trouble with SQL errors when Search by Page was used with ModR8. See #724500: Odd Results for Different Roles from Different Paths if you are interested.

CommentFileSizeAuthor
modr8_rewrite_sql.patch1.28 KBjhodgdon

Comments

pr0test0r’s picture

I have tested this patch with 6.x-1.1 on m dev site and it works! Thanks Jennifer, you're the best!

pwolanin’s picture

looks mostly good, but why:

+  $node_table = $primary_table;

instead jsut use $primary_table where needed

jhodgdon’s picture

Because, if you notice:

         if ($primary_table != 'n') {
-          $return['join'] = "LEFT JOIN {node} n ON $primary_table.nid = n.nid";
+          $return['join'] = "LEFT JOIN {node} modr_n ON $primary_table.nid = modr_n.nid";
+          $node_table = 'modr_n';
         }

If the primary table passed in isn't "node", there is a join happening, in which case primary and node tables are different.

pwolanin’s picture

Ah, right - missed the last line there.

pwolanin’s picture

Status: Needs review » Fixed

committed to 5.x and 6.x code

Status: Fixed » Closed (fixed)

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