When og_menu is enabled and no ogmenu instances exist, a fatal error occurs when deleting an OG group.

Cause:
og_menu_entity_delete() searches for ogmenu instances by the property og_audience, which does not exist.

Solution:
Fix the fetching of ogmenu_instance in the og_menu_entity_delete() hook.

So far I didn't find the connection between ogmenu_instance and an OG group to fix this issue.

Comments

lennartvv created an issue. See original summary.

fernly’s picture

Issue summary: View changes
fernly’s picture

og_audience field only exists as of the creation of the first ogmenu_instance. As long as there is no data for ogmenu_instance, the fatal error will occur on deletion of an OG group.

This patch should fix this.

fernly’s picture

Status: Active » Needs review
ducktape’s picture

Status: Needs review » Reviewed & tested by the community

I think it would be better to check if the og_audience field exists, but this works for the described behavior.

fernly’s picture

True, not all cases would be covered. I added a new patch that catches the error and simply ignores it because it's not relevant in this case.

fernly’s picture

StatusFileSize
new1.11 KB

Placed the use statement in the right spot.
Should be ready to commit.

pfrenssen’s picture

Status: Reviewed & tested by the community » Needs work

I'm not sure if this is the right approach. An `EntityStorageException` might also be thrown while deleting one of the menu instances, in which case this will be silently ignored and all following instances will remain orphaned.

Also from the issue summary it is suggested that the exception is thrown when "og_menu_entity_delete() searches for ogmenu instances by the property og_audience" so I am guessing this happens in the $storage->loadByProperties() call, but this method is not supposed to throw any exceptions. It should return an empty result.

Can you provide a backtrace or a failing test to get more insight in what is exactly going wrong?

mpp’s picture

In the past this could be reproduced as:
- set delete_orphans to FALSE
- create a group
- delete its ogmenu_instance
- delete the group

But I can no longer reproduce this.

mpp’s picture

Status: Needs work » Closed (cannot reproduce)

@Fernly, try setting delete_orphans in og.settings to TRUE.

I can only guess that there was a bug in core in loadByProperties() that is now fixed.