Sometimes node_load() will return an image field array that looks something like:

field_image => array(
  und => array(
    0 => NULL
  )
)

Which then means image_field_diff_view_prepare() will generate a $fids array that looks like:
$fids => array(NULL => NULL)

This gets passed onto file_load_multiple() which doesn't play nicely when given NULL's, more specifically entity cache will spit out the warning:
Warning: array_flip(): Can only flip STRING and INTEGER values!

We can mitigate all of this by not passing NULL values to file_load_multiple(), e.g.

  function image_field_diff_view_prepare(&$old_items, &$new_items, $context) {
    $fids = array();
    foreach (array_merge_recursive($old_items, $new_items) as $info) {
+     if (isset($info['fid'])) {
        $fids[$info['fid']] = $info['fid'];
+     }
    }
    $files = file_load_multiple($fids);
    ...
  }

Comments

MustangGB created an issue. See original summary.

mustanggb’s picture

Status: Active » Closed (duplicate)

Actually, even better lets not have NULL images in the first place.

Marking as a duplicate of #920840: Broken images displayed and PHP notices when file/image field values are missing.