I am importing an entity reference by label. If entity reference doesn't find a match, it throws an error:

Warning: array_keys() expects parameter 1 to be array, boolean given in entityreference_feeds_set_target() (line 131 of /sites/all/modules/contrib/entityreference/entityreference.feeds.inc).
Warning: reset() expects parameter 1 to be array, null given in entityreference_feeds_set_target() (line 133 of /sites/all/modules/contrib/entityreference/entityreference.feeds.inc).

In the feeds.inc we have:

        case 'label':
          $options = $handler->getReferencableEntities($value, '=');
          $options = reset($options);
          $etids = array_keys($options);
          // Use the first matching entity.
          $entity_id = reset($etids);

If $options doesn't return a result, the array_keys() line causes an error.

#1 no-label-ref-found-1943300-1.patch798 bytesRob_Feature
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es). View


Rob_Feature’s picture

new798 bytes
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es). View

This patch is almost certainly not correct, but it fixes it until a better dev comes up with a solution.

derekw’s picture

Issue summary:View changes

Same issue here. This will also occur if the reference exists, but is unpublished (or the importer does not have permission).

tikaszvince’s picture

Status:Active» Reviewed & tested by the community

This patch seems ok.

tucho’s picture

The patch from #1 worked for me.