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
This commit is contained in:
nacin 2010-05-21 15:15:32 +00:00
parent e85693b8a9
commit f9783ba838
1 changed files with 6 additions and 6 deletions

View File

@ -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 . "<br />";
// 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 . "<br />";
// 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';