I got the following error message when attempting to edit an unpublished revision:

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 'current >=1' at line 1 query: SELECT COUNT(*) FROM node_access WHERE (nid=0 OR nid=13) AND ((gid=0 AND realm='all')) AND grant_edit current >=1 in ~drupal/sites/all/modules/module_grants/module_grants.module on line 243.

The following seems to have fixed it:

function module_grants_node_access($op, $node, $account = NULL) {
  global $user;
  
  if ($op == 'edit current') {
    $op = 'update';
  }

Comments

rdeboer’s picture

Thanks for reporting! However I have problems reproducing your issue...
That conversion from 'edit current' to 'update' should have happened in function _revision_tasks_menu_access_callback(...). module_grants_node_access($op,...) should never have been called with $op = 'edit current'....
Are you using the latest dev version of Revisioning, as well as the latest of Module Grants?

ccdechesney’s picture

That's kind of what I figured, although I wasn't sure where it should be happening. That's why I put the status at "needs review". Here's what I'm running:
// $Id: module_grants.module,v 1.42 2009/12/16 03:40:11 rdeboer Exp $
// $Id: revisioning.module,v 1.57 2009/12/01 03:52:45 rdeboer Exp $

rdeboer’s picture

Looks like you have updated Module Grants to a fairly recent version (although not the latest), but didn't update Revisioning at the same time.
Suggest you update both modules to the official releases of Jan 2010, i.e. 6.x-3.2 for Module Grants and 6.x-3.1 for Revisioning.
Assuming this will fix it, but please let us know if it hasn't.

rdeboer’s picture

Status: Needs review » Fixed
Anonymous’s picture

I appear to be having the same issue with revisioning 3.3 version. When viewing revisions tab e.g. path: page/200/revisions I get the following errors:

* user warning: 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 'revisions >=1' at line 1 query: SELECT COUNT(*) FROM node_access WHERE (nid=0 OR nid=200) AND ((gid=0 AND realm='all') OR ((gid=2 AND realm='workflow_access') OR (gid=3 AND realm='workflow_access_owner'))) AND grant_view revisions >=1 in ... .../module_grants/module_grants.module on line 259.
* user warning: 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 'revisions >=1' at line 1 query: SELECT COUNT(*) FROM node_access WHERE (nid=0 OR nid=200) AND ((gid=0 AND realm='all') OR ((gid=2 AND realm='workflow_access') OR (gid=3 AND realm='workflow_access_owner'))) AND grant_view revisions >=1 in ... .../module_grants/module_grants.module on line 259.
* user warning: 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 'revisions >=1' at line 1 query: SELECT COUNT(*) FROM node_access WHERE (nid=0 OR nid=200) AND ((gid=0 AND realm='all') OR ((gid=2 AND realm='workflow_access') OR (gid=3 AND realm='workflow_access_owner'))) AND grant_edit revisions >=1 in ... .../module_grants/module_grants.module on line 259.

Still getting my head around this, probably old news to you, but line 259 is not that helpful, looking at line 255 in module_grants.module:

$sql = $base_sql . (empty($module_grants) ? "" : " OR ($module_grants)") .") AND grant_$op >=1";

It is using $op so I'm guessing its trying to concatenate values of $op that contain white space such as 'view revisions', 'edit current' etc hence the sql errors. Node access columns need to be one of grant_view, grant_update or grant_delete (hence why the previous fix to single word 'update' appeared to work). RdeBoer you mentioned that the conversion to the correct grant op should have occurred in function _revision_tasks_menu_access_callback, but looking at revisioning module I couldn't find a matching access callback for node/node%/revisioning... not sure if that is relevant?

Anonymous’s picture

My statement above possibly is irrelevant as I'm also getting sql errors plus others when viewing path: page/200/revisions/50/view

* user warning: 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 'revisions >=1' at line 1 query: SELECT COUNT(*) FROM node_access WHERE (nid=0 OR nid=200) AND ((gid=0 AND realm='all') OR ((gid=2 AND realm='workflow_access') OR (gid=3 AND realm='workflow_access_owner'))) AND grant_view revisions >=1 in ... .../module_grants/module_grants.module on line 259.
* user warning: 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 'revisions >=1' at line 1 query: SELECT COUNT(*) FROM node_access WHERE (nid=0 OR nid=200) AND ((gid=0 AND realm='all') OR ((gid=2 AND realm='workflow_access') OR (gid=3 AND realm='workflow_access_owner'))) AND grant_edit revisions >=1 in ... .../module_grants/module_grants.module on line 259.
* warning: Missing argument 1 for node_page_view() in ... .../node/node.module on line 1783.
* warning: Invalid argument supplied for foreach() in ... .../cck/content.module on line 1284.

Anonymous’s picture

Looking into it a bit more I see the difficulty. I can't find anywhere in my modules where module_grants_node_access is called with anything other than 'view', 'update' or 'delete' as the op. Yet if I put dpm($op) at the top of the function I get:

* view
* Published page Some Page has 3 revisions.
* delete
* view revisions
* view
* view
* view revisions
* view
* edit revisions
* view

rdeboer’s picture

Version: 6.x-2.x-dev » 6.x-3.3
Status: Fixed » Postponed (maintainer needs more info)

Just to make sure... We're talking Module Grants 6.x-3.3 and Revisioning 6.x-3.3 and you did go to the Administer >> Site building >> Modules page and pressed Save configuration so that the menus and access callbacks are refreshed?

Anonymous’s picture

Yep Module Grants 6.x-3.3 and Revisioning 6.x-3.3:
; $Id: revisioning.info,v 1.12 2010/01/03 06:57:11 rdeboer Exp $
; $Id: module_grants.info,v 1.7 2009/12/16 03:40:11 rdeboer Exp $

Have gone to Administer >> Site building >> Modules page and pressed Save configuration.
Emptied cache (using devel).
Rebuilt menus (using devel).

Still getting error. If it helps troubleshoot, when I simply view path node/200 I also get the error:

user warning: 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 'revisions >=1' at line 1 query: SELECT COUNT(*) FROM node_access WHERE (nid=0 OR nid=200) AND ((gid=0 AND realm='all') OR ((gid=2 AND realm='workflow_access') OR (gid=3 AND realm='workflow_access_owner'))) AND grant_view revisions >=1 in ... .../module_grants/module_grants.module on line 260.

Anonymous’s picture

Perhaps more useful:
// $Id: module_grants.module,v 1.47 2010/01/04 23:52:20 rdeboer Exp $
// $Id: revisioning.module,v 1.69 2010/01/07 04:10:00 rdeboer Exp $

Anonymous’s picture

Since I can't track the source of 'view revisions' being passed as $op in module_grants_node_access, would it makes sense to do a temp fix by putting something like this at the top of the module_grants_node_access function:

switch ($op) {
    case 'view revisions':
      return _user_may_view_revisions($node);
      break;
  }
Anonymous’s picture

Or rather:

switch ($op) {
    case 'view revisions':
    case 'edit revisions':
      return module_grants_node_revision_access($op, $node);
      break;
  }
Anonymous’s picture

Doesn't address other errors when viewing a revision:

* warning: Missing argument 1 for node_page_view() in ... .../node/node.module on line 1783.
* warning: Invalid argument supplied for foreach() in ... .../cck/content.module on line 1284.

First seems to want cid (comment id?). Latter is returning empty array. Not sure about these errors, going to revert back to earlier versions of Module Grants and Revisioning to make sure errors are result of upgrade.

Anonymous’s picture

To follow up. No errors after reverting back to Revisioning 6.x-2.3 and Module Grants 6.x-2.x-dev.

rdeboer’s picture

Damn... :-(

Anonymous’s picture

Just installed Revisioning 6.x-3.4 and Module Grants 6.x-3.4. Still receiving the SQL errors above, i.e. 'grant_view revisions' and 'grant_edit revisions' appearing when trying to view an existing revision. And the 'Missing argument...' and 'Invalid argument...' errors. Any ideas?

Anonymous’s picture

The non SQL errors are possibly Revisioning module issue? From what I can tell, the page callback for e.g. /node/200/revisions/10 is node_page_view, not _revision_view. Is that correct? From looking at revisioning.module it seems it should be _revision_view. Looking at menu router table I see:

+---------------------------------+-----------------+
| path                            | page_callback   |
+---------------------------------+-----------------+
| admin/settings/revisioning      | drupal_get_form | 
| admin/help/revisioning          | help_page       | 
| node/%/revisions                | _present_node   | 
| node/%/revisions/list           | _present_node   | 
| admin/build/trigger/revisioning | trigger_assign  | 
| node/%/revisions/%/delete       | _present_node   | 
| node/%/revisions/%/revert       | _present_node   | 
| node/%/revisions/%/view         | node_page_view  | 
| node/%/revisions/%/publish      | drupal_get_form | 
| node/%/revisions/%/unpublish    | drupal_get_form | 
| node/%/revisions/%/edit         | _revision_edit  | 
+---------------------------------+-----------------+

Not sure if that is relevant? It seems node_page_view is missing a $node.

Anonymous’s picture

Category: support » bug
Status: Closed (fixed) » Postponed (maintainer needs more info)

So it seems Module Grants line 49 is controlling the page_callback, and isn't assigning any page arguments. If I add:
$items['node/%node/revisions/%/view']['page arguments'] = array(1); to line 50 of Module Grants and rebuild the menus it fixes the following errors:

warning: Missing argument 1 for node_page_view() in .../modules/node/node.module on line 1783.
warning: Invalid argument supplied for foreach() in .../sites/example.com/modules/contributed/cck/content.module on line 1284.

But I'm not sure if that is an actual fix. It seems the page callback should be _revision_view, from revisioning module, not node_page_view from module grants?

Anonymous’s picture

So upon checking the weight of my modules in the system table I discovered that module_grants was set as a heavier weight than revisioning. I can't find anywhere in module_grants module where it suggests this is intentional, so I suspect it was done manually on our db at some point in the past, possibly to address conflicts with og_access which has a weight of 1. So I changed the weights to ensure revisioning was heavier than module grants, emptied cache and rebuilt menus and it appears to have fixed both the page callback errors and the SQL errors regarding 'grant_view revisions'. Fingers crossed that was all it was.

rdeboer’s picture

Category: bug » support
Status: Postponed (maintainer needs more info) » Fixed

Phew! What a saga! But with a happy ending that you created yourself!

Yes Revisioning should have a higher weight than Module Grants, which it has be default due to it being later in the alphabet. So there is no code to explicitly set the weight.

Can we consider this solved?

Anonymous’s picture

Yes, solved. All errors appear to have been addressed.

rdeboer’s picture

Status: Fixed » Closed (fixed)

Great. I'll close this, as it seems to have been specific to the db on your install, so less relevant to others.

Johnny vd Laar’s picture

i'm having the same issues but the weight of my modules are still at 0.

i am using this in combination with taxonomy access and domain access tho.

the fix in #18 solved part of the problem as i can see the revision pages again now.

to fix the sql errors i've done this:
if($op == 'view revisions') $op = 'view';
if($op == 'edit revisions') $op = 'update';

i guess i have a very complicated situation and i'm nearing a deadline so i've done some temporary quick fixes. if i get to it then i'll search for some better solutions.

Status: Postponed (maintainer needs more info) » Closed (fixed)