Closed (fixed)
Project:
FileField
Version:
6.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Oct 2006 at 04:55 UTC
Updated:
29 Nov 2006 at 06:15 UTC
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:
Array
(
[fid] => 0
[description] =>
[list] => 0
)
</pre></li>
<li>loading file form content.module: <pre>Array
(
[fid] => 0
[description] =>
[list] => 0
)
Comments
Comment #1
Tyrael commented$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
Comment #2
Tyrael commented$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
Comment #3
eliza411 commentedThanks for posting this . . . I was having the same problem and it was easy to fix with your directions.
Comment #4
greggles@tyrael - can you provide that as a patch: http://drupal.org/diffandpatch
@dopry - any feeling on this approach?
Comment #5
Tyrael commentedI never did this before(making diff), because I'm new in the Drupal community, but I will try this at the weekend.
Tyrael
Comment #6
dopry commented@all
I just backported a bunch of changes that went into imagefield. This error should be resolved now, plus a few extras. cheers.
Comment #7
(not verified) commented