mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-13 05:10:18 +00:00
REST API: Confirm the parent post object of an attachment exists in WP_REST_Posts_Controller::check_read_permission().
Avoid a PHP Error when attempting to embed the parent post of an attachment, when the parent post ID is invalid. Instead check if the parent post object exists before checking the read permission for the parent post. Props GhostToast. Fixes #39881. git-svn-id: https://develop.svn.wordpress.org/trunk@40306 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1294,7 +1294,9 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
// Can we read the parent if we're inheriting?
|
||||
if ( 'inherit' === $post->post_status && $post->post_parent > 0 ) {
|
||||
$parent = get_post( $post->post_parent );
|
||||
return $this->check_read_permission( $parent );
|
||||
if ( $parent ) {
|
||||
return $this->check_read_permission( $parent );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user