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

WordPress Trac noreply at wordpress.org
Mon Sep 23 19:41:47 UTC 2019


#45677: REST Autosaves Controller creating extra instance of a post type REST
controller
--------------------------------------+--------------------------------
 Reporter:  pat@…                     |       Owner:  TimothyBlynJacobs
     Type:  defect (bug)              |      Status:  assigned
 Priority:  normal                    |   Milestone:  5.3
Component:  REST API                  |     Version:  5.0
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  rest-api
--------------------------------------+--------------------------------

Comment (by TimothyBlynJacobs):

 Uploaded a version of the patch that uses
 `WP_Post_Type::get_rest_controller()` as described in
 https://core.trac.wordpress.org/ticket/40383#comment:5.

 Now that the REST API schema is cached on an instance property of the
 `WP_REST_Controller`, any changes to the registered fields would not be
 reflected when running unit tests since we'd reuse the same
 `WP_REST_Controller` instance.

 Moving it onto the post type kill this cache since the post types are
 unregistered and registered in `WP_UnitTestCase_Base::reset_post_types`.

 Alternatively, we could kill the static cache on `WP_REST_Controller` in
 `tearDown` on REST API tests.

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


More information about the wp-trac mailing list