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. Built from https://develop.svn.wordpress.org/trunk@40306 git-svn-id: http://core.svn.wordpress.org/trunk@40213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cde6126923
commit
f78ceb362e
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.8-alpha-40305';
|
||||
$wp_version = '4.8-alpha-40306';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue