Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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...
Comment | File | Size | Author |
---|---|---|---|
#2 | cckfield.jpg | 18.84 KB | NikLP |
Comments
Comment #1
arthurf CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: NikLP commentedForgot to change version number, sorry.
Comment #4
arthurf CreditAttribution: arthurf commentedI updated the 5.0 branch for this. Let me know if that works for you.
Comment #5
NikLP CreditAttribution: NikLP commentedJob done, can't generate any errors now. At least, not the old way... :)
Comment #6
(not verified) CreditAttribution: commentedComment #7
gurukripa CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: arthurf commentedHi-
Please update to the latest release- the issue you're reporting should be resolved.
thanks
Comment #10
(not verified) CreditAttribution: commentedComment #11
WeRockYourWeb.com CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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
J V CreditAttribution: J V commentedGetting it on line 182 now...
Comment #17
Daniel Wentsch CreditAttribution: Daniel Wentsch commentedSame error for me on line 182 in version 5.x-1.10 on Drupal 5.1 :(
Comment #18
joachim CreditAttribution: 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 CreditAttribution: 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)) {