[wp-trac] [WordPress Trac] #39881: `WP_REST_Posts_Controller::check_read_permission()` should check if `$parent` exists before calling itself

WordPress Trac noreply at wordpress.org
Mon Feb 27 12:56:15 UTC 2017


#39881: `WP_REST_Posts_Controller::check_read_permission()` should check if
`$parent` exists before calling itself
-------------------------------------------------+-------------------------
 Reporter:  GhostToast                           |       Owner:
     Type:  defect (bug)                         |  rachelbaker
 Priority:  normal                               |      Status:  reviewing
Component:  REST API                             |   Milestone:  4.7.4
 Severity:  normal                               |     Version:  4.7
 Keywords:  has-patch dev-feedback needs-unit-   |  Resolution:
  tests                                          |     Focuses:  rest-api
-------------------------------------------------+-------------------------

Comment (by GhostToast):

 At the very least I would argue some error handling be in place. It is
 assumed that because a non-zero`post_parent` property is present, a valid
 `$post` object will exist with that ID. What about if we check for
 `get_post()` having returned something useful? `get_post_status()` handles
 this a bit, can see similar example here:
 https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-
 includes/post.php?marks=#L655

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


More information about the wp-trac mailing list