<!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>[46272] trunk: REST API: Introduce WP_Post_Type::get_rest_controller() caching method to prevent unnecessary REST controller construction.</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/46272">46272</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/46272","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-09-23 20:24:59 +0000 (Mon, 23 Sep 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: Introduce WP_Post_Type::get_rest_controller() caching method to prevent unnecessary REST controller construction.

Cache REST controller references on their associated post type object to prevent unnecessary controller re-instantiation, which previously caused "rest_prepare_{$post_type}" and "rest_{$post_type}_query" to run twice per request.

Props TimothyBlynJacobs, patrelentlesstechnologycom.
Fixes <a href="https://core.trac.wordpress.org/ticket/45677">#45677</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpposttypephp">trunk/src/wp-includes/class-wp-post-type.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="#trunksrcwpincludesrestapiendpointsclasswprestcommentscontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-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="#trunksrcwpincludesrestapiphp">trunk/src/wp-includes/rest-api.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestpostscontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpposttypephp"></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-post-type.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-post-type.php      2019-09-23 20:14:50 UTC (rev 46271)
+++ trunk/src/wp-includes/class-wp-post-type.php        2019-09-23 20:24:59 UTC (rev 46272)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -336,6 +336,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public $rest_controller_class;
</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">+         * The controller instance for this post type's REST API endpoints.
+        *
+        * Lazily computed. Should be accessed using {@see WP_Post_Type::get_rest_controller()}.
+        *
+        * @since 5.3.0
+        * @var WP_REST_Controller $rest_controller
+        */
+       private $rest_controller;
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Constructor.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * Will populate object properties from the provided arguments and assign other
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -682,4 +692,36 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function remove_hooks() {
</span><span class="cx" style="display: block; padding: 0 10px">                remove_action( 'future_' . $this->name, '_future_post_hook', 5 );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       /**
+        * Gets the REST API controller for this post type.
+        *
+        * Will only instantiate the controller class once per request.
+        *
+        * @since 5.3.0
+        *
+        * @return WP_REST_Controller|null The controller instance, or null if the post type
+        *                                 is set not to show in rest.
+        */
+       public function get_rest_controller() {
+               if ( ! $this->show_in_rest ) {
+                       return null;
+               }
+
+               $class = $this->rest_controller_class ? $this->rest_controller_class : WP_REST_Posts_Controller::class;
+
+               if ( ! class_exists( $class ) ) {
+                       return null;
+               }
+
+               if ( ! is_subclass_of( $class, WP_REST_Controller::class ) ) {
+                       return null;
+               }
+
+               if ( ! $this->rest_controller ) {
+                       $this->rest_controller = new $class( $this->name );
+               }
+
+               return $this->rest_controller;
+       }
</ins><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-09-23 20:14:50 UTC (rev 46271)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php     2019-09-23 20:24:59 UTC (rev 46272)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,11 +59,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">        public function __construct( $parent_post_type ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $this->parent_post_type = $parent_post_type;
</span><span class="cx" style="display: block; padding: 0 10px">                $post_type_object       = get_post_type_object( $parent_post_type );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $parent_controller      = $post_type_object->get_rest_controller();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Ensure that post type-specific controller logic is available.
-               $parent_controller_class = ! empty( $post_type_object->rest_controller_class ) ? $post_type_object->rest_controller_class : 'WP_REST_Posts_Controller';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! $parent_controller ) {
+                       $parent_controller = new WP_REST_Posts_Controller( $parent_post_type );
+               }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->parent_controller    = new $parent_controller_class( $post_type_object->name );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->parent_controller    = $parent_controller;
</ins><span class="cx" style="display: block; padding: 0 10px">                 $this->revisions_controller = new WP_REST_Revisions_Controller( $parent_post_type );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->rest_namespace       = 'wp/v2';
</span><span class="cx" style="display: block; padding: 0 10px">                $this->rest_base            = 'autosaves';
</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-09-23 20:14:50 UTC (rev 46271)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php      2019-09-23 20:24:59 UTC (rev 46272)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1592,9 +1592,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @return bool Whether post can be read.
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        protected function check_read_post_permission( $post, $request ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $posts_controller = new WP_REST_Posts_Controller( $post->post_type );
</del><span class="cx" style="display: block; padding: 0 10px">                 $post_type        = get_post_type_object( $post->post_type );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $posts_controller = $post_type->get_rest_controller();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                // Ensure the posts controller is specifically a WP_REST_Posts_Controller instance
+               // before using methods specific to that controller.
+               if ( ! $posts_controller instanceof WP_REST_Posts_Controller ) {
+                       $posts_controller = new WP_REST_Posts_Controller( $post->post_type );
+               }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $has_password_filter = false;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Only check password if a specific post was queried for or a single comment
</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-09-23 20:14:50 UTC (rev 46271)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 2019-09-23 20:24:59 UTC (rev 46272)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -17,6 +17,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_REST_Posts_Controller extends WP_REST_Controller {
</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">+         * Instances of post type controllers keyed by post type.
+        *
+        * @since 5.3.0
+        * @var WP_REST_Controller[]
+        */
+       private static $post_type_controllers = array();
+
+       /**
</ins><span class="cx" style="display: block; padding: 0 10px">          * Post type.
</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="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-09-23 20:14:50 UTC (rev 46271)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php     2019-09-23 20:24:59 UTC (rev 46272)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -49,11 +49,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="cx" style="display: block; padding: 0 10px">        public function __construct( $parent_post_type ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $this->parent_post_type  = $parent_post_type;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->parent_controller = new WP_REST_Posts_Controller( $parent_post_type );
</del><span class="cx" style="display: block; padding: 0 10px">                 $this->namespace         = 'wp/v2';
</span><span class="cx" style="display: block; padding: 0 10px">                $this->rest_base         = 'revisions';
</span><span class="cx" style="display: block; padding: 0 10px">                $post_type_object        = get_post_type_object( $parent_post_type );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->parent_base       = ! empty( $post_type_object->rest_base ) ? $post_type_object->rest_base : $post_type_object->name;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $this->parent_controller = $post_type_object->get_rest_controller();
+
+               if ( ! $this->parent_controller ) {
+                       $this->parent_controller = new WP_REST_Posts_Controller( $parent_post_type );
+               }
</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="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        2019-09-23 20:14:50 UTC (rev 46271)
+++ trunk/src/wp-includes/rest-api.php  2019-09-23 20:24:59 UTC (rev 46272)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -192,15 +192,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function create_initial_rest_routes() {
</span><span class="cx" style="display: block; padding: 0 10px">        foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $class = ! empty( $post_type->rest_controller_class ) ? $post_type->rest_controller_class : 'WP_REST_Posts_Controller';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $controller = $post_type->get_rest_controller();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! class_exists( $class ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! $controller ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         continue;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $controller = new $class( $post_type->name );
-               if ( ! is_subclass_of( $controller, 'WP_REST_Controller' ) ) {
-                       continue;
-               }
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $controller->register_routes();
</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-09-23 20:14:50 UTC (rev 46271)
+++ trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php        2019-09-23 20:24:59 UTC (rev 46272)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4526,6 +4526,87 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNotEquals( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt );
</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 45677
+        */
+       public function test_get_for_post_type_reuses_same_instance() {
+               $this->assertSame(
+                       get_post_type_object( 'post' )->get_rest_controller(),
+                       get_post_type_object( 'post' )->get_rest_controller()
+               );
+       }
+
+       /**
+        * @ticket 45677
+        */
+       public function test_get_for_post_type_returns_null_if_post_type_does_not_show_in_rest() {
+               register_post_type(
+                       'not_in_rest',
+                       array(
+                               'show_in_rest' => false,
+                       )
+               );
+
+               $this->assertNull( get_post_type_object( 'not_in_rest' )->get_rest_controller() );
+       }
+
+       /**
+        * @ticket 45677
+        */
+       public function test_get_for_post_type_returns_null_if_class_does_not_exist() {
+               register_post_type(
+                       'class_not_found',
+                       array(
+                               'show_in_rest'          => true,
+                               'rest_controller_class' => 'Class_That_Does_Not_Exist',
+                       )
+               );
+
+               $this->assertNull( get_post_type_object( 'class_not_found' )->get_rest_controller() );
+       }
+
+       /**
+        * @ticket 45677
+        */
+       public function test_get_for_post_type_returns_null_if_class_does_not_subclass_rest_controller() {
+               register_post_type(
+                       'invalid_class',
+                       array(
+                               'show_in_rest'          => true,
+                               'rest_controller_class' => 'WP_Post',
+                       )
+               );
+
+               $this->assertNull( get_post_type_object( 'invalid_class' )->get_rest_controller() );
+       }
+
+       /**
+        * @ticket 45677
+        */
+       public function test_get_for_post_type_returns_posts_controller_if_custom_class_not_specified() {
+               register_post_type(
+                       'test',
+                       array(
+                               'show_in_rest' => true,
+                       )
+               );
+
+               $this->assertInstanceOf(
+                       WP_REST_Posts_Controller::class,
+                       get_post_type_object( 'test' )->get_rest_controller()
+               );
+       }
+
+       /**
+        * @ticket 45677
+        */
+       public function test_get_for_post_type_returns_provided_controller_class() {
+               $this->assertInstanceOf(
+                       WP_REST_Blocks_Controller::class,
+                       get_post_type_object( 'wp_block' )->get_rest_controller()
+               );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         public function tearDown() {
</span><span class="cx" style="display: block; padding: 0 10px">                _unregister_post_type( 'private-post' );
</span><span class="cx" style="display: block; padding: 0 10px">                _unregister_post_type( 'youseeme' );
</span></span></pre>
</div>
</div>

</body>
</html>