From facece4fa16bec55ecb1509d013b30f3c36a7ce8 Mon Sep 17 00:00:00 2001
From: Himani <himaniwork3010@gmail.com>
Date: Mon, 25 Nov 2019 10:01:26 +0530
Subject: [PATCH] Fix: #42238 Notice when Rest Comments controller is checking

---
 .../endpoints/class-wp-rest-comments-controller.php         | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
index 4fce45878c..87c982f52f 100644
--- a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
+++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
@@ -1593,6 +1593,12 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
 	 */
 	protected function check_read_post_permission( $post, $request ) {
 		$post_type        = get_post_type_object( $post->post_type );
+		
+		// Return false if custom post type doesn't exist
+		if ( ! $post_type ) {
+			return false;
+		}
+		
 		$posts_controller = $post_type->get_rest_controller();
 
 		// Ensure the posts controller is specifically a WP_REST_Posts_Controller instance
-- 
2.20.0.windows.1

