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...

CommentFileSizeAuthor
#2 cckfield.jpg18.84 KBNikLP
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

arthurf’s picture

Status: Active » Closed (fixed)

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.

NikLP’s picture

Status: Closed (fixed) » Active
FileSize
18.84 KB

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.

NikLP’s picture

Version: 5.x-1.0-beta » 5.x-1.2

Forgot to change version number, sorry.

arthurf’s picture

Status: Active » Fixed

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

NikLP’s picture

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

Anonymous’s picture

Status: Fixed » Closed (fixed)
gurukripa’s picture

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.

gurukripa’s picture

Version: 5.x-1.2 » 5.x-1.4
Status: Closed (fixed) » 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

arthurf’s picture

Status: Active » Fixed

Hi-

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

thanks

Anonymous’s picture

Status: Fixed » Closed (fixed)
WeRockYourWeb.com’s picture

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?

NikLP’s picture

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... :)

hip’s picture

Version: 4.7.x-1.1 » 5.x-1.3
Status: Closed (fixed) » 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.

richard.e.morton’s picture

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

doc2@drupalfr.org’s picture

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.

J V’s picture

Getting it on line 182 now...

Daniel Wentsch’s picture

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

joachim’s picture

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.

BenStallings’s picture

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