[wp-trac] [WordPress Trac] #41555: REST API: Call `rest_get_server()` instead of accessing the `$wp_rest_server` global

WordPress Trac noreply at wordpress.org
Thu Aug 3 21:17:14 UTC 2017


#41555: REST API: Call `rest_get_server()` instead of accessing the
`$wp_rest_server` global
--------------------------+-----------------------
 Reporter:  jnylen0       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  4.9
Component:  REST API      |    Version:  4.4
 Severity:  normal        |   Keywords:  has-patch
  Focuses:  rest-api      |
--------------------------+-----------------------
 It is possible, though unlikely, that REST API functions can be called
 from within a context that has not actually loaded a `WP_REST_Server`
 instance into the `$wp_rest_server` variable.  This has caused a few
 crashes on WP.com; details are well within the nightmare zone of
 customized WordPress load order.

 There is already a `rest_get_server()` function to ensure that the server
 object is initialized before attempting to do anything with it; we should
 be consistent in using this function rather than the global variable.

 This was mostly done in [36529] (cc @rmccue); the patch attached here
 cleans up all remaining uses of `$wp_rest_server` except for those within
 the `rest_get_server()` function, along with a few errant `@global`
 annotations.

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


More information about the wp-trac mailing list