Repeatable: Always
Steps to repeat:
1. Create two Content types for example A and B with each one relation select field, using the correct relation type
2. Create some content

Expected Results:
no errors

Actual Results:
If I create a new content the following error appears:

Notice: Undefined offset: 0 in _relation_select_field_widget_form() (Zeile 546 von /var/www/drupal_sites/opacc.ch/sites/all/modules/contrib/relation_select/relation_select.module).

Comments

fozzy’s picture

Subscribing

steveoliver’s picture

Status: Active » Closed (fixed)

Fixed in 37b291c. Thanks, daniela.

fozzy’s picture

Thanks for the patch. I applied it and the Undefined offset message disappeared.

Unfortunately I'm getting now the following message : Undefined index: entity_id in _relation_select_field_widget_form() (line 550 of relation_select.module).
Obviously related to the patch...

robertom’s picture

Title: Content Creation with Relate Fields: Undefined offset: 0 in _relation_select_field_widget_form() » Content Creation with Relate Fields: Undefined index: entity_id in _relation_select_field_widget_form()
Status: Closed (fixed) » Needs review
StatusFileSize
new697 bytes

Sorry for my bad english.

After updated to last git version, I have: Undefined index: entity_id in _relation_select_field_widget_form()

I would propose a patch that has implicit is_object and is_array

fozzy’s picture

Patch #4 applied. Looks ok.

Thanks

robertom’s picture

reroll patch #4

robertom’s picture

reroll patch #6

steveoliver’s picture

maybe something like this would be a more proper check?

robertom’s picture

Sorry for my bad english

If isset($items[$delta]->rid) is true $items[$delta] must be an object

and

if isset($items[$delta]['relation_id'] is true $items[$delta] must be an array

I think additional check is redundant, but the fix will work well also with extra check... so you could commit what you prefer ;)

steveoliver’s picture

Status: Needs review » Fixed

I was thinking we may get "Trying to get property of non-object" errors in the case where $items[$delta] is an array. But you're right, isset won't throw that error -- but calling the property without checking *would* (as you pointed out in #4) :)

Committed #7 in 559ec71.

Thanks, @robertom.

Status: Fixed » Closed (fixed)

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