[wp-trac] [WordPress Trac] #45677: REST Autosaves Controller creating extra instance of a post type REST controller

WordPress Trac noreply at wordpress.org
Mon Dec 17 17:54:35 UTC 2018


#45677: REST Autosaves Controller creating extra instance of a post type REST
controller
--------------------------+-----------------------------
 Reporter:  pat@…         |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:  5.0.1
 Severity:  major         |   Keywords:
  Focuses:  rest-api      |
--------------------------+-----------------------------
 If I register a REST controller using the 'rest_controller_class'
 parameter on register_post_type I would expect that it's instantiated once
 per REST request. This has been the case prior to 5.0

 In my constructors I often add a filter on "rest_prepare_{$post_type}" or
 "rest_{$post_type}_query" to influence the input/output. These filters are
 now being run twice per request.

 The WP_REST_Autosaves_Controller is created one per post type, and it's
 constructor creates a new instance of the post_type's controller. This
 seems unneccessary and it breaks some existing implementations. Why not
 pass the post type REST controller in to the constructor?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45677>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list