When putting together a fairly complicated view where there isn't always a value for the file field, I got this error:

warning: array_merge(): Argument #2 is not an array in /vol/home/4h/htdocs-dev/sites/all/modules/node_private_file/node_private_file.field_formatter.inc on line 69.

The code in question:

  if (empty($item['filepath']) && !empty($item['fid'])) {
  	dsm($item['fid']);
    $item = array_merge($item, field_file_load($item['fid']));
  }

It assumes there is an FID. I changed the code so that assumption was no longer made:

  if (empty($item['filepath']) && !empty($item['fid'])) {
  	$file = field_file_load($item['fid']);
  	if (is_array($file)) {
	    $item = array_merge($item, $file);
	  }
  }

Comments

andreiashu’s picture

Hi,

First of all sorry for the late reply but I was under the impression that being the module's maintainer d.o would send me an email automatically when someone posts an issue... Anyway, now I subscribed to the issue queue so hopefully I should get a notification from now on.

I would be interested if you could look into your database and see how is it that you can get an $item with a 'fid' parameter and at the same time field_file_load() to return FALSE.

I committed a slightly altered version of your code.

Thanks!

andreiashu’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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