Make WordPress Core


Ignore:
Timestamp:
03/20/2017 04:29:50 AM (9 years ago)
Author:
rachelbaker
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r40122 r40306  
    12951295                if ( 'inherit' === $post->post_status && $post->post_parent > 0 ) {
    12961296                        $parent = get_post( $post->post_parent );
    1297                         return $this->check_read_permission( $parent );
     1297                        if ( $parent ) {
     1298                                return $this->check_read_permission( $parent );
     1299                        }
    12981300                }
    12991301
Note: See TracChangeset for help on using the changeset viewer.