WordPress.org

Make WordPress Core

Changeset 14782


Ignore:
Timestamp:
05/21/2010 03:15:32 PM (8 years ago)
Author:
nacin
Message:

Some sanity checks -- make sure we have a valid post author user object before checking if the current user is the author.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/capabilities.php

    r14585 r14782  
    836836
    837837        // If the user is the author...
    838         if ( $user_id == $post_author_data->ID ) {
     838        if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) {
    839839            // If the post is published...
    840840            if ( 'publish' == $post->post_status ) {
     
    872872        }
    873873
    874         if ( $user_id == $page_author_data->ID ) {
     874        if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID ) {
    875875            // If the page is published...
    876876            if ( $page->post_status == 'publish' ) {
     
    907907        //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br />";
    908908        // If the user is the author...
    909         if ( $user_id == $post_author_data->ID ) {
     909        if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) {
    910910            // If the post is published...
    911911            if ( 'publish' == $post->post_status ) {
     
    935935        //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "<br />";
    936936        // If the user is the author...
    937         if ( $user_id == $page_author_data->ID ) {
     937        if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID ) {
    938938            // If the page is published...
    939939            if ( 'publish' == $page->post_status ) {
     
    971971        $author_data = get_userdata( $user_id );
    972972        $post_author_data = get_userdata( $post->post_author );
    973         if ( $user_id == $post_author_data->ID )
     973        if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID )
    974974            $caps[] = 'read';
    975975        else
     
    986986        $author_data = get_userdata( $user_id );
    987987        $page_author_data = get_userdata( $page->post_author );
    988         if ( $user_id == $page_author_data->ID )
     988        if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID )
    989989            $caps[] = 'read';
    990990        else
Note: See TracChangeset for help on using the changeset viewer.