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

AttachmentSizeStatusTest resultOperations
content_access.patch1.13 KBIgnoredNoneNone

#1

fischerj - March 5, 2009 - 16:34

patch works fine. Thx!

#2

jwgreen1974 - March 6, 2009 - 00:23

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

picapaoo - March 6, 2009 - 10:10
Category:bug report» support request

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

grobemo - March 6, 2009 - 21:14

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

xhochy - March 8, 2009 - 15:43
Category:support request» bug report

Flagged it as a bug report since this is a bug and not a request for support.

#6

capmex - March 9, 2009 - 18:50

Tested patch, it fixed the issue.

#7

pepó - March 10, 2009 - 07:03

Patch works.

#8

xhochy - March 10, 2009 - 09:10
Status:needs review» reviewed & tested by the community

#9

leon85321 - March 12, 2009 - 17:32

NICE FIX!!! avf

Thank you very much!!

Leon

#10

fago - March 15, 2009 - 16:11
Status:reviewed & tested by the community» fixed

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

fago - March 15, 2009 - 16:21

Please test the next generated dev snapshot.

#12

tryitonce - March 15, 2009 - 20:55

Hi Chris,

did you work it out or are you still waiting for the answer?

#13

jvieille - March 16, 2009 - 09:16

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

picapaoo - March 16, 2009 - 14:48

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

duozersk - March 16, 2009 - 14:58
Status:fixed» active

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

tryitonce - March 16, 2009 - 20:33

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

  1. You then just look for the line number 68 which should be $node = $form_state['node'];
  2. now you follow the code until you get to the line $settings[$op] = array_filter($form_state['values'][$op]);
  3. this line you have to replace with $settings[$op] = array_keys(array_filter($form_state['values'][$op]));.
  4. 1 line of the patching is done.

2. line

  1. Now you scroll done to line number 156 which should be content_access_save_per_node_settings($node, $settings);
  2. again follow the code until you get to the line $settings[$setting][$form_state['type']] = is_array($form_state['values'][$setting]) ? array_filter($form_state['values'][$setting]) : $form_state['values'][$setting];
  3. this line you have to replace with $settings[$setting][$form_state['type']] = is_array($form_state['values'][$setting]) ? array_keys(array_filter($form_state['values'][$setting])) : $form_state['values'][$setting];

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

TSE - March 17, 2009 - 13:38

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

akalsey - March 17, 2009 - 14:57
Title:Random behaviour when submitting content_access forms» Permissions for anonymous user not saved
Status:active» reviewed & tested by the community

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

fago - March 17, 2009 - 16:05
Version:6.x-1.0» 6.x-1.x-dev
Status:reviewed & tested by the community» fixed

grml, somehow the changes in .admin.inc were not committed. I've done it now, sry.
Again please test the next devel snapshot.

#20

wdevn - March 17, 2009 - 21:14

This patch really works!

Thanks a lot!

#21

duozersk - March 19, 2009 - 14:51

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

swordedge - March 23, 2009 - 05:55

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

fago - March 25, 2009 - 15:25

>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

System Message - April 8, 2009 - 15:30
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#25

CarbonPig - June 17, 2009 - 18:43

subscribe

 
 

Drupal is a registered trademark of Dries Buytaert.