When a role has the "post comments" permission but not the "access comments" permission he will see an "Add new comment" link at the bottom of the node page. It links to #comment-form, but the form is not there, i.e. nothing happens. In D6 the link generates a server hit, but only to show the error message "You are not authorized to view comments."
I don't know if it is intentional that the "access comments" permission prevent posting comments. It seems reasonable that a site admin will allow users to comment on nodes without showing the comments publicly. The error message in D6 doesn't really make sense from an end-user point of view.
This patch allows users to post comments without having permission to view comments.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | drupal.comment-permissions.22.patch | 9.24 KB | sun |
| #12 | drupal.comment-permissions.12.patch | 9.32 KB | sun |
| #9 | drupal.comment-permissions.9.patch | 8.58 KB | sun |
| #6 | drupal.comment-permissions.6.patch | 8.46 KB | sun |
| #4 | drupal.comment-permissions.4.patch | 8.54 KB | sun |
Comments
Comment #1
c960657 commentedReroll.
Comment #2
aaronbaumanInitially I got hung up on #438224: "Post comments without approval" permission name is completely misleading, but after enabling the wrongly-named "Post comments with approval" permission that's actually just "Post comments", this patch worked for me.
Comment #3
Anonymous (not verified) commentedgot here from #845774: Regression: Anonymous users can post comments in the name of registered users, will review shortly.
Comment #4
sunSqueezed a similar fix into #757154: Base form_id via hook_forms() not taken into account for #validate, #submit, hook_form_FORMID_alter(), this issue is a better home.
This has to invoke node_access() -- overall, that entire logic in comment_reply() scares me a bit. Did you try whether it can be simplified?
Attached is just a re-roll, including tiny adjustment of parentheses in the access condition.
40 critical left. Go review some!
Comment #6
sunRe-rolled against HEAD.
Comment #7
sunThe "Add new comment" link assertion I removed in #6 is required and needs to be kept, it seems. At least, that link appears without this patch.
Comment #8
effulgentsia commentedsubscribing
Comment #9
sunRe-rolled against HEAD.
Comment #10
sunComment #11
dwwI believe this is a bug:
Note:
[und];)Comment #12
sunWell, that's not really related to this patch. Fixed it anyway.
Comment #13
coderintherye commentedThis patch applies cleanly on the latest Drupal HEAD, does exactly what it states it will do, and has no problems found via coder. I tested this on Drupal Head on Oct. 12th, and reversed and reapplied the patch a couple times and tried posting a couple comments as well and found no issues.
Marking RTBC. Please mark back if you find an issue I didn't see.
Comment #14
sun#12: drupal.comment-permissions.12.patch queued for re-testing.
Comment #15
sun#12: drupal.comment-permissions.12.patch queued for re-testing.
Comment #17
sun#12: drupal.comment-permissions.12.patch queued for re-testing.
Comment #18
sunThis is 1) a WTF and 2) a tiny API change.
Comment #19
sun#12: drupal.comment-permissions.12.patch queued for re-testing.
Comment #20
webchickSorry, but IMO this represents a behaviour change way after we can make behaviour changes like this. It's not a bad idea, mind you. But invalidates documentation and makes a miniscule API shift for a non-critical bug.
Bumping to 8.x.
Comment #21
sunComment form on same page. 0 comments exist. View of an anonymous user, having "post comments" but not "view comments" permission:
Comment #22
sunassertNoLink() only has two arguments. Fixed in attached patch.
Powered by Dreditor.
Comment #23
sunAlthough this patch can be committed as is, I wanted to mention that it has been merged into #754760: "Add new comment" appears directly above comment form / "post comments" does not work without "access comments" permission, because that patch tests all possible permutations of comment links under all possible conditions.
Comment #24
webchickLet's deal with it over there.