Opened 8 years ago
Closed 8 years ago
#38692 closed defect (bug) (fixed)
REST API: Add support for comments of password-protected posts
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | REST API | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
Migrated from https://github.com/WP-API/WP-API/issues/2791. Current status from @rachelbaker:
The Comments Controller does not have a password param to support viewing/editing/creating/deleting comments on password protected posts. Attempting to interact with a comment on a password protected post returns a WP_Error because without the proper post password the permission checks fail.
Action items:
- Add the password param to allow users to pass the password for the related Post to a Comment.
- Modify our permission checks to support handling the password param
- Add unit tests
I think this parameter should be called post_password
and we should try to get this into 4.7 for consistency and completeness. Arguable whether this is a bug, but it's unexpected behavior to me.
Attachments (2)
Change History (10)
This ticket was mentioned in Slack in #core-restapi by joehoyle. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by helen. View the logs.
8 years ago
#5
@
8 years ago
- Keywords has-unit-tests added; needs-unit-tests removed
38692.2.diff adds unit tests for the changes.
#6
@
8 years ago
- Milestone changed from Awaiting Review to 4.7
- "Should we deal with passing multiple passwords?" Probably not, neither core nor the API supports this for listing posts.
- Based on the logic in the posts controller ("Edit context always gets access to password-protected posts") we should be fine here.
38692.diff allows to read comments of password-protected posts when passing the correct
password
parameter with the request. It works by making theWP_REST_Posts_Controller::can_access_password_content()
method public and calling it fromWP_REST_Comments_Controller::check_read_post_permission()
. In order for it to work, the$request
object is passed to that method.Thoughts / questsions:
WP_REST_Comments_Controller::check_edit_permission()
as well? I don't think this makes sense since I don't see how someone that can edit the comment wouldn't be able to read the password-protected post. Correct me if I'm wrong.