WordPress.org

Make WordPress Core

Changeset 34130


Ignore:
Timestamp:
09/14/2015 09:46:40 PM (6 years ago)
Author:
wonderboymusic
Message:

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

See #33638.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/comment.php

    r34129 r34130  
    259259    switch ( $action ) {
    260260        case 'deletecomment' :
    261             wp_delete_comment( $comment_id );
     261            wp_delete_comment( $comment );
    262262            $redir = add_query_arg( array('deleted' => '1'), $redir );
    263263            break;
    264264        case 'trashcomment' :
    265             wp_trash_comment($comment_id);
     265            wp_trash_comment( $comment );
    266266            $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
    267267            break;
    268268        case 'untrashcomment' :
    269             wp_untrash_comment($comment_id);
     269            wp_untrash_comment( $comment );
    270270            $redir = add_query_arg( array('untrashed' => '1'), $redir );
    271271            break;
    272272        case 'spamcomment' :
    273             wp_spam_comment($comment_id);
     273            wp_spam_comment( $comment );
    274274            $redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir );
    275275            break;
    276276        case 'unspamcomment' :
    277             wp_unspam_comment($comment_id);
     277            wp_unspam_comment( $comment );
    278278            $redir = add_query_arg( array('unspammed' => '1'), $redir );
    279279            break;
  • trunk/src/wp-admin/includes/ajax-actions.php

    r34129 r34130  
    527527        if ( 'trash' == $status )
    528528            wp_die( time() );
    529         $r = wp_trash_comment( $comment->comment_ID );
     529        $r = wp_trash_comment( $comment );
    530530    } elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
    531531        if ( 'trash' != $status )
    532532            wp_die( time() );
    533         $r = wp_untrash_comment( $comment->comment_ID );
     533        $r = wp_untrash_comment( $comment );
    534534        if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
    535535            $delta = 1;
     
    537537        if ( 'spam' == $status )
    538538            wp_die( time() );
    539         $r = wp_spam_comment( $comment->comment_ID );
     539        $r = wp_spam_comment( $comment );
    540540    } elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
    541541        if ( 'spam' != $status )
    542542            wp_die( time() );
    543         $r = wp_unspam_comment( $comment->comment_ID );
     543        $r = wp_unspam_comment( $comment );
    544544        if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
    545545            $delta = 1;
    546546    } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
    547         $r = wp_delete_comment( $comment->comment_ID );
     547        $r = wp_delete_comment( $comment );
    548548    } else {
    549549        wp_die( -1 );
  • trunk/src/wp-includes/comment-functions.php

    r34129 r34130  
    11651165 * @since 2.9.0
    11661166 *
    1167  * @param int $comment_id Comment ID.
     1167 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
    11681168 * @return bool True on success, false on failure.
    11691169 */
    1170 function wp_unspam_comment($comment_id) {
    1171     if ( ! (int)$comment_id )
    1172         return false;
    1173 
     1170function wp_unspam_comment( $comment_id ) {
    11741171    $comment = get_comment( $comment_id );
    11751172    if ( ! $comment ) {
     
    11841181     * @param int $comment_id The comment ID.
    11851182     */
    1186     do_action( 'unspam_comment', $comment_id );
    1187 
    1188     $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
     1183    do_action( 'unspam_comment', $comment->comment_ID );
     1184
     1185    $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
    11891186    if ( empty($status) )
    11901187        $status = '0';
    11911188
    11921189    if ( wp_set_comment_status( $comment, $status ) ) {
    1193         delete_comment_meta( $comment_id, '_wp_trash_meta_status' );
    1194         delete_comment_meta( $comment_id, '_wp_trash_meta_time' );
     1190        delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
     1191        delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
    11951192        /**
    11961193         * Fires immediately after a comment is unmarked as Spam.
     
    12001197         * @param int $comment_id The comment ID.
    12011198         */
    1202         do_action( 'unspammed_comment', $comment_id );
     1199        do_action( 'unspammed_comment', $comment->comment_ID );
    12031200        return true;
    12041201    }
Note: See TracChangeset for help on using the changeset viewer.