Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
comment.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Jan 2009 at 01:42 UTC
Updated:
26 Sep 2010 at 02:54 UTC
Jump to comment: Most recent file
Comments
Comment #1
catchComment #2
dave reidComment #3
webchickSounds good to me. This is usually step 4 on any Drupal site I ever build.
Comment #4
rszrama commentedHmm... just noticed the Novice tag and think I read about leaving these jobs for beginners. I already patched and tested it, so I suppose it's still better to post up the code. Hopefully a novice could still review it and appreciate it. : P
fwiw, I never liked the fact that there wasn't an API function to add a permission to a role. Would that be a considerable separate patch?
This patch just adds the appropriate permission in system.install. I tested on the latest unstable release, both available profiles, and it obviously sets the permission fine. ; )
Comment #6
rszrama commentedHmm... curious... any way to see what test failed? My local test site keeps failing w/ a 500 error on "/drupal7/batch?id=3&op=do".
Comment #7
dave reidThe test is failing because of the new comment block test that I wrote (CommentBlockFunctionalTest in comment.test), which expects that an anonymous user by default does not have access to view comments.
What will work best is if you create a new user in the test that does not have the access comments permission and instead of using the anonymous user, login with the new user:
BTW, the role/permission APIs are in #300993: User roles and permissions API which also moves this default permissions to default.profile so I'll need to keep an eye on this patch in case it lands before 300993.
Comment #8
MichaelCole commentedThe above patch is dead now. The code has been refactored.
The issue is still valid: http://d7p2.dev/admin/config/people/permissions/1
Rerolling patch...
Comment #9
MichaelCole commented- Edited both default install profiles to include "access comments" for anon user.
- Verified "comment block" test above still fails.
- Then fixed it with Dave's suggestion :-)
TO TEST PATCH:
1) download d7 from CVS.
2) FIRST apply patch (patch is to install code!)
3) THEN run install.php
4) Check permissions here: http://d7p2.dev/admin/config/people/permissions/1 Both anon and auth should have access comments. Admin doesn't need (is auth)
Hurray for new install profiles!
Comment #11
MichaelCole commentedLet's try again. Fixed the test.
What happened? createDrupalUser(array()) does not return a user with empty permissions. It returns a user with a user with authorized user default permissions (which include "access comments").
There isn't a practical way to test the absence of the block. General block access control is outside the appropriate coverage for comments.test. So I removed the failing bit from the test. Left in the test for presence of the block.
See testing notes above. Moving on!
Comment #12
MichaelCole commentedComment #13
nkmaniLooks good and access comments is enabled by default for anon. Tested with the default install profile. not with the expert profile. But the changes are identical, so should work there too.
Comment #14
webchickThis change makes a lot of sense. But I'd really rather not lose that test for access denied in the process.
Can we not test to make sure that they can access the comment, then call http://api.drupal.org/api/function/user_role_revoke_permissions/7 to revoke the permission and ensure that they're successfully blocked?
Comment #15
ergonlogicRerolled patch from #11 with the following alterations:
- Only added 'access comments' permission to anonymous user in standard.install, leaving minimal.install as is;
- As per #14, preserved the access denied test with user_role_revoke_permissions().
Comment #17
David_Rothstein commentedI think this should make the test pass.
Comment #18
frankcarey commentedtest works, code looks good
Comment #19
cleaver commentedAlso reviewed and agree it looks good.
Comment #20
cleaver commentedoops... setting back to reviewed...
Comment #21
David_Rothstein commentedHm, note that if we do this, we make the standard Drupal installation pretty "human-spammer friendly" (see discussion at #698144: D7: Fresh install allows visitors to create accounts). We already let anyone come along, get a free account and add comments/upload pictures - but with this patch we'd then be letting the rest of the world see whatever they uploaded, which is a big difference...
I wonder if we should consider accompanying this with taking away the 'post comments without approval' permission from authenticated users? This is probably what a lot of sites want anyway if they aren't going to have spam protection (which Drupal core doesn't have built in)... Or is that being too paranoid?
Comment #22
catchComment moderation on by default sounds good, and should probably be made at the same time as this patch.
Comment #23
David_Rothstein commentedAlright, well let's try it and see what happens. I'm guessing it will break some tests.
Comment #25
yesct commentedchicago camp sprint, patch coming
Comment #26
yesct commentedsummary:
patch:
1) adds access comments permission for anonymous users by default in standard install,
2) removes post comments without approval to authenticated users
#14 keep test for access denied (view comments?)
#15 only added access comments permission to anonymous in standard.install (not minimal.install)
does that need to be documented somewhere (diff between standard and minimal doc)?
and a changelog? for removing the post comments without approval permission from authenticated users?
Comment #27
yesct commented#23: anon-access-comments-364159-23.patch queued for re-testing.
Comment #28
yesct commentedmy test results on my local machine with the patch did not match the test bot... retesting.
Comment #29
yesct commentedday over for now, if someone wants to try to make a patch... when the testbot reports back. :)
Comment #30
David_Rothstein commentedRe-uploading the patch from #17.
My comment in #21 is no longer valid, since in the interim #174972: User creation setting should be "Visitors, with admin approval" was committed. This means spammers won't be able to get through in the default install (because the administrator has to approve their account first).
So, this should be RTBC again if the tests pass.
Comment #31
David_Rothstein commentedRe #26:
The standard and minimal profiles were already different in this regard. I don't think there is any documentation of these kinds of differences, just the general idea that the minimal profile has very little in it (e.g., it doesn't even have the comment module enabled).
Comment #32
David_Rothstein commentedTests passed, so back to RTBC.
Comment #33
aspilicious commentedTotally in for this
Comment #34
dries commentedCommitted to CVS HEAD. Thanks.