[wp-trac] [WordPress Trac] #42238: Notice when Rest Comments controler is checking permision for a non existent post type

WordPress Trac noreply at wordpress.org
Thu Oct 19 12:53:00 UTC 2017


#42238: Notice when Rest Comments controler is checking permision for a non
existent post type
-------------------------------+------------------------------
 Reporter:  dragosh635         |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  REST API           |     Version:  4.8.2
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:
-------------------------------+------------------------------

Comment (by dragosh635):

 Hello, @subrataemfluence

 Thank you for looking into the matter and sorry for not beeing able to
 respond earilier.

 I remade the test with a custom plugin in the same way you did ( without
 using woocommerce ) and the notice was still there.

 Your first few steps were ok ( 1 -  3 ), from than I think it was a
 misunderstanding. Basically I was speaking of getting the comments from
 the post using the rest api. I think your example refers to get the posts
 created with that custom post type.

 So, my error is when getting the comments using the rest api and in the
 comments list there is a comment on a post of a custom post type that not
 longer exists.

 Your next steps in debugging would be: ( the post type needs to be set to
 accept comments and enable rest api). I used this function to create my
 custom post type

 {{{#!php
 <?php
 register_post_type( 'bug_post',
                 array(
                         'labels'       => array(
                                 'name'          => __( 'Bug Post' ),
                                 'singular_name' => __( 'Bugs' )
                         ),
                         'public'       => true,
                         'has_archive'  => true,
                         'supports'     => array( 'title', 'editor',
 'author', 'excerpt', 'comments', 'revisions' ),
                         'show_in_rest' => true,
                 )
         );
 }}}


 4.After publishing the post, go on it and add a few comments.
 5.Run the next rest route http://{insert_your_local_url}/wp-
 json/wp/v2/comments -> you should get the list of comments
 6.Disable the plugin
 7.Run the rest route again -> a PHP notice will appear ( only when
 WP_DEBUG is set to true )

 I hope that this clarifies the issue.
 Thank you for the heads up to not use a third party plugin in my testing.

 If there is anything else that I can clear please feel free to comment on
 my ticket.

 Thanks,
 Dragos

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42238#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list