<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[45811] trunk: REST API: Cache results of get_item_schema on controller instances for performance.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/45811">45811</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/45811","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>kadamwhite</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-08-15 21:08:05 +0000 (Thu, 15 Aug 2019)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>REST API: Cache results of get_item_schema on controller instances for performance.
Caches the output of get_item_schema() to avoid redundant recomputation of translatable strings and other computed values. This method is called many times per item in each REST request, and the results of the method should not vary between calls.
Additional schema fields are not cached.
Props kadamwhite, joehoyle, TimothyBlynJacobs.
Fixes <a href="https://core.trac.wordpress.org/ticket/47871">#47871</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestattachmentscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestautosavescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestblockrenderercontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestblockscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestcommentscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestcontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestpoststatusescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestposttypescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestpostscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestrevisionscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestsearchcontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestsettingscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswpresttaxonomiescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswpresttermscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestthemescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestuserscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestpostscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestuserscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-users-controller.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesrestapiendpointsclasswprestattachmentscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -417,6 +417,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema as an array.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $schema = parent::get_item_schema();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -513,7 +516,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $schema['properties']['password'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $schema;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestautosavescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -296,6 +296,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $schema = $this->revisions_controller->get_item_schema();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $schema['properties']['preview_link'] = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -306,7 +310,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $schema;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestblockrenderercontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -161,7 +161,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->schema;
+ }
+
+ $this->schema = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> '$schema' => 'http://json-schema.org/schema#',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'rendered-block',
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'object',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -174,5 +178,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $this->schema;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestblockscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -68,6 +68,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Do not cache this schema because all properties are derived from parent controller.
</ins><span class="cx" style="display: block; padding: 0 10px"> $schema = parent::get_item_schema();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestcommentscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1215,6 +1215,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $schema = array(
</span><span class="cx" style="display: block; padding: 0 10px"> '$schema' => 'http://json-schema.org/draft-04/schema#',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'comment',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1364,7 +1368,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $schema['properties']['meta'] = $this->meta->get_field_schema();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->add_additional_fields_schema( $schema );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestcontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -31,6 +31,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> protected $rest_base;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Cached results of get_item_schema.
+ *
+ * @since 5.3.0
+ * @var array
+ */
+ protected $schema;
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Registers the routes for the objects of the controller.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.7.0
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestpoststatusescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -268,6 +268,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $schema = array(
</span><span class="cx" style="display: block; padding: 0 10px"> '$schema' => 'http://json-schema.org/draft-04/schema#',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'status',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -318,7 +322,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->add_additional_fields_schema( $schema );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestposttypescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,6 +242,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $schema = array(
</span><span class="cx" style="display: block; padding: 0 10px"> '$schema' => 'http://json-schema.org/draft-04/schema#',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'type',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -312,7 +316,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->add_additional_fields_schema( $schema );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestpostscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1870,6 +1870,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $schema = array(
</span><span class="cx" style="display: block; padding: 0 10px"> '$schema' => 'http://json-schema.org/draft-04/schema#',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2229,7 +2232,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $schema['links'] = $schema_links;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->add_additional_fields_schema( $schema );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestrevisionscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -606,6 +606,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $schema = array(
</span><span class="cx" style="display: block; padding: 0 10px"> '$schema' => 'http://json-schema.org/draft-04/schema#',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => "{$this->parent_post_type}-revision",
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -682,7 +686,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $schema['properties']['guid'] = $parent_schema['properties']['guid'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->add_additional_fields_schema( $schema );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestsearchcontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -211,6 +211,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $types = array();
</span><span class="cx" style="display: block; padding: 0 10px"> $subtypes = array();
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $this->search_handlers as $search_handler ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -262,7 +266,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->add_additional_fields_schema( $schema );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestsettingscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -270,6 +270,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $options = $this->get_registered_options();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $schema = array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -286,7 +290,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->add_additional_fields_schema( $schema );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswpresttaxonomiescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -276,6 +276,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $schema = array(
</span><span class="cx" style="display: block; padding: 0 10px"> '$schema' => 'http://json-schema.org/draft-04/schema#',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'taxonomy',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -373,7 +377,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->add_additional_fields_schema( $schema );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswpresttermscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -856,6 +856,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $schema = array(
</span><span class="cx" style="display: block; padding: 0 10px"> '$schema' => 'http://json-schema.org/draft-04/schema#',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'post_tag' === $this->taxonomy ? 'tag' : $this->taxonomy,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -924,7 +928,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $schema['properties']['meta'] = $this->meta->get_field_schema();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->add_additional_fields_schema( $schema );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestthemescontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -147,6 +147,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $schema = array(
</span><span class="cx" style="display: block; padding: 0 10px"> '$schema' => 'http://json-schema.org/draft-04/schema#',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'theme',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -177,7 +181,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->add_additional_fields_schema( $schema );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestuserscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1178,6 +1178,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Item schema data.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_item_schema() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $this->schema ) {
+ return $this->add_additional_fields_schema( $this->schema );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $schema = array(
</span><span class="cx" style="display: block; padding: 0 10px"> '$schema' => 'http://json-schema.org/draft-04/schema#',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'user',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1334,7 +1338,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $schema['properties']['meta'] = $this->meta->get_field_schema();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $this->add_additional_fields_schema( $schema );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = $schema;
+ return $this->add_additional_fields_schema( $this->schema );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestpostscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3919,6 +3919,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> remove_post_type_support( 'post', 'author' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Re-initialize the controller to cache-bust schemas from prior test runs.
+ $GLOBALS['wp_rest_server']->override_by_default = true;
+ $controller = new WP_REST_Posts_Controller( 'post' );
+ $controller->register_routes();
+ $GLOBALS['wp_rest_server']->override_by_default = false;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><span class="cx" style="display: block; padding: 0 10px"> $schema = $data['schema'];
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestuserscontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/rest-api/rest-users-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-users-controller.php 2019-08-15 20:03:18 UTC (rev 45810)
+++ trunk/tests/phpunit/tests/rest-api/rest-users-controller.php 2019-08-15 21:08:05 UTC (rev 45811)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2522,6 +2522,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_get_item_schema_show_avatar() {
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'show_avatars', false );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Re-initialize the controller to cache-bust schemas from prior test runs.
+ $GLOBALS['wp_rest_server']->override_by_default = true;
+ $controller = new WP_REST_Users_Controller();
+ $controller->register_routes();
+ $GLOBALS['wp_rest_server']->override_by_default = false;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' );
</span><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span></span></pre>
</div>
</div>
</body>
</html>