Make WordPress Core


Ignore:
Timestamp:
03/27/2017 09:23:05 AM (10 years ago)
Author:
swissspidy
Message:

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.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r40325 r40337  
    12891289                if ( 'inherit' === $post->post_status && $post->post_parent > 0 ) {
    12901290                        $parent = get_post( $post->post_parent );
    1291                         return $this->check_read_permission( $parent );
     1291                        if ( $parent ) {
     1292                                return $this->check_read_permission( $parent );
     1293                        }
    12921294                }
    12931295
Note: See TracChangeset for help on using the changeset viewer.