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...
Comments
Comment #1
arthurf commentedIt 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:
You won't get any fields listed if there aren't any cck fields defined for this content type.
thanks for the feedback.
Comment #2
niklp commentedHi 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:
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.
Comment #3
niklp commentedForgot to change version number, sorry.
Comment #4
arthurf commentedI updated the 5.0 branch for this. Let me know if that works for you.
Comment #5
niklp commentedJob done, can't generate any errors now. At least, not the old way... :)
Comment #6
(not verified) commentedComment #7
gurukripa commentedwarning: 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.
Comment #8
gurukripa commentedi 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
Comment #9
arthurf commentedHi-
Please update to the latest release- the issue you're reporting should be resolved.
thanks
Comment #10
(not verified) commentedComment #11
WeRockYourWeb.com commentedI'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?
Comment #12
niklp commentedOn 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... :)
Comment #13
hip commentedMe 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.
Comment #14
richard.e.morton commentedHi,
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
Comment #15
doc2@drupalfr.org commentedGood catch. Indeed we should be able to prevent any new cck_field_permission by enabling any content type susceptible to host such a field.
Comment #16
jnvsor commentedGetting it on line 182 now...
Comment #17
daniel wentsch commentedSame error for me on line 182 in version 5.x-1.10 on Drupal 5.1 :(
Comment #18
joachim commentedSame 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:
Casting $disallowed_fields[$type] to an array would work, as would checking it's non-empty.
Comment #19
benstallings commentedThe easy solution to this problem would be to change lines 76 and 179 from
if ($disallowed_fields) {
to
if (is_array($disallowed_fields)) {
Comment #20
benstallings commented