This error occurs when a file that is listed in the FILES table, but is no longer on the file system, is referenced.

filefield_widget.inc :: filefield_widget_value()

the problem comes from not handling the case where field_file_load has returned FALSE.

suggesting the patch to handle this, which sets $file=array(), in this situation

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

duozersk’s picture

I have the same error messages in the watchdog, not sure if I should try this patch.

I'm using Filefield + Imagefield (6.x-3.7 both) + Filefield Paths 6.x-1.4 (to arrange the files on the file system). The issue is that sometimes the images uploaded with Imagefiled widget and then inserted into FCKeditor using the Automatic style of the Insert module just disappear after saving the node edit form (both from the view node and the files uploaded in the node edit form).

It all worked just fine in the past (3-4 months ago)... but we are having difficulties to track after which update is became broken. As Filefield Paths didn't update for quite some time - then it leaves us with the updates of Filefield/Imagefield (maybe it requires some code changes to Filefield Paths module).

Any help would be appreciated.

Thanks
AndyB

duozersk’s picture

While searching for a root cause of the issue I described above - looks like it might be unrelated to the watchdog error message, sorry for that.

I found another issue with the images disappearing #745768: Certain Imagefield Crop Files deleted after node save. Disabled the file name sanitization logic in the Filefield Paths for now.

I will raise another issue for my problem if needed - please consider it a separate one, not related to the initial one about the watchdog message.

AndyB

craig_’s picture

FileSize
580 bytes

wanted to bump this to the maintainers, to see if this patch is going to make the next release of filefield v3.x

in the code, an empty array is handled, but a null is not. this patch helps turn a null into an empty array, so the function can continue execution

thanks!

maciej.zgadzaj’s picture

I had the same error too, only that in my case $item was NULL ($file was a proper array), which was coming from $element not having any #default_value set.

And it happened only when no file was uploaded to a field (as actually I had 2 ImageFields and 1 FileField in the form - if all 3 of them were empty, I was getting 3 errors like this), after uploading at least one file error disappeared.

Attached patch did help in my case.

YesCT’s picture

Title: Argument #2 is not an array in /sites/all/modules/filefield/filefield_widget.inc on line 254 » Argument #2 is not an array in /sites/all/modules/filefield/filefield_widget.inc on line 255
Version: 6.x-3.7 » 6.x-3.9
Status: Needs review » Needs work

patch in #3 made one of the errors (warnings) in #972044: Fully support multi-valued CCK fields go away. (editablefields)

Needs better comment 1) end with a period and 2) describe what the new code is doing, not just what was wrong before.

craig_’s picture

Status: Needs work » Needs review
FileSize
795 bytes

let me know if this is sufficient

Von Gunther’s picture

This error also occurs when the files database table is missing an entry (accidental erasure etc ) refered to elsewhere.

quicksketch’s picture

Status: Needs review » Fixed
FileSize
413 bytes

I've committed this simple patch which accomplishes the exact same thing but just reuses the existing conditional instead of adding a new one.

Suggested approach from above:

    if (!$file) {
      $file = array();
    }

     // If the file entry doesn't exist, don't save anything.
     if (empty($file)) {
       $item = array();
     }

New approach:

     // If the file entry doesn't exist, don't save anything.
     if (empty($file)) {
       $item = array();
       $file = array();
     }

Thanks for your patience on this guys. Now that I've gone through the queue and cleaned up all the issues that have been solved I'll put out a new release shortly.

quicksketch’s picture

The 3.10 version of FileField is now available for your downloading pleasure. Please do not reopen this issue. File a new issue against 3.10 for further problems.

Status: Fixed » Closed (fixed)

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

tfmy2k’s picture

Version: 6.x-3.9 » 6.x-3.10

I had 6.x-3.9 installed: i was getting the Argument #2 is not an array in /sites/all/modules/filefield/filefield_widget.inc on line 255 directory.

I then upgraded to 6.x-3.10. I am now consistently getting the following error:

Argument #1 is not an array in /sites/all/modules/filefield/filefield_widget.inc on line 255.

I have verified that the files do end up getting uploaded into the following directory:

.../sites/default/files/

I have spent almost half a day on this: NO AVAIL: my site is down: Please help!!!

tfmy2k’s picture

In addition to the above post: If i try to upload file from Drupal back-end, it gives me following error message:

Fatal error: Only variables can be passed by reference in drupal/includes/form.inc on line 1345

rgarand’s picture

Status: Closed (fixed) » Active

I'm seeing this with filefield 3.10. It gives the following 2 errors:

# warning: array_merge() [function.array-merge]: Argument #2 is not an array in sites/all/modules/contrib/filefield/filefield.module on line 319.
# warning: array_merge() [function.array-merge]: Argument #1 is not an array in sites/all/modules/contrib/filefield/filefield_widget.inc on line 255.

In filefield_widget_value, $edit is set to false and $element['#default_value'] is null. This goes down a different branch and doesn't activate the original fix. The site has a few custom modules that I'm still not familiar with so I'm not sure if filefield causes this but it can handle it easily by using

  if (isset($items[$delta]) && !empty($items[$delta])) {

instead of

  if (isset($items[$delta])) {

in filefield_widget (filefield.module)

Nitebreed’s picture

The fix in #13 seems to work fine!

scriptaimago’s picture

I've applied all the suggested patches, once at time. I still get the warning. Any idea?

quicksketch’s picture

Status: Active » Closed (fixed)