Error when creating new viewfield
Aren Cambre - June 3, 2009 - 03:43
| Project: | Viewfield |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
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.

#1
I also receive this error with my drupal 6 site and everything is also up to date.
#2
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.
#3
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.
#4
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.
#5
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.
#6
If line 274 causes an error, will 275 ever be executed?
#7
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
#8
#9
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.
#10
Fixed in commit http://drupal.org/cvs?commit=226092
Jer
#11
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
#12
Same error here also with June 17 dev.
#13
also confirming for Viewfield 6.x-1.x-dev from 17-Jun-2009.
Greetings, -asb
#14
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.
#15
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
#16
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.
#17
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.
#18
Subscribe
#19
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
#20
Just downloaded the latest .dev and encountered the same error.
#21
Subscribe
#22
subscribe.
#23
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.
#24
This appears to be a critical problem on my website that is breaking some of my view generated front pages.
#25
just change line 274 from v1.20
to this:
$field['allowed_views'] = is_array($field['allowed_views']) ? array_filter($field['allowed_views']) : array();
cheers
#26
I still get this error as well even with the change in #25. Any solutions?