hi, I've received the following error repeatedly when running deploy/cron:

Notice: Undefined index: target_type in entityreference_field_entity_dependencies() (line 139 of /home/path/to/sites/all/modules/entity_dependency/entity_dependency.core.inc).
Notice: Undefined index: entity keys in entityreference_field_entity_dependencies() (line 139 of /home/path/to/sites/all/modules/entity_dependency/entity_dependency.core.inc).

any thoughts of what may cause this?

thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein’s picture

Title: Undefined index: target_type in entityreference_field_entity_dependencies() » Dependencies are not added for entityreference fields (Symptom: "Undefined index: target_type")
Priority: Normal » Major
Status: Active » Needs review
FileSize
730 bytes

This seems to be more than just PHP notices - I'm seeing it result in entityreference fields not being processed for dependencies correctly at all.

The attached patch is based on a similar fix for the UUID module (see #1511274: entityreference_field_uuid_load() and entityreference_field_uuid_presave() use wrong target_type source) and seems to work.

Status: Needs review » Needs work

The last submitted patch, entity-dependency-entityreference-1545278-1.patch, failed testing.

David_Rothstein’s picture

Status: Needs work » Needs review
danielb’s picture

Status: Needs review » Reviewed & tested by the community

I have confirmed the bug, both the notice appearing and through debugging the iterator that the dependency is missing.
David_Rothstein's patch does indeed fix both.

skwashd’s picture

I have also tested this and found that it fixes the issue outlined above.

skwashd’s picture

jneubert’s picture

jneubert’s picture

I came across the issue described above, and the patch worked for me.

bricel’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
803 bytes

This is related to a change in Entity reference, $item['target_type'] has moved to $field['settings']['target_type'], so line 149, 150 should look like this:
$info = entity_get_info($field['settings']['target_type']);
entity_dependency_add($dependencies, $item, $field['settings']['target_type'], $info['entity keys']['id']);

Attached patch.

Boobaa’s picture

Ran into the same problem, which was solved by the patch in #1. I don't know how could #9 be related to this, as I didn't need it, so I'm not touching the issue status.

mpgeek’s picture

#9 fixed this issue for me.

microhate’s picture

microhate’s picture

For sure #9 can not work correct.

Entity reference always use target_id to store entity id. If patch #9 we use $info['entity keys']['id'] to get property name, so it would be nid for node or tid for term.

#9 solve problem with notices but does not get dependencies correct.
Patch #1 is correct way. It works for me.

Here is #1 correct applied for current dev branch.

Status: Needs review » Needs work

The last submitted patch, 1545278-entity_dependency_entity_reference_fix-13.patch, failed testing.

igor.ro’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1545278-entity_dependency_entity_reference_fix-13.patch, failed testing.

maciej.zgadzaj’s picture

Status: Needs work » Needs review
FileSize
730 bytes

Re-rolled.

maciej.zgadzaj’s picture

Status: Needs review » Reviewed & tested by the community

Considering that several people already confirmed this solution fixed the issue for them and that it tests ok now, should we RTBC?

igor.ro’s picture

I think yes.
Now we need to merge it to dev branch

RoSk0’s picture

Works like a charm.
Is there any estimate on when this will be committed?

lhridley’s picture

Confirmed that patch in #17 above worked as well.

dixon_’s picture

Committed. Thanks!

dixon_’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Was a bit late yesterday, forgot to mark issue accordingly.

Status: Fixed » Closed (fixed)

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