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.
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.
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedThis 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.
Comment #3
David_Rothstein CreditAttribution: David_Rothstein commentedComment #4
danielb CreditAttribution: danielb commentedI 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.
Comment #5
skwashd CreditAttribution: skwashd commentedI have also tested this and found that it fixes the issue outlined above.
Comment #6
skwashd CreditAttribution: skwashd commented#1: entity-dependency-entityreference-1545278-1.patch queued for re-testing.
Comment #7
jneubert CreditAttribution: jneubert commented#1: entity-dependency-entityreference-1545278-1.patch queued for re-testing.
Comment #8
jneubert CreditAttribution: jneubert commentedI came across the issue described above, and the patch worked for me.
Comment #9
bricel CreditAttribution: bricel commentedThis 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.
Comment #10
BoobaaRan 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.
Comment #11
mpgeek CreditAttribution: mpgeek commented#9 fixed this issue for me.
Comment #12
microhate CreditAttribution: microhate commented#1: entity-dependency-entityreference-1545278-1.patch queued for re-testing.
Comment #13
microhate CreditAttribution: microhate commentedFor 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.
Comment #15
igor.ro CreditAttribution: igor.ro commented#13: 1545278-entity_dependency_entity_reference_fix-13.patch queued for re-testing.
Comment #17
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedRe-rolled.
Comment #18
maciej.zgadzaj CreditAttribution: maciej.zgadzaj commentedConsidering that several people already confirmed this solution fixed the issue for them and that it tests ok now, should we RTBC?
Comment #19
igor.ro CreditAttribution: igor.ro commentedI think yes.
Now we need to merge it to dev branch
Comment #20
RoSk0Works like a charm.
Is there any estimate on when this will be committed?
Comment #21
lhridley CreditAttribution: lhridley commentedConfirmed that patch in #17 above worked as well.
Comment #22
dixon_Committed. Thanks!
Comment #23
dixon_Was a bit late yesterday, forgot to mark issue accordingly.