I'm currently using the 1.10 version of filefield. If I create a content type that uses the filefield where the field is optional and then I do not upload a file, the first time that I vew that node I get the error:

warning: array_merge() [function.array-merge]: Argument #2 is not an array in filefield\filefield.module on line 172.

I get one error per field. It seems that the test !empty($file) is insufficient. I tried commenting out some of the print statements and found the following:

  • loading file form content.module:
    Array
    (
        [fid] => 0
        [description] => 
        [list] => 0
    )
    
  • loading file from db:
    </pre></li>
      <li>loading file form content.module: <pre>Array
    (
        [fid] => 0
        [description] => 
        [list] => 0
    )
    
    
  • loading file from db:

Comments

Tyrael’s picture

$values[$delta] = array_merge($file, $dbfile);
this is the 172th line.

$dbfile had a false value, because the _filefield_file_load($file['fid']) function return with false

I replaced that line with this:
if(_filefield_file_load($file['fid'])){
$dbfile = _filefield_file_load($file['fid']);
}
else{
$dbfile= array();
}

Now there is no error message, but im not sure about the solution, maybe its just fix the error message, but the $dbfile should have a proper array value.
dunno.

sorry for my bad english

Tyrael

Tyrael’s picture

$dbfile = _filefield_file_load($file['fid']);
if(!$dbfile || !is_array($dbfile)){
$dbfile= array();
}

it's a better solution.
sorry, I couldn't edit my post.

Tyrael

eliza411’s picture

Thanks for posting this . . . I was having the same problem and it was easy to fix with your directions.

greggles’s picture

@tyrael - can you provide that as a patch: http://drupal.org/diffandpatch

@dopry - any feeling on this approach?

Tyrael’s picture

I never did this before(making diff), because I'm new in the Drupal community, but I will try this at the weekend.

Tyrael

dopry’s picture

Status: Active » Fixed

@all

I just backported a bunch of changes that went into imagefield. This error should be resolved now, plus a few extras. cheers.

Anonymous’s picture

Status: Fixed » Closed (fixed)