Make WordPress Core


Ignore:
Timestamp:
09/17/2009 08:51:12 PM (15 years ago)
Author:
westi
Message:

Move the storage of the metadata for trashed comments into the comment meta table rather than storing it in an option. See #4529.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r11943 r11945  
    820820    do_action('delete_comment', $comment_id);
    821821
    822     $trash_meta = get_option('wp_trash_meta');
    823     if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) {
    824         unset($trash_meta['comments'][$comment_id]);
    825         update_option('wp_trash_meta', $trash_meta);
    826     }
     822    delete_comment_meta($comment_id,'_wp_trash_meta_status');
     823    delete_comment_meta($comment_id,'_wp_trash_meta_time');
    827824
    828825    if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
     
    866863    do_action('trash_comment', $comment_id);
    867864
    868     $trash_meta = get_option('wp_trash_meta', array());
    869     $trash_meta['comments'][$comment_id]['status'] = $comment->comment_approved;
    870     $trash_meta['comments'][$comment_id]['time'] = time();
    871     update_option('wp_trash_meta', $trash_meta);
    872 
     865    add_comment_meta($comment_id,'_wp_trash_meta_status', $comment->comment_approved);
     866    add_comment_meta($comment_id,'_wp_trash_meta_time', time() );   
     867   
    873868    wp_set_comment_status($comment_id, 'trash');
    874869
     
    892887
    893888    $comment = array('comment_ID'=>$comment_id, 'comment_approved'=>'0');
    894 
    895     $trash_meta = get_option('wp_trash_meta');
    896     if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) {
    897         $comment['comment_approved'] = $trash_meta['comments'][$comment_id]['status'];
    898         unset($trash_meta['comments'][$comment_id]);
    899         update_option('wp_trash_meta', $trash_meta);
    900     }
     889   
     890    //Either set comment_approved to the value in comment_meta or worse case to false which will mean moderation
     891    $comment['comment_approved'] = get_comment_meta($comment_id, '_wp_trash_meta_status', true);
    901892
    902893    wp_update_comment($comment);
Note: See TracChangeset for help on using the changeset viewer.