From f9783ba8381604bca2687f8a3252cca0ddf29bd1 Mon Sep 17 00:00:00 2001 From: nacin Date: Fri, 21 May 2010 15:15:32 +0000 Subject: [PATCH] Some sanity checks -- make sure we have a valid post author user object before checking if the current user is the author. git-svn-id: http://svn.automattic.com/wordpress/trunk@14782 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/capabilities.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index db7b545ff..fbd513de3 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -835,7 +835,7 @@ function map_meta_cap( $cap, $user_id ) { } // If the user is the author... - if ( $user_id == $post_author_data->ID ) { + if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) { // If the post is published... if ( 'publish' == $post->post_status ) { $caps[] = 'delete_published_posts'; @@ -871,7 +871,7 @@ function map_meta_cap( $cap, $user_id ) { $page_author_data = $author_data; } - if ( $user_id == $page_author_data->ID ) { + if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID ) { // If the page is published... if ( $page->post_status == 'publish' ) { $caps[] = 'delete_published_pages'; @@ -906,7 +906,7 @@ function map_meta_cap( $cap, $user_id ) { $post_author_data = get_userdata( $post->post_author ); //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
"; // If the user is the author... - if ( $user_id == $post_author_data->ID ) { + if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) { // If the post is published... if ( 'publish' == $post->post_status ) { $caps[] = 'edit_published_posts'; @@ -934,7 +934,7 @@ function map_meta_cap( $cap, $user_id ) { $page_author_data = get_userdata( $page->post_author ); //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "
"; // If the user is the author... - if ( $user_id == $page_author_data->ID ) { + if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID ) { // If the page is published... if ( 'publish' == $page->post_status ) { $caps[] = 'edit_published_pages'; @@ -970,7 +970,7 @@ function map_meta_cap( $cap, $user_id ) { $author_data = get_userdata( $user_id ); $post_author_data = get_userdata( $post->post_author ); - if ( $user_id == $post_author_data->ID ) + if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID ) $caps[] = 'read'; else $caps[] = 'read_private_posts'; @@ -985,7 +985,7 @@ function map_meta_cap( $cap, $user_id ) { $author_data = get_userdata( $user_id ); $page_author_data = get_userdata( $page->post_author ); - if ( $user_id == $page_author_data->ID ) + if ( is_object( $page_author_data ) && $user_id == $page_author_data->ID ) $caps[] = 'read'; else $caps[] = 'read_private_pages';