The node has an Entity reference field to a user. The view to include requires this field's uid as argument. During preview of the node, the arguments string is put into _viewfield_get_view_args() which on line 360 results in a PHP notice "invalid index" (actually trying to access array index NULL, see below).

The line reads (from 358 to 360):

    list($entity_id) = entity_extract_ids($entity_type, $entity);
    $entities = entity_load($entity_type, array($entity_id));
    $token_data = array($entity_type => $entities[$entity_id]);

Via dpm() I found $entity_id is NULL. entity_load() also had trouble with null (a common error), but that's more or less a side effect.

I'm not sure, who is responsible (Viewfield or Entity reference), but I think it would make sense to validate the $entity_id before passing it on.

Comments

  • jerdavis committed 9cae65c on 7.x-3.x
    Issue #1658126 by jerdavis: Arguments not always available during node...
jerdavis’s picture

Issue summary: View changes
Status: Active » Fixed

Wrapping this in a conditional of if (!empty($entity_id)) seemed reasonable. That should at least prevent the PHP error. Committed to 7.x-3.x

Status: Fixed » Closed (fixed)

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