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?

CommentFileSizeAuthor
#6 save_as_draft_570074.diff1.07 KBlandry

Comments

landry’s picture

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.

landry’s picture

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.

--- 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,
   );
 //    }
landry’s picture

And finally, it works (but surely not the best fix) if i add this before drupal_get_form() :

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.. :

--- 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);
 }
beasley’s picture

That's great! It seems to work fine on D6.13, at least on my install. Thanks a lot for that :O)

realityloop’s picture

@landry could you submit this as a patch please?

landry’s picture

StatusFileSize
new1.07 KB

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

realityloop’s picture

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.

davidhernandez’s picture

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.

realityloop’s picture

Status: Needs review » Fixed

Grab 6.x-1.0-beta2

realityloop’s picture

Status: Fixed » Closed (fixed)

fixed

realityloop’s picture

Status: Closed (fixed) » Fixed
realityloop’s picture

Status: Fixed » Closed (fixed)