Book revision page showing access denied if no revision present I've edited the content type Book to "create a new revision" whenever user publishes the page (while creation and editing the page).


I have created a custom menu Book revisions, with path node/[node:nid]/revisions using menu token module. It renders http://site-url/4/revisions with 4 as the node id of current node.
I am using Nice menus module to create the menu block and have placed it on every book page so that user can see the revisions whenever he is on the book page.

When I first create a page, and click on this menu, it gives me Access denied page (I'm logged in as user1). But, the moment I edit the page and save it, it works as expected - showing the different revisions.
Requirement: I want to display "No revisions" instead of "Access denied" to users. How can this be done?
I'm also open to suggestions to hide the menu for the first time, and again show it as soon as a revision of the node is created.

Edit: I find that if a node is not revised (edited), node_revision table has only one vid for the nid of node; and if the node is revised the table contain one vid per revision.
Using this information and a database query, I think it would be possible to find out whether a node has revision. Something like  

$result = db_query('SELECT n.nid from {node_revision} n WHERE n.nid LIKE :uid',array(':uid' =&gt; arg(1)));    
$temp_var = 0;
foreach ($result as $result_item) {
  $temp_var++;
}
//If revisions are present $temp_var&gt;1
//Only one version present if $temp_var == 1
if($temp_var == 1) {
  //menu unset code goes here...
}


I am just not sure in which hook should I implement this.

EDIT: I'm using Diff module to enable the users to view the differences in two revisions.
If I understood this right, you have a (Nice) menu on node pages, and you've added the node/[node:nid]/revisions item to that menu. You're not actually listing revisions, just making a link to the revisions page, right?

If so, the problem is that the access callback for that menu item is hardcoded to return access denied if a node doesn't have revisions. Actually looks like this is being fixed for D8. Normally the tab wouldn't show, but it is in your case because you're creating the menu item in a different way, and the access is not checked when the link is printed. The solutions I can think of:


Replace the page with a view listing node revisions. Easy, but I don't know if you can replicate all the core revisions page functionality.
Create a wrapper menu item around the core revisions page using hook_menu(). Call it something else, like node/%node/revs. In the callback for that menu item, check if the node has revisions. If so, return the output of node_revision_overview($nid), the core function that generates that page. Otherwise, return 'No revisions'
Use hook_menu_alter() to take the existing revisions menu item (node/%node/revisions) and move it to your menu. Take a look at the definition of the menu item in node.module line 2043. You'll need to change it to not be a LOCAL_TASK and then use the menu_name property to tell it to get into your custom menu. I'm pretty sure this can work.