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

Closed

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 ) );
        }

Activity

  1. added this to the 2.0 milestone on Dec 10, 2015
  2. danielbachhuber commented on Dec 10, 2015

    @danielbachhuber
    Member

    Related #1652

  3. removed their assignment
    on Dec 15, 2015
  4. danielbachhuber commented on Dec 15, 2015

    @danielbachhuber
    Member

    Blocked on core, as it turns out https://core.trac.wordpress.org/ticket/35090

  5. danielbachhuber commented on Feb 2, 2016

    @danielbachhuber
    Member

    Actually, post__in works fine for our needs

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

      Sponsor
      SponsoredKunjungi sekarang
      Promo