From cd7e3f097d1f71cd20abfa60f50365bd4e00b7dc Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 31 Jul 2012 17:39:14 +0000 Subject: [PATCH] Don't call get_userdata() every time for the current user in map_meta_cap()'s read_post, edit_post, and delete_post branches. see #21120. git-svn-id: https://develop.svn.wordpress.org/trunk@21375 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/capabilities.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 27905a6a95..6768ef4f2c 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -960,7 +960,6 @@ function map_meta_cap( $cap, $user_id ) { break; case 'delete_post': case 'delete_page': - $author_data = get_userdata( $user_id ); $post = get_post( $args[0] ); if ( 'revision' == $post->post_type ) { @@ -981,7 +980,7 @@ function map_meta_cap( $cap, $user_id ) { $post_author_data = get_userdata( $post->post_author ); } else { // No author set yet, so default to current user for cap checks. - $post_author_data = $author_data; + $post_author_data = get_userdata( $user_id ); } // If the user is the author... @@ -1010,7 +1009,6 @@ function map_meta_cap( $cap, $user_id ) { // edit_others_posts case 'edit_post': case 'edit_page': - $author_data = get_userdata( $user_id ); $post = get_post( $args[0] ); if ( 'revision' == $post->post_type ) { @@ -1031,7 +1029,7 @@ function map_meta_cap( $cap, $user_id ) { $post_author_data = get_userdata( $post->post_author ); } else { // No author set yet, so default to current user for cap checks. - $post_author_data = $author_data; + $post_author_data = get_userdata( $user_id ); } //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "
"; @@ -1059,7 +1057,6 @@ function map_meta_cap( $cap, $user_id ) { break; case 'read_post': case 'read_page': - $author_data = get_userdata( $user_id ); $post = get_post( $args[0] ); if ( 'revision' == $post->post_type ) { @@ -1086,7 +1083,7 @@ function map_meta_cap( $cap, $user_id ) { $post_author_data = get_userdata( $post->post_author ); } else { // No author set yet, so default to current user for cap checks. - $post_author_data = $author_data; + $post_author_data = get_userdata( $user_id ); } if ( is_object( $post_author_data ) && $user_id == $post_author_data->ID )