I'm seeing warnings while doing a node_export:import on some nodes that have file fields and node entity references. I don't really know which (if either) of those items are involved, but there is something odd going on in any case. The warning is:

array_flip(): Can only flip STRING and INTEGER values! uuid.entity.inc:456 [warning]

At the point of the warning being generated, the node being exported has a node_export_dependency containing two elements: one type file for a (pdf) file field with a proper uuid, and one type node, an entityreference, again with a proper uuid.

function node_export_dependency_node_export_after_import_alter
147:      foreach ($node->node_export_dependency as $dep_key => $dependency) {
148:        // Try to handle this dependency now, and unset if successful.
149:        // Only do this now if maintaining dependency to original node, because
150:        // if that setting is turned off, doing this at this stage will break
151:        // things.
152>        if (variable_get('node_export_dependency_existing', 1) && node_export_dependency_handle_dependency($node, $dependency)) {
153:          unset($node->node_export_dependency[$dep_key]);

However at this point, the dependency has been transformed or replaced by one to type 'user', but for module file and on the (pdf) file field. the uuid field has a value of false

function node_export_dependency_handle_dependency
389:   if (!isset($dependency['relationship'])) {
390:     // Entity id.
391>    $entity_ids = entity_get_id_by_uuid($dependency['type'], array($dependency['uuid']));
392:    $entity_id = $entity_ids ? reset($entity_ids) : FALSE;

So when the call to get the entity id is made, it passes an array [ 0: false ] and causes a php warning.

$uuids = [ 0 => false ];
function entity_get_id_by_uuid
410:  $cached_ids = entity_uuid_id_cache($entity_type, $uuids, $revision);

... which then directly calls:

function entity_uuid_id_cache
$ids = [ 0 => false ];
455:  $cached_ids = $cache[$entity_type][(int) $revision];
456>  return array_intersect_key($cached_ids, array_flip($ids));

and complains because the array [ 0 => false ] cannot be flipped.

Is one part of the fix:

function node_export_dependency_handle_dependency
389:  if (!isset($dependency['relationship']) && !empty($dependency['uuid'])) {

I can't help feeling that the entity_uuid_id_cache() function sould be rewritten without needing an array_flip, and the issues it can throw up.

Comments

rivimey created an issue. See original summary.

rivimey’s picture

Issue summary: View changes