When editing an empty entityreference field as autocomplete:

Warning: Invalid argument supplied for foreach() in entityreference_field_widget_form()
#5 1522172_er-warning_5.patch599 bytesjrbeeman
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es). View
#1 0001-fixed-1522172-Invalid-argument-supplied-for-foreach.patch798 bytesaxel.rutz
PASSED: [[SimpleTest]]: [MySQL] 66 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


axel.rutz’s picture

Issue summary: View changes


axel.rutz’s picture

Status: Active » Needs review
798 bytes
PASSED: [[SimpleTest]]: [MySQL] 66 pass(es). View

we need a simple patch like this to prevent foreach eating NULL values.

pyrello’s picture

Patch from #1 appears to work.

amitaibu’s picture

Status: Needs review » Closed (cannot reproduce)

Sorry for the late reply... :)
Seems to be already resolved.

davidi’s picture

Is there a reason this patch was never applied. I am migrating one of our drupal sites and noticed that a developer had this patch code in our entityreference.module. Looking in the source repository, I don't see the fix merged in anywhere. Is it necessary? If so can the patch be applied in the next release?

jrbeeman’s picture

Title: "Invalid argument supplied for foreach" » Invalid argument supplied for foreach in entityreference_field_widget_form()
Status: Closed (cannot reproduce) » Needs review
599 bytes
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es). View

Re-opening as we ran into this issue during a Commons sprint. Commons uses a combination of OG, Entity Reference Prepopulate, and Entity Reference. In cases where a prepopulate argument isn't passed in the URL, we receive this warning. I believe the fix is simple: Don't assume $items has a value. Patch attached against 7.x-1.x.

khanz’s picture

facing the same issue..

daniel-san’s picture

Was receiving same error on creation of node where a prepopulate argument isn't passed in the URL.

Patch in #5 seems to work well.

Thank you for working on this.

micnap’s picture

Ditto daniel-san.

hefox’s picture

My guess is whatever is calling that function is suppose to be passing in $items an array and that the error may be from the calling function instead. Not experiencing this error so haven't looked inot

hefox’s picture

Issue summary: View changes