Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
After upgrading to 2.4 I get the following errors on node save:
Notice: Undefined index: #entity in og_form_group_reference_validate() (line 754 of xxx/sites/all/modules/contrib/og/og.module).
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7697 of xxx/includes/common.inc).
I could not reproduce it on a clean install but I will try. In the meantime, I'm attaching a patch.
Comment | File | Size | Author |
---|---|---|---|
#24 | 2143733-24.patch | 527 bytes | Angry Dan |
#21 | og-entity_key-2143733-21.patch | 998 bytes | dobe |
#13 | og-entity_key-2143733-13.patch | 1.21 KB | czigor |
#1 | og-entity_key-2143733-1.patch | 519 bytes | czigor |
Comments
Comment #1
czigor CreditAttribution: czigor commentedComment #2
czigor CreditAttribution: czigor commentedI succeeded to reproduce the error.
1. Install a minimal Drupal.
2. Enable og_ui (with all its dependencies) and field_ui.
3. Create a content type "Group" and select "Group" on the "Organic Group" tab on the content type edit page.
4. Add a Group node.
5. Create a content type "Page" and select "Group content" on the "Organic Group" tab on the content type edit page. Select 'Group' as bundle.
6. Remove the body field from Page so that the only remaining field is og_group_ref. The cardinality and requiredness of og_group_ref does not seem to matter.
6a. EDIT: Change the og_group_ref widget from OG Reference to Select.
7. Try to create a page by submitting the node/add/page form.
You should see a white error page with the following text:
Notice: Undefined index: field_mode in OgBehaviorHandler->validate() (line 246 of xxx/sites/all/modules/og/plugins/entityreference/behavior/OgBehaviorHandler.class.php).
Notice: Undefined index: #entity in og_form_group_reference_validate() (line 754 of xxx/sites/all/modules/og/og.module).
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7697 of xxx/includes/common.inc).
The problem comes from the core field_default_form() which creates $form['#entity'] only
However, $form['#node'] is always added by node_form().
EDIT: I left out one thing: The widget of the og_group_ref field must be 'Select', not the default OG Reference. It is not clear yet, whether selects should be allowed at all for og_group_ref fields. See #2141101: Plain core select widget does not work for og_group_ref fields.
Comment #3
bjcooper CreditAttribution: bjcooper commentedI've run into the same error. I can reproduce the problem as described and confirm that the patch fixes it (at least in my case).
Still keeping an eye on the other thread to see if using the 'select list' widgit will be allowed.
Comment #4
bjcooper CreditAttribution: bjcooper commentedAlso, I should mention that I got this when adding the Group Audience field to the core Polls node type, since it has no Body field.
Comment #5
jraviotta CreditAttribution: jraviotta commentedI experienced this error also. Patch in #1 solved the error
Comment #6
shushu CreditAttribution: shushu commentedComment #7
shushu CreditAttribution: shushu commentedComment #8
czigor CreditAttribution: czigor commentedWhy is this a duplicate? This is a different issue with a different patch.
Comment #9
shushu CreditAttribution: shushu commentedAs far as I can tell this issue happen since using the select widget instead of the OG widget.
If this issue still exist after solving #2141101: Plain core select widget does not work for og_group_ref fields then you are correct, and this should be handled separately.
Can you verify it still exist ?
Comment #10
czigor CreditAttribution: czigor commentedYes, it does exist. It is related to #2141101: Plain core select widget does not work for og_group_ref fields since it only happens when using the select widget but it is a different issue. Do the steps to reproduce in #2 not work for you?
Comment #11
shushu CreditAttribution: shushu commentedTrue, once removing the body field and using the select box widget, I was able to reproduce the problem and the patch solved it.
But then I tried to reproduce the scenario with non-node group content (using taxonomy term), and I wasn't able to reproduce either with and without the patch.
Debugging it, I think there is a problem in og_form_group_reference_validate() when it is doing:
I know it is not 100% related to the issue, but I won't want to push a fix in og_form_group_reference_validate() without being able to actually use it with non-node entities.
I will continue to investigate this.
Comment #12
czigor CreditAttribution: czigor commentedI think you're right. There are two problems in og_form_group_reference_validate():
What do you think?
Comment #13
czigor CreditAttribution: czigor commentedThe patch does the following:
Comment #14
czigor CreditAttribution: czigor commentedComment #16
czigor CreditAttribution: czigor commented13: og-entity_key-2143733-13.patch queued for re-testing.
Comment #17
shushu CreditAttribution: shushu commentedDo you have a scenario to use in order to reproduce situation #2 - entity inside og_audience field form element ?
Comment #18
czigor CreditAttribution: czigor commentedYes, it is the scenario described in comment #2. If (as most often is the case) $form['#entity'] is set this issue does not appear.
Comment #19
shushu CreditAttribution: shushu commentedComment #20
John Carbone CreditAttribution: John Carbone commentedThanks guys! I was seeing errors with og_form_group_reference_validate() throwing undefined index warnings when saving users and this patch cleared it up. I couldn't find a more specific issue so I'm including the errors I was getting in case anyone else finds this thread.
The errors:
Notice: Undefined index: #entity in og_form_group_reference_validate() (line 737 of sites/all/modules/contrib/og/og.module).
Notice: Undefined index: field_mode in OgBehaviorHandler->validate() (line 254 of sites/all/modules/contrib/og/plugins/entityreference/behavior/OgBehaviorHandler.class.php).
Comment #21
dobe CreditAttribution: dobe commentedUnfortunately, this patch needs reviewed again. Patch #13 removes the check to see if empty($form_state[$entity_type]). This causes an issue when dealing with single field forms (The FAPE module). This causes problems on fields that are not OG. Where the entity type being passed comes up null and throws:
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids()
-Jesse
Comment #22
Jeff Veit CreditAttribution: Jeff Veit commentedPatch in #21 works for me.
I'm encountering the error because I'm using the Field Permissions module, and some users do not have the rights to see or edit the list of groups.
Comment #23
maikeru CreditAttribution: maikeru commented#21 also works for me when using checkboxes, when previously I was getting the error reported by OP
Comment #24
Angry Dan CreditAttribution: Angry Dan at Deeson commentedIsn't it easier to just define
#entity
inog_field_attach_form()
?This fixed the issue for me, and seems easier than grepping around the built form.
Comment #25
drupal3013 CreditAttribution: drupal3013 commentedThe patch on comment Number 24
worked for me
Comment #26
dtarc CreditAttribution: dtarc at Affinity Bridge commentedWe're also using the patch in #24 successfully.
Comment #27
hbensalem CreditAttribution: hbensalem commented+1 to patch #24 works great for us
Comment #28
amitaibuMerged, thanks.