Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When editing an empty entityreference field as autocomplete:
Warning: Invalid argument supplied for foreach() in entityreference_field_widget_form()
Comment | File | Size | Author |
---|---|---|---|
#5 | 1522172_er-warning_5.patch | 599 bytes | jrbeeman |
#1 | 0001-fixed-1522172-Invalid-argument-supplied-for-foreach.patch | 798 bytes | geek-merlin |
Comments
Comment #0.0
geek-merlincorrection
Comment #1
geek-merlinwe need a simple patch like this to prevent foreach eating NULL values.
Comment #2
pyrello CreditAttribution: pyrello commentedPatch from #1 appears to work.
Comment #3
amitaibuSorry for the late reply... :)
Seems to be already resolved.
Comment #4
davidi CreditAttribution: davidi commentedIs 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?
Thanks
Comment #5
jrbeemanRe-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.
Comment #6
khanz CreditAttribution: khanz commentedfacing the same issue..
Comment #7
daniel-san CreditAttribution: daniel-san commentedWas 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.
Comment #8
micnap CreditAttribution: micnap commentedDitto daniel-san.
Comment #9
hefox CreditAttribution: hefox commentedMy 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
Comment #9.0
hefox CreditAttribution: hefox commentedcorrection
Comment #10
Chris Matthews CreditAttribution: Chris Matthews commentedThe 6 year old patch in #5 to entityreference.module does not apply to the latest 7.x-1.x-dev and if still relevant needs a reroll.