Download & Extend

'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:closed (fixed)

Issue Summary

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?

Comments

#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() :

<?php
module_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)

#5

@landry could you submit this as a patch please?

#6

Sure, here you are.. but i'm still not sure the module_load_include() call is correct.

AttachmentSize
save_as_draft_570074.diff 1.07 KB

#7

Status:active» needs review

I've done a fair few changes which incorporate #6 with other changes, please grab from CVS and test, or wait for DEV build to be updated in the next few hours.

I've tested it fairly extensively, but would like some feedback from others before commiting it as a stable.

#8

I did a fair amount of testing with the DEV build and it seems stable. I was able to replicate the original error, and the current DEV fixed it. I went back and forth with a lot of different revisions and drafts, on various nodes, and did not receive any errors.

#9

Status:needs review» fixed

Grab 6.x-1.0-beta2

#10

Status:fixed» closed (fixed)

fixed

#11

Status:closed (fixed)» fixed

#12

Status:fixed» closed (fixed)
nobody click here