mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-16 23:00:21 +00:00
REST API: Short-circuit comment controller permissions check if commented-upon post type does not exist.
Props imani3011, dragosh635, subrataemfluence, timothyblynjacobs. Fixes #42238. git-svn-id: https://develop.svn.wordpress.org/trunk@47036 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1592,7 +1592,13 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
* @return bool Whether post can be read.
|
||||
*/
|
||||
protected function check_read_post_permission( $post, $request ) {
|
||||
$post_type = get_post_type_object( $post->post_type );
|
||||
$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
|
||||
|
||||
Reference in New Issue
Block a user