<!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>[48526] trunk: REST API: Issue a _doing_it_wrong when registering a route without a permission callback.</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/48526">48526</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/48526","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>TimothyBlynJacobs</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-07-21 12:01:10 +0000 (Tue, 21 Jul 2020)</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: Issue a _doing_it_wrong when registering a route without a permission callback.

The REST API treats routes without a permission_callback as public. Because this happens without any warning to the user, if the permission callback is unintentionally omitted or misspelled, the endpoint can end up being available to the public. Such a scenario has happened multiple times in the wild, and the results can be catostrophic when it occurs.

For REST API routes that are intended to be public, it is recommended to set the permission callback to the `__return_true` built in function.

Fixes <a href="https://core.trac.wordpress.org/ticket/50075">#50075</a>.
Props rmccue, sorenbronsted, whyisjake, SergeyBiryukov, TimothyBlynJacobs.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpoembedcontrollerphp">trunk/src/wp-includes/class-wp-oembed-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="#trunksrcwpincludesrestapiendpointsclasswprestuserscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php</a></li>
<li><a href="#trunksrcwpincludesrestapiphp">trunk/src/wp-includes/rest-api.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestserverphp">trunk/tests/phpunit/tests/rest-api/rest-server.php</a></li>
<li><a href="#trunktestsphpunittestsrestapiphp">trunk/tests/phpunit/tests/rest-api.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpoembedcontrollerphp"></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/class-wp-oembed-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-oembed-controller.php      2020-07-21 02:59:00 UTC (rev 48525)
+++ trunk/src/wp-includes/class-wp-oembed-controller.php        2020-07-21 12:01:10 UTC (rev 48526)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,9 +36,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '/embed',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'methods'  => WP_REST_Server::READABLE,
-                                       'callback' => array( $this, 'get_item' ),
-                                       'args'     => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'methods'             => WP_REST_Server::READABLE,
+                                       'callback'            => array( $this, 'get_item' ),
+                                       'permission_callback' => '__return_true',
+                                       'args'                => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                                 'url'      => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                                        'description' => __( 'The URL of the resource for which to fetch oEmbed data.' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                                        'required'    => true,
</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  2020-07-21 02:59:00 UTC (rev 48525)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php    2020-07-21 12:01:10 UTC (rev 48526)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -60,9 +60,10 @@
</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">                                array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'methods'  => WP_REST_Server::READABLE,
-                                       'callback' => array( $this, 'get_item' ),
-                                       'args'     => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'methods'             => WP_REST_Server::READABLE,
+                                       'callback'            => array( $this, 'get_item' ),
+                                       'permission_callback' => '__return_true',
+                                       'args'                => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                                 'context' => $this->get_context_param( array( 'default' => 'view' ) ),
</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       2020-07-21 02:59:00 UTC (rev 48525)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php 2020-07-21 12:01:10 UTC (rev 48526)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -116,9 +116,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '/' . $this->rest_base . '/me',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'methods'  => WP_REST_Server::READABLE,
-                                       'callback' => array( $this, 'get_current_item' ),
-                                       'args'     => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'methods'             => WP_REST_Server::READABLE,
+                                       'permission_callback' => '__return_true',
+                                       'callback'            => array( $this, 'get_current_item' ),
+                                       'args'                => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                                 'context' => $this->get_context_param( array( 'default' => 'view' ) ),
</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="trunksrcwpincludesrestapiphp"></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.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api.php        2020-07-21 02:59:00 UTC (rev 48525)
+++ trunk/src/wp-includes/rest-api.php  2020-07-21 12:01:10 UTC (rev 48526)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -88,6 +88,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $arg_group         = array_merge( $defaults, $arg_group );
</span><span class="cx" style="display: block; padding: 0 10px">                $arg_group['args'] = array_merge( $common_args, $arg_group['args'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+               if ( ! isset( $arg_group['permission_callback'] ) ) {
+                       _doing_it_wrong(
+                               __FUNCTION__,
+                               sprintf(
+                                       /* translators: 1. The REST API route being registered. 2. The argument name. 3. The suggested function name. */
+                                       __( 'The REST API route definition for %1$s is missing the required %2$s argument. For REST API routes that are intended to be public, use %3$s as the permission callback.', 'LION' ),
+                                       '<code>' . $clean_namespace . '/' . trim( $route, '/' ) . '</code>',
+                                       '<code>permission_callback</code>',
+                                       '<code>__return_true</code>'
+                               ),
+                               '5.5.0'
+                       );
+               }
</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">        $full_route = '/' . $clean_namespace . '/' . trim( $route, '/' );
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestserverphp"></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-server.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-server.php        2020-07-21 02:59:00 UTC (rev 48525)
+++ trunk/tests/phpunit/tests/rest-api/rest-server.php  2020-07-21 12:01:10 UTC (rev 48526)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -66,9 +66,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => '__return_null',
-                               'args'     => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
+                               'args'                => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                         'foo' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                                'default' => 'bar',
</span><span class="cx" style="display: block; padding: 0 10px">                                        ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -88,9 +89,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => '__return_null',
-                               'args'     => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
+                               'args'                => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                         'foo' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                                'default' => 'bar',
</span><span class="cx" style="display: block; padding: 0 10px">                                        ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -110,9 +112,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'optional',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => '__return_null',
-                               'args'     => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
+                               'args'                => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                         'foo' => array(),
</span><span class="cx" style="display: block; padding: 0 10px">                                ),
</span><span class="cx" style="display: block; padding: 0 10px">                        )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -131,9 +134,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'no-zero',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => '__return_null',
-                               'args'     => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
+                               'args'                => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                         'foo' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                                'default' => 'bar',
</span><span class="cx" style="display: block; padding: 0 10px">                                        ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -150,8 +154,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'head-request',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => '__return_true',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => '__return_true',
+                               'permission_callback' => '__return_true',
</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">                $request  = new WP_REST_Request( 'HEAD', '/head-request/test' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -171,8 +176,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'methods'  => array( 'HEAD' ),
-                                       'callback' => '__return_true',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'methods'             => array( 'HEAD' ),
+                                       'callback'            => '__return_true',
+                                       'permission_callback' => '__return_true',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 ),
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'methods'             => array( 'GET' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -193,9 +199,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test/(?P<data>.*)',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'methods'  => WP_REST_Server::READABLE,
-                                       'callback' => '__return_false',
-                                       'args'     => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'methods'             => WP_REST_Server::READABLE,
+                                       'callback'            => '__return_false',
+                                       'permission_callback' => '__return_true',
+                                       'args'                => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                                 'data' => array(),
</span><span class="cx" style="display: block; padding: 0 10px">                                        ),
</span><span class="cx" style="display: block; padding: 0 10px">                                ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -266,9 +273,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'      => 'GET',
-                               'callback'     => '__return_null',
-                               'should_exist' => false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => 'GET',
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
+                               'should_exist'        => false,
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -293,9 +301,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'      => 'GET',
-                               'callback'     => '__return_null',
-                               'should_exist' => false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => 'GET',
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
+                               'should_exist'        => false,
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -303,9 +312,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'      => 'POST',
-                               'callback'     => '__return_null',
-                               'should_exist' => false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => 'POST',
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
+                               'should_exist'        => false,
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -342,9 +352,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'      => 'POST',
-                               'callback'     => '__return_null',
-                               'should_exist' => false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => 'POST',
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
+                               'should_exist'        => false,
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -365,8 +376,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'methods'  => array( 'GET' ),
-                                       'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'methods'             => array( 'GET' ),
+                                       'callback'            => '__return_null',
+                                       'permission_callback' => '__return_true',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 ),
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><span class="cx" style="display: block; padding: 0 10px">                                        'methods'             => array( 'POST' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1327,9 +1339,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => '__return_null',
-                               'args'     => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
+                               'args'                => array(
</ins><span class="cx" style="display: block; padding: 0 10px">                                         'someinteger' => array(
</span><span class="cx" style="display: block; padding: 0 10px">                                                'validate_callback' => array( $this, '_validate_as_integer_123' ),
</span><span class="cx" style="display: block; padding: 0 10px">                                                'sanitize_callback' => 'absint',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1362,10 +1375,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => function () {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => function () {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         return new WP_REST_Response();
</span><span class="cx" style="display: block; padding: 0 10px">                                },
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1383,10 +1397,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => function () {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => function () {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         return new WP_REST_Response( 'data', 204 );
</span><span class="cx" style="display: block; padding: 0 10px">                                },
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1473,10 +1488,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => function() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => function() {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         return new WP_REST_Response( 'data', 204 );
</span><span class="cx" style="display: block; padding: 0 10px">                                },
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'permission_callback' => '__return_true',
</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">                register_rest_route(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1483,10 +1499,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns/v1',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => function() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => function() {
</ins><span class="cx" style="display: block; padding: 0 10px">                                         return new WP_REST_Response( 'data', 204 );
</span><span class="cx" style="display: block; padding: 0 10px">                                },
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                'permission_callback' => '__return_true',
</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="trunktestsphpunittestsrestapiphp"></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.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api.php    2020-07-21 02:59:00 UTC (rev 48525)
+++ trunk/tests/phpunit/tests/rest-api.php      2020-07-21 12:01:10 UTC (rev 48526)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -84,8 +84,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -120,12 +121,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'methods'  => array( 'GET' ),
-                                       'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'methods'             => array( 'GET' ),
+                                       'callback'            => '__return_null',
+                                       'permission_callback' => '__return_true',
</ins><span class="cx" style="display: block; padding: 0 10px">                                 ),
</span><span class="cx" style="display: block; padding: 0 10px">                                array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                        'methods'  => array( 'POST' ),
-                                       'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                 'methods'             => array( 'POST' ),
+                                       'callback'            => '__return_null',
+                                       'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -160,8 +163,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
</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">                register_rest_route(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -168,8 +172,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'POST' ),
-                               'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'POST' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -187,9 +192,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'      => array( 'GET' ),
-                               'callback'     => '__return_null',
-                               'should_exist' => false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
+                               'should_exist'        => false,
</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">                register_rest_route(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -196,9 +202,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'      => array( 'POST' ),
-                               'callback'     => '__return_null',
-                               'should_exist' => true,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'POST' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
+                               'should_exist'        => true,
</ins><span class="cx" style="display: block; padding: 0 10px">                         ),
</span><span class="cx" style="display: block; padding: 0 10px">                        true
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -223,8 +230,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test-empty-namespace',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'POST' ),
-                               'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'POST' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
</ins><span class="cx" style="display: block; padding: 0 10px">                         ),
</span><span class="cx" style="display: block; padding: 0 10px">                        true
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,8 +250,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test-empty-route',
</span><span class="cx" style="display: block; padding: 0 10px">                        '',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'POST' ),
-                               'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'POST' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
</ins><span class="cx" style="display: block; padding: 0 10px">                         ),
</span><span class="cx" style="display: block; padding: 0 10px">                        true
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -264,8 +273,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -282,8 +292,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => 'GET',
-                               'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => 'GET',
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -300,8 +311,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET', 'POST' ),
-                               'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET', 'POST' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -324,8 +336,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => 'GET,POST',
-                               'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => 'GET,POST',
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -345,8 +358,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => 'GET,POST',
-                               'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => 'GET,POST',
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -367,8 +381,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => 'GET,POST',
-                               'callback' => '__return_true',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => 'GET,POST',
+                               'callback'            => '__return_true',
+                               'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -910,8 +925,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'test-ns',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/test',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'methods'  => array( 'GET' ),
-                               'callback' => '__return_null',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'methods'             => array( 'GET' ),
+                               'callback'            => '__return_null',
+                               'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -996,7 +1012,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        '/my-namespace/v1/',
</span><span class="cx" style="display: block; padding: 0 10px">                        '/my-route',
</span><span class="cx" style="display: block; padding: 0 10px">                        array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                'callback' => '__return_true',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         'callback'            => '__return_true',
+                               'permission_callback' => '__return_true',
</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 class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1006,6 +1023,66 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( rest_do_request( '/my-namespace/v1/my-route' )->get_data() );
</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">+        /**
+        * @ticket 50075
+        */
+       public function test_register_route_with_missing_permission_callback_top_level_route() {
+               $this->setExpectedIncorrectUsage( 'register_rest_route' );
+
+               $registered = register_rest_route(
+                       'my-ns/v1',
+                       '/my-route',
+                       array(
+                               'callback' => '__return_true',
+                       )
+               );
+
+               $this->assertTrue( $registered );
+       }
+
+       /**
+        * @ticket 50075
+        */
+       public function test_register_route_with_missing_permission_callback_single_wrapped_route() {
+               $this->setExpectedIncorrectUsage( 'register_rest_route' );
+
+               $registered = register_rest_route(
+                       'my-ns/v1',
+                       '/my-route',
+                       array(
+                               array(
+                                       'callback' => '__return_true',
+                               ),
+                       )
+               );
+
+               $this->assertTrue( $registered );
+       }
+
+
+       /**
+        * @ticket 50075
+        */
+       public function test_register_route_with_missing_permission_callback_multiple_wrapped_route() {
+               $this->setExpectedIncorrectUsage( 'register_rest_route' );
+
+               $registered = register_rest_route(
+                       'my-ns/v1',
+                       '/my-route',
+                       array(
+                               array(
+                                       'callback' => '__return_true',
+                               ),
+                               array(
+                                       'callback'            => '__return_true',
+                                       'permission_callback' => '__return_true',
+                               ),
+                       )
+               );
+
+               $this->assertTrue( $registered );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         public function _dp_rest_filter_response_by_context() {
</span><span class="cx" style="display: block; padding: 0 10px">                return array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'default'                => array(
</span></span></pre>
</div>
</div>

</body>
</html>