Invalid argument errors

NikLP - December 27, 2006 - 01:09
Project:CCK Field Permissions
Version:5.x-1.10
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi, I'm not sure what's happening, but when I enable this module, and tick some boxes in /admin/settings/cck_field_perms, but when I go to add/edit anything in a node that relates to something I ticked in there, I get an error (below). Also there is nothing listed below "Field permisions:" in any of my 'fields' groups under that admin page.

The error is :

warning: Invalid argument supplied for foreach() in /var/www/vhosts/drupal.kinetasystems.com/httpdocs/drupal5/sites/default/modules/cck_field_perms/cck_field_perms.module on line 78.

Apologies if I've missed something or been shortsighted...

#1

arthurf - December 27, 2006 - 17:56
Status:active» closed

It looks like I messed up when I was tagging my 5.0 release. I gave it another go and it should be ready. This release should address the issue that you're having. You can grab the latest 5.0 code here:

http://cvs.drupal.org/viewcvs/drupal/contributions/modules/cck_field_per...

Where you say:

Also there is nothing listed below "Field permisions:" in any of my 'fields' groups under that admin page.

You won't get any fields listed if there aren't any cck fields defined for this content type.

thanks for the feedback.

#2

NikLP - January 8, 2007 - 03:09
Status:closed» active

Hi Arthur,

I'm afraid this error still occurs in the new release. I think this is due to not having defined any CCK fields to have permissions set. If I add a field to the blog content type, and DON'T enable any CCK-added fields to have permissions set on them (see attached picture), I get the exact same error on all my content pages.

It's clear it is unlikely that one would enable a content type to have permissions set on it, and then not set any fields as such, but the situation exists nonetheless. I believe the solution to this would be simply to add a check to see if any fields have been selected before attempting to access the array here:

Lines: 56, 100
$disallowed_fields = unserialize(variable_get('cfp_values', null));

On the next line (I have experienced this in only two places thus far) after this unserialize, the code attempts to access the contents of the $disallowed_fields array, but there is no check to see if it is empty AFAIK, which I assume causes the error.

AttachmentSize
cckfield.jpg 18.84 KB

#3

NikLP - January 8, 2007 - 15:00
Version:5.x-1.0-beta» 5.x-1.2

Forgot to change version number, sorry.

#4

arthurf - January 10, 2007 - 21:28
Status:active» fixed

I updated the 5.0 branch for this. Let me know if that works for you.

#5

NikLP - January 11, 2007 - 08:04

Job done, can't generate any errors now. At least, not the old way... :)

#6

Anonymous - January 25, 2007 - 08:15
Status:fixed» closed

#7

gurukripa - March 10, 2007 - 22:45

warning: Invalid argument supplied for foreach() in /home/tirupati/public_html/caitanya/modules/cck_field_perms/cck_field_perms.module on line 77.

hi , i keep getting this kind of errors..

is there something you can do about it..i use 5.1 with the latest cck version that was put up for download...pls help.

#8

gurukripa - March 10, 2007 - 22:48
Version:5.x-1.2» 5.x-1.4
Status:closed» active

i am getting this problem with 5.x-1.4 and i use 5.1 drupal.
warning: Invalid argument supplied for foreach() in /home/tirupati/public_html/caitanya/modules/cck_field_perms/cck_field_perms.module on line 77.
thats the error..
pls help.
thanks

#9

arthurf - May 2, 2007 - 02:45
Status:active» fixed

Hi-

Please update to the latest release- the issue you're reporting should be resolved.

thanks

#10

Anonymous - May 16, 2007 - 03:03
Status:fixed» closed

#11

asterix - May 22, 2007 - 01:44
Version:5.x-1.4» 4.7.x-1.1

I'm getting this same error in the 4.7 version. I'll continue troubleshooting to see if I can find out more. Should the 4.7 issue be in a different thread?

#12

NikLP - May 22, 2007 - 23:28

On your question - not sure. You might be able to take a diff of your 4.7 and latest 5.x code and spot the problem from that though? Depending on your php experience and knowledge of Drupal, presumably... :)

#13

hip - December 31, 2007 - 11:17
Version:4.7.x-1.1» 5.x-1.3
Status:closed» active

Me too I'm getting the same error:

warning: Invalid argument supplied for foreach() in E:\webroot\yth3\modules\cck_field_perms\cck_field_perms.module on line 82.

module version: 1.3.2.27 (2007/08/27 21:25:36 arthuregg)
Drupal version: 5.5

I started to get this error once I removed node-profile module and reinstalled and activated it. I don't know if it can have anything to do with the error.

#14

richard.e.morton - February 16, 2008 - 09:38
Version:5.x-1.3» 5.x-1.10

Hi,

I am getting this error as described above, it appears on the home page in the lovely red error box...

warning: Invalid argument supplied for foreach() in ... /modules/cck_field_perms/cck_field_perms.module on line 77.

I have found the cause and it is when I have activated Field permissions for a content type which does not have any CCK fields created for it.

Could a check be implemented to remove the error?
I would try to help out with a patch but the code is beyond me at this point.

Thanks

Richard

#15

doc2@drupalfr.org - April 1, 2008 - 17:43

Good catch. Indeed we should be able to prevent any new cck_field_permission by enabling any content type susceptible to host such a field.

#16

gettingpissed - June 22, 2008 - 14:44

Getting it on line 182 now...

#17

wentsch - September 11, 2008 - 11:52

Same error for me on line 182 in version 5.x-1.10 on Drupal 5.1 :(

#18

joachim - October 13, 2008 - 16:44

Same here for a content type with no fields.
(I enabled it for CCK field perms and was going to add the fields later...)

Line 182 is:

          foreach ($disallowed_fields[$type] as $disallowed_field => $value){

Casting $disallowed_fields[$type] to an array would work, as would checking it's non-empty.

#19

BenStallings - June 22, 2009 - 16:09

The easy solution to this problem would be to change lines 76 and 179 from
if ($disallowed_fields) {
to
if (is_array($disallowed_fields)) {

 
 

Drupal is a registered trademark of Dries Buytaert.