Hello,

For some reason, when I'm trying to import users that are associated with group nodes some imported users do not have any referenced group nodes associated.

I've noticed that the group nodes that cannot be referenced are only nodes that have been imported via a previous feeds import. Despite this, users that are created through the user creation form CAN be associated with the group nodes that do not work through the feeds import process.

There are two php warnings that occur when an entity reference cannot be created through the feeds process:

Warning: array_keys() expects parameter 1 to be array, boolean given in entityreference_feeds_set_target() (line 132 of /home/angelo/dev/client/profiles/openatrium/modules/contrib/entityreference/entityreference.feeds.inc).

Warning: reset() expects parameter 1 to be array, null given in entityreference_feeds_set_target() (line 134 of /home/angelo/dev/client/profiles/openatrium/modules/contrib/entityreference/entityreference.feeds.inc).

This implies that for some reason
127: $handler->getReferencableEntities($value, '=')
isn't returning what it's supposed to and I'm not too sure why.

Has anyone else run into this issue?

Comments

captainpants’s picture

Issue summary: View changes
captainpants’s picture

Category: Bug report » Support request
Priority: Major » Normal
Status: Active » Closed (works as designed)

Fixed. It turns out there were erroneous microsoft nbsp characters in the feed CSV that looked exactly like spaces. This resulted in the referenced entity not being found.

Removing these characters made the feed work correctly.

jadhavdevendra’s picture

I am using "Entity Reference" version 7.x-1.1, I have a user reference field in the content type.
If I am running multiple feed importers programatically using following code -

foreach ($importers as $key => $value) {
  //feeds_batch_set(t('Importing'), 'import', 'yale_courses_importer', $value->nid);
  while (FEEDS_BATCH_COMPLETE != feeds_source('yale_courses_importer', $value->nid)->import());
}

I am matching the reference by entity label.
If the user reference is not present I get these two warnings.

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

I do not get this error in following cases -

  1. User reference is present.
  2. Source user reference field is empty.
  3. If I run the importer individually by clicking on feeds import button.

Not sure where should this issue go, to feeds or to entity reference.

jadhavdevendra’s picture

Status: Closed (works as designed) » Active
dman’s picture

I'm getting this also. Though I do sometimes do funny things with entity lookups and tampers, tracing this notice shows that it's just native behaviour coming from entityreference_feeds_set_target()

Basically, even if the search for the entity done at
$options = $handler->getReferencableEntities($value, '=');
returns an empty array (no results, which is usually legal)
the later code there assumes there is at least one result always, and resets and manipulates the array as if it had something in it.
We still end up with the system, returning no match, but only after triggering these warnings.

Checking for empty will probably help here, like:

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

( this is probably not the right issue for the PHP notice warning though. I'm getting it when the referenced entity just don't exist)

g33kg1rl’s picture

I am also experiencing this issue. Let me know if I can give any additional information to fix this. :)

dman’s picture

Shifting to #2722671: Warning when feed refers to non-existing target: array_keys() expects parameter 1 to be array, boolean given in entityreference_feeds_set_target() (line 129) because the warning is unrelated to the reported issue "feed imports not working". The warning is just a later symptom that happens after the "not working" problem happens, and the warning can be triggered just by failed lookups on a working site.