I get this error when creating a new viewfield: warning: array_filter() [function.array-filter]: The first argument should be an array in /home/arencambre/drupal6/sites/all/modules/viewfield/viewfield.module on line 274.

This is an installation that was upgraded from 5 a while back. It is up to date on all modules.

CommentFileSizeAuthor
#7 480432_viewfield_array_filter.patch806 bytesscottrigby

Comments

highvoltage’s picture

I also receive this error with my drupal 6 site and everything is also up to date.

hadsie’s picture

The code where that's happening looks like:

274: $field['allowed_views'] = array_filter($field['allowed_views']);
275: $field['allowed_views'] = empty($field['allowed_views']) ? array_keys(views_get_all_views()) : $field['allowed_views'];

The first line looks to be left over and should probably be removed, since anything there is just going to be overwritten by 275 anyway. Deleting line 274 will make that error go away, and won't break anything either.

jjalocha’s picture

Subscribing.

Same warning here with clean Drupal 6.12 install.

Does anyone know if this is critical, or it can be ignored? I am using this on a prototype, and I hope the Viewfield D6 becomes stable in the meantime.

aren cambre’s picture

Priority: Normal » Critical

I noticed that the viewfield appears to get created despite this, but I still wonder whether this could leave certain data in an inconsistent state. Marking as critical until someone knowledgeable says otherwise due to possible data corruption issues.

hadsie’s picture

As I mentioned with my previous post I don't believe this is critical, just a line of code that got left behind by the developer. Line 274 triggers the error, but line 275 fixes anything that could have been a mistake and/or cause data corruption issues. The patch is to simply delete line 274.

aren cambre’s picture

If line 274 causes an error, will 275 ever be executed?

scottrigby’s picture

Priority: Critical » Normal
Status: Active » Needs review
StatusFileSize
new806 bytes

Assuming line 274 is really unnecessary (it's definitely being overwritten currently by line 275 like hadsie said), here's a patch

Edit: I just noticed deleting that line causes another error, so best not to use this patch till a better solution is found :p

scottrigby’s picture

Status: Needs review » Needs work
darren oh’s picture

Status: Needs work » Needs review

That line is not being overwritten. array_filter removes all keys whose value is 0. The error is real, and should be fixed by re-saving the allowed views.

jerdavis’s picture

Status: Needs review » Fixed
jvieille’s picture

Status: Fixed » Active

Still getting the error using the last dev dated June 17th:

warning: array_filter() [function.array-filter]: The first argument should be an array in /home/controlc/www/sites/all/modules/viewfield/viewfield.module on line 274

Even worse:
When creating a new field for a given content type, all nodes of this type get a view, by default the first in the list.
No way to get ride of it: you can only chose another view - none is not en option.
I created an empty view to handle that in the meantime

TC44’s picture

Same error here also with June 17 dev.

asb’s picture

also confirming for Viewfield 6.x-1.x-dev from 17-Jun-2009.

Greetings, -asb

rwd’s picture

The commit mentioned in #10 is not the final change to viewfield.module that made it into the 2009-Jun-17 dev snapshot.

The later commit http://drupal.org/cvs?commit=226106 also changed viewfield.module to the version that's in the snapshot, but this commit reintroduces the error mentioned by the OP for new viewfields.

drupalfo’s picture

Just Downloaded and installed fresh version of Drupal 6.13.
also downloaded latest Viewfield 6.x dev. and got the same exact error.

warning: array_filter() [function.array-filter]: The first argument should be an array in drupal6/sites/all/modules/viewfield/viewfield.module on line 274

tomsherlock’s picture

I would like to confirm that i have the same exact error with the 2009-Jun-17 dev snapshot. I just downloaded it.
I also have Drupal 6.13.

jvieille’s picture

The error is still there
The line 274 had actually gone in the last dev of June 17th, but the error appear at the same pace.
As mentionned, this is not critical. Just save the content type ignoring the error. the next time, it is clean.

missym’s picture

Subscribe

dig1’s picture

Subscribing

Yes, I just upgraded from 6.12-6.13 and upgraded to Viewfield 6.x-1.x-dev (2009-Jun-17). I added a second viewfield to a content type and got this error:

warning: array_filter() [function.array-filter]: The first argument should be an array in ...sites/all/modules/viewfield/viewfield.module on line 274.

The content type subsequently seems to display my two views ok.

Digby

bartezz’s picture

Just downloaded the latest .dev and encountered the same error.

tchronister’s picture

Subscribe

seanberto’s picture

subscribe.

Anonymous’s picture

When I debug the code with a breakpoint on line 274, when entering the page, $field('allowed_views') is set as an array of the available views which is correct. With none of the views in the checkbox list selected and just a view from the combo box selected, the code stops again at the breakpoint but this time $field('allowed_views') is set as a string value which is what causes the error. I haven't had time to backtrace where the string value is being set.

Roger.

protoplasm’s picture

This appears to be a critical problem on my website that is breaking some of my view generated front pages.

rampage’s picture

just change line 274 from v1.20
to this:
$field['allowed_views'] = is_array($field['allowed_views']) ? array_filter($field['allowed_views']) : array();

cheers

timaholt’s picture

I still get this error as well even with the change in #25. Any solutions?

leon85321’s picture

Thank you for the patch.
After applying #25, it works now, it does not display any errors now :)

darren oh’s picture

Status: Active » Fixed

Fixed in CVS commit 226106.

Status: Fixed » Closed (fixed)

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

ablewave’s picture

Is this fixed in the latest dev? I am getting this error, but for line 270, and only on nodes where there is no View selected. It is a book page node if that makes any difference.

warning: array_filter() [function.array-filter]: The first argument should be an array in /home/monti/public_html/sites/all/modules/viewfield/viewfield.module on line 270.

acb’s picture

I see it too

guillefar’s picture

When I'm creating editing or just viewing content, this message appears:

warning: array_filter() [function.array-filter]: The first argument should be an array in /var/www/d/sites/all/modules/viewfield/viewfield.module on line 275.

I suppose is related with the previous errors.

Any idea or what it could be?