Problem/Motivation
In the use case that follows, there is a flag exposed to users on the node edit form that fires a hook_node_presave to turn-on/off og menu.
If a site uses any type of workflow, then resaving a revision or anything that isn't the current live revision and which has OG Menu's turned off will cause the og_menu to be deleted. The live revision has og_menu turned on, just not the revision. That isn't good. Editing a revision or something about to be staged to live shouldn't effect the live revision.
Proposed resolution
Confirm that the currently saved revision in hook_node_update is also the current revision.
Remaining tasks
Review
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Original report by @fuerst
When reverting a node revision for a OG node the OG menu of that node will be removed. That happens at og_menu_nodeapi() in the $op case update: There is no $node->og_menu set at this stage. Calling $node->og_menu = og_menu_get_group_menus(array($node->nid)) may fix this but I'm unsure if this causes a conflict when updating a node the standard way (by editing & saving).
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | og_menu-reverting_node_revision-1509538-13.patch | 2.47 KB | heddn |
| #10 | og_menu-1509538-10.patch | 619 bytes | fuerst |
| #2 | og-menu-deleting-on-revisions-1509538-6022610.patch | 1 KB | LSU_JBob |
Comments
Comment #1
justindodge commentedI was having a similar issue with 7.x-2.0.
A simple fix was to add a check in og_menu_node_update:
The same could be applied to the equivalent hook_nodeapi function in D6.
The problem with what's going on in this function in general is, as stated by the OP, that
$node->og_menuis never available, and so the resulting condition acts incorrectly. The problem with my solution is that it although it handles one situation with node revisions, it will still fail when og nodes are saved programmatically, vianode_savefor example.This variable is populated in
og_menu_node_prepare(), which is a hook only used for the node form. A better place for this might be the 'load' function of nodeapi, but I haven't had time to consider the consequences of implementing this and how it would affect the behavior of the form posts.A final thought for solution would be to change the conditionals in hook_node_update. Right now it's:
but a safer alternative would be to do nothing if the og_menu property is not set at all, and be more explicit about what it contains:
Hope that helps...
Comment #2
LSU_JBob commentedtook justindodge's changes and rolled them into a patch for 7.x-3.x
Comment #3
rv0 commentedplease check if this still happens now
#1393958: Menus are lost when using Panelizer module might have fixed this.
re-open if not.
Comment #5
fuerst commentedI had filed the bug for version 6.x-2.4. Since #1393958 covers 7.x only I assume the bug still exists in 6.x
Comment #6
troybthompson commentedWould this be related to the menu being deleted when creating a new draft using workbench_moderation? I'm using the 7.x-3.x version.
Comment #7
rv0 commented#6 yes.. is this happening with latest 3.x version?
Comment #8
troybthompson commentedI apologize, it looks like I just missed the latest version. Yes, the new version fixes it in 7. Thanks!
Comment #9
rv0 commentedgreat to hear
leaving this open for 6.x
Comment #10
fuerst commentedLooks like there is no easy way in Drupal 6 to check if a node is reverted or just updated. I found when
$node->revision_uidand$node->old_vidboth are set the node was reverted. That is kind of hacky I guess. Patch is attached anyway.Comment #11
fuerst commentedPatch in #10 is against latest 6.x-2.x-dev
Comment #12
osopolarPossibly the same issue as in #1330550: OG Menu settings get lost on custom node_save()?
Comment #13
heddnLet's fix this on 7.x first, then we can backport.
Comment #14
rv0 commentedStrange, from the comments above you would think it didn't happen in 7.x... Seems like some regression was introduced somewhere.
Basically all this patch adds is this, right?
Comment #15
heddnBasically, yes. That is all it does. It doesn't catch all workflow issues. In fact, it doesn't catch what I needed for my site's specific implementation at all. However, I'm hoping it will catch other's. Maybe we could have someone test with workbench moderation?
Comment #16
rv0 commentedTried to reproduce it with core revisions and also with workbench moderation;.. Wasn't able to reproduce the issue.
Anyone have detailed instructions on how to reproduce this in D7?