This is an issue in the 3.x branch -

To see the issue, create a group, and a menu for that group.

Create a node in that group, and add it into the menu - the node appears in the menu as it should.

Then, edit the node, and after the node is saved, it is no longer in the menu.

This issue *is not* present as of commit a1a2ff6 in the 3.x branch.

Somewhere between a1a2ff6 and commit dbf7a18 this bug was introduced into the 3.x branch. You can eliminate the bug described in this issue by doing a git checkout of a1a2ff6.

Comments

bonobo’s picture

Some additional testing shows that the bug is not present as of f6cbebf

Given that dbf7a18 is the next commit on the 3.x branch, either this commit introduced the bug, or I'm missing something obvious.

azinck’s picture

StatusFileSize
new926 bytes

The problem only occurs if you have the content type configuration set to not allow the node to be added to any menus. Here's a shot at a patch against 3.x-dev. I didn't dig too deeply but a better solution would be to see if there's any way to make menu_parent_options() pick up our OG menus properly.

azinck’s picture

Status: Active » Needs review
justindodge’s picture

Version: 7.x-3.x-dev » 7.x-2.x-dev
StatusFileSize
new1.8 KB

I can corroborate azinck's description of the conditions that the issue occurs. This is also an issue back in 7.x-2.x. I also agree about the suggestion for a better solution that shoots at the root of the issue, this is my solution which also helps restore the interface for allowing the user to place the node in the menu.

I think the comments in the code document it as well as I could reexplain, check it out.

rv0’s picture

This code might be better in hook_node_prepare?

Also:

The problem only occurs if you have the content type configuration set to not allow the node to be added to any menus.

This known architectural issue has had some mentions in previous issues.

azinck’s picture

This code might be better in hook_node_prepare?

Which code and why? justindodge and I took rather different approaches.

rv0’s picture

any code that add the needed info when there is no menu enabled

re:

The problem only occurs if you have the content type configuration set to not allow the node to be added to any menus.

imo, we should have a setting to enable nodes for use with og_menu.
I also thought about providing a widget for og menu specifically, instead of "hacking" the normal menu widget.
Ideas, thoughts and opinions are welcome. This may change a lot of things.

justindodge’s picture

@rv0:

This code might be better in hook_node_prepare?

I think the suggestion for hook_node_prepare may be a good one, this could prevent the need for menu.module's hook_form_alter to be potentially called twice and so make things a little more efficient.

imo, we should have a setting to enable nodes for use with og_menu.

Actually, my first approach to this task was to alter the content type administration form to add a new "pseudo" menu called "OG Menus". This would essentially have been the first condition checked before executing the rest of my patch. I like that the user still wouldn't see all of the OG Menus in the form and be potentially overwhelmed with clutter, but still have a control per content type for allowing nodes into the OG Menus. I think this is the best approach that I can come up with, but I was finding some complication with the implementation and opted to go for this incremental improvement which at least solves the original issue (and was more time permitting).

I think it would be over doing it to have per-node control, at least by default - but I'm not sure if were implying this.

I also thought about providing a widget for og menu specifically, instead of "hacking" the normal menu widget.

Personally I'm pretty happy with the approach of having the widget in the normal location - it keeps the UI familiar and less confusing. I feel like the "hacking" is kept to a minimum since we are still relying on the menu module to fill in the form values - a widget duplicating (or nearly so) menu.module's widget actually feels more hacky to me. Plus, I think your suggestion for hook_node_prepare makes it feel altogether less hacky in general. Just my two cents.

rv0’s picture

Status: Needs review » Needs work

Sounds reasonable.

I tried the content type administration approach a few times too, but got stuck and/or ran out of time for it too often.

I'm setting this to needs work and hopefully we'll find a way to cleanly solve this issue once and for all for the 7.x branch.
The latest 2 commits might have broken the current patches (have yet to try)

bulldozer2003’s picture

Status: Needs work » Needs review

I provided a patch in #1872228: Rewrite og_menu_form_node_form_alter() that partially rewrote some of og_menu_node_prepare(). With that patch, I do not suffer this bug.

rv0’s picture

Title: Menu affiliation lost when editing a node in a group » Menu affiliation lost when editing a node in a group, improve menu settings on administer node type form.
Version: 7.x-2.x-dev » 7.x-3.x-dev
Priority: Normal » Major
Status: Needs review » Needs work

Patch from #10 has been committed but the bug is still there.

Changing version
For 7.x-2.x-dev => Just enable a menu for the content type, and only allow group users to "administer menus" on group level.
The plan is to fix this in 7.x-3.x-dev, then perhaps backport it

Upping priority

Changing to more descriptive title

marking #1801204: Improve OG Menu activation in Menu Settings (administer node type form) as duplicate

Setting to needs work

azinck’s picture

rv0: my fix in #2 is not very ambitious. I change very little and do not attempt to load the interface for menus on the node edit form (as justindodge attempts). My patch simply prevents the problem of a node getting removed from the OG menu when a node is edited. Getting my #2 in might be very easy low-hanging fruit. You could then try to tackle the broader interface and architectural problems later.

rv0’s picture

@azinck
If you like, this bug can be circumvented by just enabling a menu for the node type.. There's no side effects in doing that, besides that users with global administer menu permission will also see those menu options.

The high-hanging fruit is usually a lot more tasteful.

azinck’s picture

rv0: Your call. The current behavior is destructive if people don't know about the quirk. My simple fix prevents such destruction while awaiting a more full-fledged fix.

bonobo’s picture

RE: "The current behavior is destructive if people don't know about the quirk."

Agreed. The effects of this bug on people who are unaware of how to avoid it is pretty large. +1 on a simple fix that eliminates the issue while a more comprehensive fix gets completed.

bulldozer2003’s picture

The menu affiliation bug, I am not suffering that in 3.x, is that a 2.x bug?

rv0’s picture

@bulldozer2003: i think you need a user without administer (og) menu permissions to test it.
I'm able to reproduce the issue on my development site, a fix is near.

rv0’s picture

Status: Needs work » Fixed

This should be fixed in latest commit:
http://drupalcode.org/project/og_menu.git/commit/8baa699

This introduces a setting on the node type form to enable OG Menu for the node type.
Run update.php to enable this for all your group types, and the bug will be gone.
Also updated the readme file.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Fixing typo

anthonys’s picture

Issue summary: View changes

I'm still experiencing this with version 3.1, and the main menu workaround worked for me. It's not on a clean install though and makes use of subgroups, menu attributes and special menu items.

rv0’s picture

subgroups might be your problem anthonys.. og_menu code relies heavily on og_context function, which may not be set properly with subgroups.