I found a quite annoying error. When publish or reverting a node that is a parent in a Drupal menu, the node is removed from the menu and its child nodes are then promoted up to the same level as the parent.

Example:

*Home
*Node Reverted
   *Child 1
   *Child 2
   *Child 3
*Contact Us
*FAQ

Reverting or publishing "Node Reverted" results in this:
*Home
*Child 1
*Child 2
*Child 3
*Contact Us
*FAQ

Comments

rdeboer’s picture

Hi JEmbry,
When you say "publish a node" do you mean "publish the latest revision in favour of the current published revision" or "publish a not yet published node"? In the latter case are we talking about the latest and current revision being published (for instance a node with a single revision) ?
Rik

JEmbry’s picture

Yes, when publishing the latest revision over the current published revision, the node has multiple revisions.

erarcham’s picture

Version: 7.x-1.4 » 7.x-1.5

Hello,

This bug is still active in this newest release, I was wondering if this is still being investigated?

pbz1912’s picture

Version: 7.x-1.5 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new769 bytes

I fixed this in the same way that paths and pathauto is fixed.

rdeboer’s picture

Thanks for the path pbz1912!
Rik

rdeboer’s picture

Assigned: Unassigned » rdeboer
Status: Needs review » Fixed

Patch applied with attribution.
Available in 7.x-1.x-dev
Thanks Laura.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Spacing issues

lwalley’s picture

Issue summary: View changes

Using a combination of pathauto and pathauto persist modules with menu-link token patterns results in the generation of an incorrect alias if menu item is removed from the node, as is the case with this patch in comment #4.

At the moment _revisioning_publish_revision() only prevents the update of path alias if pathauto is not set. Pathauto persist module sets pathauto on entity load, and if it sets pathauto to 1 then pathauto module will go ahead and create the alias. If the alias includes menu item tokens in its pattern and the menu item has been removed then the new alias will be missing those bits.

So, what is the best approach for dealing with this? Given this patch prevents menu item from being updated on publish and code exists to prevent path alias from being updated on publish, is it safe to assume that the best approach is to also prevent path alias from being updated on publish when pathauto persist is in the mix, i.e. always set pathauto to FALSE here regardless of what its persistent setting is?

Many thanks in advance for any thoughts on this.

On a separate note, I notice in the patch in comment #4 #1698024-4: Publishing or reverting node that is in menu that there are two if statements that appear to be the same but one sets menu to an array and the other to an empty string, and I was wondering what the intention was behind the second one? Patch code added below for reference:

+  // Make sure the menu, if present, is not changed when publishing.
+  if (!isset($node_revision->menu)) {
+    $node_revision->menu = array(
+      'enabled' => '',
+      'mlid' => '',
+      'link_title' => '',
+      'link_path' => '',
+      'description' => '',
+    );
+  }
+  elseif (!isset($node_revision->menu)) {
+    $node_revision->menu = '';
+  }
lwalley’s picture

Removing the patch in #4 from the revisioning module appears to address the broken menu tokens in the path alias which I described in my previous comment. I tried unsetting the path to prevent the alias from being recreated but unfortunately that breaks pathauto persist; pathauto persist saves the value of path['pathauto'] in pathauto_persist_node_update() so setting it to FALSE to avoid the alias creation is not an option.

In my use case, after I removed the patch, I was unable to recreate the problem of the disappearing parent menu item described in this issue. In my case the menu item was not set. If I set the menu item on the node in the pre publish hook then the menu item would disappear as described in this issue. I could not find any negative impact when the menu item was not set, alias tokens continued to work correctly presumably because token_node_menu_link_load() kicks in when menu is not set.

So, rather than setting menu to an array of empty values as done in the patch in #4, I instead replaced that patch with a simple unset($node_revision->menu), see attached patch. This appears to do the trick so far, I will continue testing.

cornelyus’s picture

I wanna make bump on this case.
I have same issue as lwalley, and had to use is patch.
Because of the code on revisioning_api, I am losing the path alias generated, because $node_revision->menu is set to empty. He won't find the tokens necessary.

chris burge’s picture

The patch committed in #4 is causing issues in my set up (when used in conjunction with OG Menu Single, the menu item weight gets reset to 0'). It can't work as it was intended to because the 'if' condition and the 'elseif' condition are identical. I don't understand that need to set empty values in the menu array. I think the approach taken in #9 is better.