Closed (fixed)
Project:
Module Grants
Version:
6.x-3.3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Dec 2009 at 20:46 UTC
Updated:
2 Jan 2014 at 19:06 UTC
Jump to comment: Most recent
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
Comment #1
rdeboerThanks 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?
Comment #2
ccdechesney commentedThat'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 $
Comment #3
rdeboerLooks 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.
Comment #4
rdeboerComment #5
Anonymous (not verified) commentedI 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:
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?
Comment #6
Anonymous (not verified) commentedMy statement above possibly is irrelevant as I'm also getting sql errors plus others when viewing path: page/200/revisions/50/view
Comment #7
Anonymous (not verified) commentedLooking 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:
Comment #8
rdeboerJust 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?
Comment #9
Anonymous (not verified) commentedYep 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:
Comment #10
Anonymous (not verified) commentedPerhaps 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 $
Comment #11
Anonymous (not verified) commentedSince 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:
Comment #12
Anonymous (not verified) commentedOr rather:
Comment #13
Anonymous (not verified) commentedDoesn't address other errors when viewing a revision:
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.
Comment #14
Anonymous (not verified) commentedTo follow up. No errors after reverting back to Revisioning 6.x-2.3 and Module Grants 6.x-2.x-dev.
Comment #15
rdeboerDamn... :-(
Comment #16
Anonymous (not verified) commentedJust 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?
Comment #17
Anonymous (not verified) commentedThe 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:
Not sure if that is relevant? It seems node_page_view is missing a $node.
Comment #18
Anonymous (not verified) commentedSo 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: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?
Comment #19
Anonymous (not verified) commentedSo 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.
Comment #20
rdeboerPhew! 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?
Comment #21
Anonymous (not verified) commentedYes, solved. All errors appear to have been addressed.
Comment #22
rdeboerGreat. I'll close this, as it seems to have been specific to the db on your install, so less relevant to others.
Comment #23
Johnny vd Laar commentedi'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.