Use get_post() in lieu of direct query in wp_ajax_replyto_comment(). fixes #23940.

git-svn-id: http://core.svn.wordpress.org/trunk@23907 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-04-04 18:44:38 +00:00
parent 08d7f2c1b0
commit 3015605cae

View File

@ -724,14 +724,16 @@ function wp_ajax_replyto_comment( $action ) {
check_ajax_referer( $action, '_ajax_nonce-replyto-comment' ); check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
$comment_post_ID = (int) $_POST['comment_post_ID']; $comment_post_ID = (int) $_POST['comment_post_ID'];
$post = get_post( $comment_post_ID );
if ( ! $post )
wp_die( -1 );
if ( !current_user_can( 'edit_post', $comment_post_ID ) ) if ( !current_user_can( 'edit_post', $comment_post_ID ) )
wp_die( -1 ); wp_die( -1 );
$status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) ); if ( empty( $post->post_status ) )
if ( empty($status) )
wp_die( 1 ); wp_die( 1 );
elseif ( in_array($status, array('draft', 'pending', 'trash') ) ) elseif ( in_array($post->post_status, array('draft', 'pending', 'trash') ) )
wp_die( __('ERROR: you are replying to a comment on a draft post.') ); wp_die( __('ERROR: you are replying to a comment on a draft post.') );
$user = wp_get_current_user(); $user = wp_get_current_user();