Permissions for anonymous user not saved
avf - February 26, 2009 - 19:54
| Project: | Content Access |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
The attached patch fixes some random behaviour when submitting content_access-related forms.
This was messing up permissions for anonymous users (rid 1) because the arrays in question had the form "rid1 => 1; rid2 => 1" instead of "0 => rid1; 1 => rid2" (i.e., array_keys of the former).
I briefly tried the latest -dev, but this behaviour still seemed to be there.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| content_access.patch | 1.13 KB | Ignored | None | None |

#1
patch works fine. Thx!
#2
In my case I came across this on a new site I was building, and the module worked on one test site and not the other. The difference was that on the one that was not working, I had created a role for site administrators and put the super-admin in it, which was also the account that I was using to work on the site. When I did this on the site that did not have this problem, the problem showed up there as well. Both sites were bare-bones with no other modules installed but this and the ACL module. When I deleted the site admin role, going back and re-editing the permissions in the nodes that had problems fixed the issue.
#3
Hi everybody,
i`d like to apply this patch too but I´m not a programmer.
What do I need to to?
Replace this code in the content_access.admin.inc file:
foreach (_content_access_get_operations() as $op) {
// Set the settings so that further calls will return this settings.
$settings[$op] = array_filter($form_state['values'][$op]);
}
// Save per-node settings.
content_access_save_per_node_settings($node, $settings);
if (module_exists('acl')) {
foreach (array('view', 'update', 'delete') as $op) {
acl_save_form($form_state['values']['acl'][$op]);
}
}
by this code (patch):
@@ -68,7 +68,7 @@
$node = $form_state['node'];
foreach (_content_access_get_operations() as $op) {
// Set the settings so that further calls will return this settings.
- $settings[$op] = array_filter($form_state['values'][$op]);
+ $settings[$op] = array_keys(array_filter($form_state['values'][$op]));
}
// Save per-node settings.
content_access_save_per_node_settings($node, $settings);
@@ -156,7 +156,7 @@
foreach (content_access_available_settings() as $setting) {
unset($settings[$setting][$form_state['type']]);
if (isset($form_state['values'][$setting])) {
- $settings[$setting][$form_state['type']] = is_array($form_state['values'][$setting]) ? array_filter($form_state['values'][$setting]) : $form_state['values'][$setting];
+ $settings[$setting][$form_state['type']] = is_array($form_state['values'][$setting]) ? array_keys(array_filter($form_state['values'][$setting])) : $form_state['values'][$setting];
}
}
content_access_set_settings($settings);
Please help!
Thanks,
Chris
#4
I had the same problem on a new site: I was unable to disable access to a "Staff Page" node type for anonymous users.
This patch solved the problem for me (using Content Access 6.x-1.0 on Drupal 6.10).
Thanks, avf!
#5
Flagged it as a bug report since this is a bug and not a request for support.
#6
Tested patch, it fixed the issue.
#7
Patch works.
#8
#9
NICE FIX!!! avf
Thank you very much!!
Leon
#10
hm, I'm not totally sure what's the problem that got introduced with drupal 6.10, but indeed some tests failed and your patch fixed that. So I've added your fix to the rules integration too and committed it. thanks!
#11
Please test the next generated dev snapshot.
#12
Hi Chris,
did you work it out or are you still waiting for the answer?
#13
I tried today's dev. It doesn't work.
I am still unable to disable "View any content" and "View own content" for anonymous user
#14
Hi tryitonce,
no i didn`t work it out yet. I`ve been waiting for the answer for a while. Then i switched to nodeaccess -that one works fine:-)
That doesn`t mean I`m not interested getting an answer anymore.
It´s just a matter of time having the same patch problem again with some other module...
So what do i need to do to use this patch (or other)?
Replace the ancient code by the patch code in the file? I know, this question sounds silly for some expert, but as i said: I´m no programmer!!
I`ve only got some basic skills in action-script1&2 programming, that`s it...
Thx in advance!
Chris
#15
Just checked the latest dev available; it looks like the patch from this issue wasn't applied - just looked on the strings this patch changes and they were not changed.
#16
Hi Chris,
You need to open the file "content_access.admin.inc" with a suitable editor - I use PSPad - http://www.pspad.com/.
The patch is for the replacement of two lines of code:
1. line
2. line
That is it. Now you have to make sure that the file is saved. It might take a few seconds to go through - a little longer if you are not working on your home local machine. You might need to clear your cache and make sure Drupal is running in development mode - with cache disabled - or clear the cache in Drupal as well.
Now you should have fixed the problem. Quite simple in a way, but not so easy the first time - as many of the experts assume we know all these simple mechanics of "brick layiing". I am not an expert and can very well understand how you feel. I hope it works and do ask the experts "silly" questions - well there are no silly questions - only silly or sometimes arrogant answers.
I guess patches are shown to include relevant code of the routine around the patch - so the expert can see exactly what the patch will do and whether it will work. So, fair enough.
I hope it helps and works for you. Good luck
CC
By the way - do report back how you solved your problem and do write how you did it - add file names and links to where you found help, files, etc. - lots of people joining Drupal will be grateful - for a simple, "start-with-the-basics"-approach.
#17
Hi,
i had to use this patch since it's not in the latest dev version: 6.x-1.x-dev from 2009-Mar-16
Worked fine, Problem solved ;)
ThX TSE
#18
Patch tested against Mar 15 dev snapshot and 1.0 release. It applies perfectly and fixes the issue.
Changing the title to be more descriptive of the issue (to help other people find the issue and patch).
#19
grml, somehow the changes in .admin.inc were not committed. I've done it now, sry.
Again please test the next devel snapshot.
#20
This patch really works!
Thanks a lot!
#21
fago,
It looks like a major functionality fix for the CA and its Rules integration... so maybe it will be appropriate to release the 1.1 version?
#22
Patch works... silly way to apply it (manual editing of said file)
and when I finally disabled Anonymous from viewing my members only page, it said
Access denied
You are not authorized to access this page.
It is also a menu item and... disappeared from the menu... yay! Log in and it reappears.
Can I edit that access denied page message?
Over all, took all da?? day to find and configure a members only section. Way too long IMHO
Now to test autologout... 23 days logged in is idiocy
#23
>It looks like a major functionality fix for the CA and its Rules integration... so maybe it will be appropriate to release the 1.1 version?
I agree, I just wanted to be sure it works.
#24
Automatically closed -- issue fixed for 2 weeks with no activity.
#25
subscribe