Make WordPress Core


Ignore:
Timestamp:
02/04/2020 11:00:53 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Posts, Post Types: Revert [47179] pending test failures investigation.

See #48653.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-query.php

    r47179 r47180  
    30673067                if ( ! empty( $this->posts ) && ( $this->is_single || $this->is_page ) ) {
    30683068                        $status = get_post_status( $this->posts[0] );
    3069 
    30703069                        if ( 'attachment' === $this->posts[0]->post_type && 0 === (int) $this->posts[0]->post_parent ) {
    30713070                                $this->is_page       = false;
     
    30733072                                $this->is_attachment = true;
    30743073                        }
     3074                        $post_status_obj = get_post_status_object( $status );
    30753075
    30763076                        // If the post_status was specifically requested, let it pass through.
    3077                         if ( ! in_array( $status, $q_status ) ) {
    3078                                 $post_status_obj = get_post_status_object( $status );
    3079 
    3080                                 if ( $post_status_obj && ! $post_status_obj->public ) {
    3081                                         if ( ! is_user_logged_in() ) {
    3082                                                 // User must be logged in to view unpublished posts.
    3083                                                 $this->posts = array();
    3084                                         } else {
    3085                                                 if ( $post_status_obj->protected ) {
    3086                                                         // User must have edit permissions on the draft to preview.
    3087                                                         if ( ! current_user_can( $edit_cap, $this->posts[0]->ID ) ) {
    3088                                                                 $this->posts = array();
    3089                                                         } else {
    3090                                                                 $this->is_preview = true;
    3091                                                                 if ( 'future' != $status ) {
    3092                                                                         $this->posts[0]->post_date = current_time( 'mysql' );
    3093                                                                 }
     3077                        if ( ! $post_status_obj->public && ! in_array( $status, $q_status ) ) {
     3078
     3079                                if ( ! is_user_logged_in() ) {
     3080                                        // User must be logged in to view unpublished posts.
     3081                                        $this->posts = array();
     3082                                } else {
     3083                                        if ( $post_status_obj->protected ) {
     3084                                                // User must have edit permissions on the draft to preview.
     3085                                                if ( ! current_user_can( $edit_cap, $this->posts[0]->ID ) ) {
     3086                                                        $this->posts = array();
     3087                                                } else {
     3088                                                        $this->is_preview = true;
     3089                                                        if ( 'future' != $status ) {
     3090                                                                $this->posts[0]->post_date = current_time( 'mysql' );
    30943091                                                        }
    3095                                                 } elseif ( $post_status_obj->private ) {
    3096                                                         if ( ! current_user_can( $read_cap, $this->posts[0]->ID ) ) {
    3097                                                                 $this->posts = array();
    3098                                                         }
    3099                                                 } else {
     3092                                                }
     3093                                        } elseif ( $post_status_obj->private ) {
     3094                                                if ( ! current_user_can( $read_cap, $this->posts[0]->ID ) ) {
    31003095                                                        $this->posts = array();
    31013096                                                }
     3097                                        } else {
     3098                                                $this->posts = array();
    31023099                                        }
    3103                                 } else {
    3104                                         // Post status is not registered, assume it's not public.
    3105                                         $this->posts = array();
    31063100                                }
    31073101                        }
Note: See TracChangeset for help on using the changeset viewer.