I came across this issue when doing a piece of work for a client that attempts to display revision pages as if they were the node page. One issue I had was getting menu blocks (using the menu_block module) to display on the revision pages. I managed to get it working with a bit of trickery, but I kept having an issue where the menu block would not display when viewing the revision that was currently published, but would display on any other revision page (quite counter-intuitive right?). Today I've had some time to debug into this and it's lead me to an interesting discovery:

Basically what I noticed was that the menu item did not have active_trail set to TRUE when returned from menu_tree_page_data(). I tracked this down to the fact that menu_link_get_preferred() was returning the menu item from the Navigation menu rather than from Main menu (again very weird). Debugging further into this function, I noticed that the $preferred_links array did not have the main-menu menu item in it, hence why it wasn't being returned and why the active trail wasn't being set (since menu_link_get_preferred() was returning FALSE which is what causes active_trail to be empty - you can see this at line 1261 of includes/menu.inc).

The only way the main-menu item could be excluded from the $preferred_links array is on line 2517 of includes/menu.inc where after _menu_translate() is run over the $candidate_item the access key is set to false (just a note on both published revision pages and non-published revision pages at this point all variables hold the same values - $path_candidates, $menu_names).

So, inside _menu_translate the _menu_check_access function is called, which then calls whatever the access_callback is that is defined on the router item. In this case it's _revisioning_view_edit_access_callback(). Maybe this is where things are going wrong, because what is actually denying access and causing this whole issue is the following conditional:

    if ($load_op == REVISIONING_LOAD_CURRENT && $vid == $node->current_revision_id) {
      // Suppress 'View current' and 'Edit current' tabs when viewing current.
      return FALSE;
    }

On both the published revision page and any other revision page of a node, the $load_op is 0 (i.e REVISIONING_LOAD_CURRENT), for the non published revisions all of these conditionals fail so it falls through to the final return value of _revisioning_access_node_revision() but for the published revision, the above conditional evaluates to TRUE and the main-menu item is denied access.

Here's some screenshots to show what's going on now:

Published revision:

Published revision


Unpublished revision:

Unpublished revision


I don't think this conditional is the only thing that's causing issues, if I simply change it to return TRUE, the breadcrumbs are correctly fixed but the menu item is not marked as active so the child is not shown in the left hand navigation. Nevermind, this was a caching issue, after clearing cache the trial showed correctly :)

I'm hoping someone else has more ideas about what else could be going on and potential fixes! Cheers

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

acbramley’s picture

Issue summary: View changes
acbramley’s picture

Issue summary: View changes
acbramley’s picture

Issue summary: View changes
acbramley’s picture

Status: Active » Needs review
FileSize
1.58 KB

I've come up with a fix that seems to work well, although I'm a bit hesitant as it changes the access callbacks used in hook_menu_alter to make sure _revisioning_view_edit_access_callback() is only used on the local task tabs (which it seems is what that function is intended for, and a sudo wrapper for _revisioning_access_node_revision()).

Another solution was proposed by a colleague where instead of explicitly denying access to a menu item, we use hook_menu_local_tasks_alter() which could be done if this approach breaks anything else.

Patch is attached, this definitely needs some rigorous testing :)

RdeBoer’s picture

Thanks for all this Adam!

Agree with you that it needs rigorous testing as changing of access rules may have some unwanted side-effects.
I was just about to create a new release especially after the great and much needed fix for #2023375: Revisioning: rules integration broken, so I'm not sure whether to hold off on that or to roll an official release while "maturing" this fix as a dev snapshot.

Rik

acbramley’s picture

@RdeBoer I think going ahead with the stable release for the rules integration fix and getting some further testing on this in a dev release would be best since it's probably not quite as important (the existing access callbacks have been there since 2011 and it's probably a small use case for what I'm doing)

acbramley’s picture

Bump, just encountered this bug again (after the module was updated without the patch) and spent a while debugging it again, only to google and find my own issue again.

Time for a beer.