`wp_unspam_comment()` can accept a full object instead of comment_ID to reduce cache/db lookups..

See #33638.

Built from https://develop.svn.wordpress.org/trunk@34130


git-svn-id: http://core.svn.wordpress.org/trunk@34098 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-09-14 21:47:25 +00:00
parent b1bc8a6522
commit 7639a89a1f
4 changed files with 18 additions and 21 deletions

View File

@ -258,23 +258,23 @@ case 'unapprovecomment' :
switch ( $action ) {
case 'deletecomment' :
wp_delete_comment( $comment_id );
wp_delete_comment( $comment );
$redir = add_query_arg( array('deleted' => '1'), $redir );
break;
case 'trashcomment' :
wp_trash_comment($comment_id);
wp_trash_comment( $comment );
$redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
break;
case 'untrashcomment' :
wp_untrash_comment($comment_id);
wp_untrash_comment( $comment );
$redir = add_query_arg( array('untrashed' => '1'), $redir );
break;
case 'spamcomment' :
wp_spam_comment($comment_id);
wp_spam_comment( $comment );
$redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir );
break;
case 'unspamcomment' :
wp_unspam_comment($comment_id);
wp_unspam_comment( $comment );
$redir = add_query_arg( array('unspammed' => '1'), $redir );
break;
case 'approvecomment' :

View File

@ -526,25 +526,25 @@ function wp_ajax_delete_comment() {
if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
if ( 'trash' == $status )
wp_die( time() );
$r = wp_trash_comment( $comment->comment_ID );
$r = wp_trash_comment( $comment );
} elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
if ( 'trash' != $status )
wp_die( time() );
$r = wp_untrash_comment( $comment->comment_ID );
$r = wp_untrash_comment( $comment );
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
$delta = 1;
} elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
if ( 'spam' == $status )
wp_die( time() );
$r = wp_spam_comment( $comment->comment_ID );
$r = wp_spam_comment( $comment );
} elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
if ( 'spam' != $status )
wp_die( time() );
$r = wp_unspam_comment( $comment->comment_ID );
$r = wp_unspam_comment( $comment );
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
$delta = 1;
} elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
$r = wp_delete_comment( $comment->comment_ID );
$r = wp_delete_comment( $comment );
} else {
wp_die( -1 );
}

View File

@ -1164,13 +1164,10 @@ function wp_spam_comment( $comment_id ) {
*
* @since 2.9.0
*
* @param int $comment_id Comment ID.
* @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
* @return bool True on success, false on failure.
*/
function wp_unspam_comment($comment_id) {
if ( ! (int)$comment_id )
return false;
function wp_unspam_comment( $comment_id ) {
$comment = get_comment( $comment_id );
if ( ! $comment ) {
return false;
@ -1183,15 +1180,15 @@ function wp_unspam_comment($comment_id) {
*
* @param int $comment_id The comment ID.
*/
do_action( 'unspam_comment', $comment_id );
do_action( 'unspam_comment', $comment->comment_ID );
$status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
$status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
if ( empty($status) )
$status = '0';
if ( wp_set_comment_status( $comment, $status ) ) {
delete_comment_meta( $comment_id, '_wp_trash_meta_status' );
delete_comment_meta( $comment_id, '_wp_trash_meta_time' );
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
/**
* Fires immediately after a comment is unmarked as Spam.
*
@ -1199,7 +1196,7 @@ function wp_unspam_comment($comment_id) {
*
* @param int $comment_id The comment ID.
*/
do_action( 'unspammed_comment', $comment_id );
do_action( 'unspammed_comment', $comment->comment_ID );
return true;
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34129';
$wp_version = '4.4-alpha-34130';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.