Using CCK I have created a custom content type and added a imagefield.
When I try to create content using that content type I get
warning: in_array() [function.in-array]: Wrong datatype for second argument in /var/www/drupal/modules/filefield/filefield.module on line 289.

Comments

Matt Townsend’s picture

Priority: Normal » Critical

I second this. There's a thread about this in the imagefield section, but I this seems to come up for all filefield attachments, not just images. I'm on 6.4 with the latest modules. I removed the imagefield module and it's still doing it.

I get this with the alpha and the 6x3x dev release.

Any ideas here?

Matt Townsend’s picture

Priority: Critical » Normal

Nevermind on the critical. This doesn't seem to be affecting the function of filefield. But a fix would be nice.

When I comment lines 289 to 292:
/* if (!in_array('filefield_node_form_submit', $form['#submit'])) {
$form['#submit'][] = 'filefield_node_form_submit';
}
*/

The error message goes away, and files seem to upload fine. I'm sure this is a terrible idea, but I thought it might be useful to know.

acase’s picture

Hello all,

I am having the same problem...except my error continues to show with the provided code commented out. Anyone know of a quick fix for this one? Thanks!

ps I upgraded to Drupal 6.4 if that makes a difference...

rc2020’s picture

I too am having this issue. Any thoughts?

pingvinen’s picture

Assigned: Unassigned » pingvinen

Same here!

Michael Mikx’s picture

I've replaced line 289

if (!in_array('filefield_node_form_submit', $form['#submit'])) {

with

if (is_array($form['#submit']) && !in_array('filefield_node_form_submit', $form['#submit'])) {

and that made an error go away.

drewish’s picture

Status: Active » Postponed (maintainer needs more info)

make sure you're running the latest versions of CCK and the filefield module.

mavos’s picture

I still see this with filefield alpha4 and the latest of everything (downloaded today).

On node/add with an image field:
warning: in_array() [function.in-array]: Wrong datatype for second argument in /srv/www/grus/htdocs/modules/filefield/filefield.module on line 289.

philippsimon.de’s picture

i also have the same problem ... install 6.x-1.0-beta2 again

ComputerWolf’s picture

Alright, this issue and #297395: warning: in_array() [function.in-array]: seem to be the same thing... but i'm not sure if one is a duplicate of the other, so i'll post my findings in both.

It seems that even with the latest modules, this warning is still appearing. I found an easy fix by making line #289 of filefield.module look like this:

  if (isset($form['#submit']))
  {
    if (!in_array('filefield_node_form_submit', $form['#submit'])) {
      $form['#submit'][] = 'filefield_node_form_submit';
    }
  }

This works for me, but I don't know why $form['#submit'] is being referenced when for some reason it doesn't exist. I guess that would be an issue for the filefield/CCK developers.

saltcod’s picture

worked for me too - though for anyone new following this, i kept the php tags in when i copied and pasted from above and got a white screen. Remove the beginning and ending php tag and all will go well.

This isn't likely necessary, but may help for anyone new.

pingvinen’s picture

Finaly, no warning message. Thank you ComputerWolf

drewish’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

marked #305905: warning: in_array() in filefield.module as a duplicate of this. marking this as a duplicate of #308832: Wrong datatype for second argument filefield.module on line 289. since it has a patch.

AndriaD’s picture

I followed what was shown above in #10 and #11, ComputerWolf and saltcod, and it worked, got rid of the error, so, thank you very VERY much!

Dre wish, I saw the post about the patch but could not figure out what to do with it; a lot of you folks need to realize that a lot of us folks AREN'T programmers, and don't have one clue what the heck you're all talking about.

Clear-cut instructions about what to remove/change/add are a great deal more helpful than a page of code with code-geek-type comments.

Oh, and this error cropped up with filefield-6.x-3.0-alpha4, but I found the posts referring to this error by simply searching for "filefield.module on line 289".

Again, many thanks,
Andria