When Entity Reference is interacting with different modules, can produce the following error:

Notice : Undefined variable: element in entityreference_field_formatter_settings_form() (line 1141 in /sites/all/modules/entityreference/entityreference.module).

I found it is given because $element is display type is none of the expected ones. I have added a simple check to avoid returning $element if not set.

Comments

geoffreyr’s picture

This seems to be triggered when selecting Entity ID as the display type. Currently noticing this while I try and Formatter Field working with Paragraphs - there's no initialisation for $element taking place in this function.

geoffreyr’s picture

Status: Active » Needs review
StatusFileSize
new526 bytes

Here's a really tiny patch that should address the issue.

damienmckenna’s picture

devin carlson’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

This is very easy to run into while using the Entity Embed module.

The one-line patch in #2 applies cleanly to Entity Reference 7.x-1.x and ensures that $element is always defined. This is the same approach taken by the example implementation of hook_field_formatter_settings_form() in field_ui.api.php.

The last submitted patch, entityreference_2314339.patch, failed testing.

jenlampton’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new566 bytes

Patch in #2 didn't apply to 7.x-1.x-dev for me. Rerolled.

Status: Needs review » Needs work

The last submitted patch, 6: entityreference-undefined_variable-2495405-6.patch, failed testing.

jenlampton’s picture

Status: Needs work » Needs review
StatusFileSize
new526 bytes

Uploading previous patch to see if that passes tests, maybe my local branch is borked?

jenlampton’s picture

Status: Needs review » Reviewed & tested by the community

yeah, looks like it. setting back to RTBC.

devin carlson’s picture

Status: Reviewed & tested by the community » Fixed

Re-tested #2 and committed it to Entity Reference 7.x-1.x.

Status: Fixed » Closed (fixed)

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