mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-14 22:56:19 +01: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. Merges [40306] to the 4.7 branch. Built from https://develop.svn.wordpress.org/branches/4.7@40337 git-svn-id: http://core.svn.wordpress.org/branches/4.7@40244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a56cceb25f
commit
7f659d9ea1
@ -1288,7 +1288,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.7.4-alpha-40336';
|
||||
$wp_version = '4.7.4-alpha-40337';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user