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

highvoltage - June 5, 2009 - 04:55

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

#2

hadsie - June 8, 2009 - 05:16

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

jjalocha - June 10, 2009 - 13:23

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

Aren Cambre - June 10, 2009 - 15:37
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.

#5

hadsie - June 13, 2009 - 19:16

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

Aren Cambre - June 14, 2009 - 01:16

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

#7

scottrigby - June 14, 2009 - 16:44
Priority:critical» normal
Status:active» needs review

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

AttachmentSize
480432_viewfield_array_filter.patch 806 bytes

#8

scottrigby - June 14, 2009 - 16:45
Status:needs review» needs work

#9

Darren Oh - June 14, 2009 - 16:45
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.

#10

jerdavis - June 17, 2009 - 02:08
Status:needs review» fixed

Fixed in commit http://drupal.org/cvs?commit=226092

Jer

#11

jvieille - June 28, 2009 - 13:47
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

#12

TC44 - July 3, 2009 - 20:45

Same error here also with June 17 dev.

#13

asb - July 21, 2009 - 10:49

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

Greetings, -asb

#14

richardwdoe - July 24, 2009 - 11:31

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

drupalfo - July 31, 2009 - 15:11

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

TomSherlock - August 3, 2009 - 20:18

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

jvieille - August 6, 2009 - 06:46

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

MissyM - August 16, 2009 - 15:59

Subscribe

#19

Dig1 - August 25, 2009 - 13:24

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

Bartezz - September 10, 2009 - 14:44

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

#21

chroni - October 8, 2009 - 21:21

Subscribe

#22

Campsoupster - October 9, 2009 - 17:08

subscribe.

#23

rogerlittin - October 13, 2009 - 00:22

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

protoplasm - October 21, 2009 - 11:45

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

#25

rampage - October 22, 2009 - 20:58

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

trimsyndicate - November 4, 2009 - 23:43

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

 
 

Drupal is a registered trademark of Dries Buytaert.