From 8c791aaf60f26a53cedc67b1c17dee87839c08c6 Mon Sep 17 00:00:00 2001 From: westi Date: Mon, 7 Dec 2009 18:01:02 +0000 Subject: [PATCH] Check the correct global in get_page and also ensure that the cap check for deleting pages copes for the default page we edit when adding new. Fixes #11203. git-svn-id: http://svn.automattic.com/wordpress/trunk@12332 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/capabilities.php | 8 ++++++++ wp-includes/post.php | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 110c9f2aac..4a5ccec036 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -818,6 +818,14 @@ 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 ('' != $page->post_author) { + $page_author_data = get_userdata( $page->post_author ); + } else { + //No author set yet so default to current user for cap checks + $page_author_data = $author_data; + } + if ( $user_id == $page_author_data->ID ) { // If the page is published... if ( $page->post_status == 'publish' ) { diff --git a/wp-includes/post.php b/wp-includes/post.php index 0f82c67977..626ebc45ce 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2279,8 +2279,8 @@ function get_all_page_ids() { */ function &get_page(&$page, $output = OBJECT, $filter = 'raw') { if ( empty($page) ) { - if ( isset( $GLOBALS['page'] ) && isset( $GLOBALS['page']->ID ) ) { - return get_post($GLOBALS['page'], $output, $filter); + if ( isset( $GLOBALS['post'] ) && isset( $GLOBALS['post']->ID ) ) { + return get_post($GLOBALS['post'], $output, $filter); } else { $page = null; return $page;