diff --git a/wp-admin/post.php b/wp-admin/post.php
index 6c9984c4d..431b01b56 100644
--- a/wp-admin/post.php
+++ b/wp-admin/post.php
@@ -207,7 +207,7 @@ case 'edit':
if ( !user_can_edit_post($user_ID, $post_ID) )
die ( __('You are not allowed to edit this post.') );
- $postdata = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$post_ID'");
+ $postdata = &get_post($post_ID);
$content = $postdata->post_content;
$content = format_to_edit($content);
$content = apply_filters('content_edit_pre', $content);
@@ -237,7 +237,7 @@ case 'edit':
include('edit-form-advanced.php');
}
- $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$post_ID'");
+ $post = &$postdata;
?>
@@ -527,7 +527,7 @@ case 'deletecomment':
$noredir = false;
}
- $postdata = get_postdata($p) or die(sprintf(__('Oops, no post with this ID.
Go back!'), 'edit.php'));
+ $postdata = get_post($p) or die(sprintf(__('Oops, no post with this ID.
Go back!'), 'edit.php'));
$commentdata = get_commentdata($comment, 1, true) or die(sprintf(__('Oops, no comment with this ID.
Go back!'), 'post.php'));
if (!user_can_delete_post_comments($user_ID, $commentdata['comment_post_ID'])) {
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index 17eddf3f0..51c2fa204 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -461,30 +461,27 @@ meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'");
return true;
}
+// Deprecated. Use get_post().
function get_postdata($postid) {
- global $post, $wpdb;
-
- if ( $postid == $post->ID )
- $a_post = $post;
- else
- $a_post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$postid'");
+ $post = &get_post($postid);
$postdata = array (
- 'ID' => $a_post->ID,
- 'Author_ID' => $a_post->post_author,
- 'Date' => $a_post->post_date,
- 'Content' => $a_post->post_content,
- 'Excerpt' => $a_post->post_excerpt,
- 'Title' => $a_post->post_title,
- 'Category' => $a_post->post_category,
- 'post_status' => $a_post->post_status,
- 'comment_status' => $a_post->comment_status,
- 'ping_status' => $a_post->ping_status,
- 'post_password' => $a_post->post_password,
- 'to_ping' => $a_post->to_ping,
- 'pinged' => $a_post->pinged,
- 'post_name' => $a_post->post_name
+ 'ID' => $post->ID,
+ 'Author_ID' => $post->post_author,
+ 'Date' => $post->post_date,
+ 'Content' => $post->post_content,
+ 'Excerpt' => $post->post_excerpt,
+ 'Title' => $post->post_title,
+ 'Category' => $post->post_category,
+ 'post_status' => $post->post_status,
+ 'comment_status' => $post->comment_status,
+ 'ping_status' => $post->ping_status,
+ 'post_password' => $post->post_password,
+ 'to_ping' => $post->to_ping,
+ 'pinged' => $post->pinged,
+ 'post_name' => $post->post_name
);
+
return $postdata;
}