To recreate:
1) log in as an admin with "administer groups" permission
2) in a group where the logged in user is not a member, create new content using a required group audience field with entity prepopulate via the URL.
3) Despite not being a member, the group appears in the 'default' field as part of the combo audience field for group administrators.
5) Click 'upload' on a file/image field within the group content node form. The default field will still show the prepopulated group in 'your groups'. (If no ajax submit buttons are clicked, saving works.)
6) Attempt to save.
7) Your groups is cleared, and the node form throws the following error: "An illegal choice has been detected. Please contact the site administrator." - from line 1388 in includes/form.inc - because the value of the prepopulated group is no long in the options for 'your groups'.
8) This error is compounded because after the error, it's no longer possible to select the prepopulated group in EITHER 'your groups' or 'other groups'. If selected in 'other groups', the referenced group throws "The referenced group (@type: @id) is invalid." from OgBehaviorHandler.class.php because the prepopulated value is not listed in the results from entityreference_get_selection_handler() any longer.

This issue is specific to fields with 'skip_perm' configured and users with the matching permission. It occurs because entityreference_prepopulate_field_attach_form() has a continue; statement for users with 'skip permissions' BEFORE executing the code that would store the value in the $form_state.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jastraat’s picture

Status: Active » Needs review
FileSize
1.49 KB

Patch against current dev is attached. To fix this error, you need both the current dev version of this module + this patch.

amitaibu’s picture

@HelenaEksler can you please review.

HelenaEksler’s picture

@amitaibu
The patch looks fine as to me.
I've repeated the described way, got the error without patch and the patch has solved the problem.

jastraat’s picture

@HelenaEksler - could you mark this reviewed?

amitaibu’s picture

jastraat’s picture

@amitai - not quite. This patch simply moves a group-admin-only section of code (e.g. if ((!empty($settings['skip_perm'])) below the already existing code in the OG dev branch with the comment
// Store prepopulated values in the form state to make them persistent,

The error in this issue is specific to OG admins who can skip permissions, and it doesn't matter what fallback action is selected for pre-populate.

"Not hiding or disabling the Groups Audience field" prevents the error in #1958800 - but there is no work around for this admin-only issue.

amitaibu’s picture

Hi Jess(y) :)

Keeping my promises -- I've tried to reproduce the error on a clean installation but couldn't - possibly because I wasn't to reproduce exactly your environment. Can you attach a db dump of a clean installation and a set of simple steps to recreate?

jastraat’s picture

FileSize
288.26 KB

Thanks Amitai!

I've attached the DB of a fresh Drupal install with the following modules:

Drupal core 7.37

Chaos tools (ctools) 7.x-1.7
Entity Reference (entityreference) 7.x-1.1+4-dev (latest dev)
Entity reference prepopulate (entityreference_prepopulate) 7.x-1.5+5-dev (latest dev)
Organic groups (og) 7.x-2.7+30-dev (latest dev)
Organic groups context (og_context) 7.x-2.7+30-dev (latest dev)
Organic groups UI (og_ui) 7.x-2.7+30-dev (latest dev)
Entity API (entity) 7.x-1.6
Views (views) 7.x-3.11
Views Bulk Operations (views_bulk_operations) 7.x-3.2

I've created an example group at node one that this admin is not a member of.

login: admin/admin

To recreate, login and go to yourdomain.com/node/add/article?og_group_ref=1

Then follow the steps in this issue to recreate the error.

  • amitaibu committed 16d7d9f on 7.x-1.x authored by jastraat
    Issue #2447657 by jastraat, HelenaEksler: ajax submit button breaks...
amitaibu’s picture

Status: Needs review » Fixed

Merged, thanks.

@jastraat, See you in the issue queues ... :)

Status: Fixed » Closed (fixed)

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