Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Allow comments with a comment_post_ID of 0 in our GET requests #1832

Description

@rachelbaker

Users with the moderate_comments permission should be allowed to view comments that are not attached to a Post.

What happens now

GET Comments Collection:

We don't check that the comment_post_ID !==0 in WP_REST_Comments_Controller->get_items() before checking the read post permission anyone that even has comments without a post relationship gets this response:

[ ]

No error, just an empty response with a PHP Notice in their log about trying to get the property on a non-object.

GET Single Comment

$post = get_post( $comment->comment_post_ID );
        if ( empty( $post ) ) {
            return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post id.' ), array( 'status' => 404 ) );
        }

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions