'Access denied' when trying to edit a revision
| Project: | Save As Draft |
| Version: | 6.x-1.0-beta1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
I save a page as a draft and then get 'This post has one or more draft revisions: view list of revisions.' I click on the link to view the list of revisions and get the list okay. If I click on a revision made with 'Save as draft' I get:
You are currently viewing a revision of this post created on [date] by [username].
* Edit revision
* Publish revision
* Delete revision
Now when I click either 'Edit revision' or 'Publish revision' I get:
Access denied
warning: Invalid argument supplied for foreach() in /var/www/drupal/includes/menu.inc on line 258.
You are not authorized to access this page.
I'm the admin of the site so I have all permissions, including permission to view and edit revisions, so I don't know why this happens. Any ideas?

#1
I'm getting the same issue - using drupal 6.6. - README.txt still states that the module is designed to work with D5, maybe it's related.
#2
This patch 'partly' resolves the access issue at least (which was also happening when publishing revisions), now when i try to edit a revision i get :
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'node_form' was given in /usr/share/drupal6/includes/form.inc on line 366.
and the edit form is not rendered.
<?php
--- save_as_draft.module.orig 2009-09-08 08:43:40.000000000 +0000
+++ save_as_draft.module 2009-09-08 09:14:22.000000000 +0000
@@ -62,7 +62,7 @@
'title' => 'Edit revision',
'page callback' => 'save_as_draft_edit',
'page arguments' => array(1, 3),
- 'access arguments' => TRUE,
+ 'access arguments' => array('administer nodes'),
'type' => MENU_CALLBACK,
);
@@ -71,7 +71,7 @@
'title' => 'Publish revision',
'page callback' => 'save_as_draft_publish',
'page arguments' => array(1, 3),
- 'access arguments' => TRUE,
+ 'access arguments' => array('administer nodes'),
'type' => MENU_CALLBACK,
);
// }
?>
#3
And finally, it works (but surely not the best fix) if i add this before drupal_get_form() :
<?phpmodule_load_include('inc', 'node', 'node.pages');
?>
So the final diff to fix the issue is the following, but i'm not sure about the module_load_include.. :
<?php
--- save_as_draft.module.orig 2009-09-08 08:43:40.000000000 +0000
+++ save_as_draft.module 2009-09-08 11:20:48.000000000 +0000
@@ -62,7 +62,7 @@
'title' => 'Edit revision',
'page callback' => 'save_as_draft_edit',
'page arguments' => array(1, 3),
- 'access arguments' => TRUE,
+ 'access arguments' => array('administer nodes'),
'type' => MENU_CALLBACK,
);
@@ -71,7 +71,7 @@
'title' => 'Publish revision',
'page callback' => 'save_as_draft_publish',
'page arguments' => array(1, 3),
- 'access arguments' => TRUE,
+ 'access arguments' => array('administer nodes'),
'type' => MENU_CALLBACK,
);
// }
@@ -321,6 +321,7 @@
*/
function save_as_draft_edit($nid, $vid) {
$node = node_load($nid, $vid);
+ module_load_include('inc', 'node', 'node.pages');
drupal_set_message(t('You are currently editing a revision of this post created on @date by @author.', array('@date' => format_date($node->changed, 'small'), '@author' => $node->name)));
return drupal_get_form($node->type .'_node_form', $node);
}
?>
#4
That's great! It seems to work fine on D6.13, at least on my install. Thanks a lot for that :O)