mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 17:48:01 +01:00
Move the storage of the metadata for trashed comments into the comment meta table rather than storing it in an option. See #4529.
git-svn-id: http://svn.automattic.com/wordpress/trunk@11945 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
607ec769f0
commit
ef11608c43
@ -2193,14 +2193,11 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true,
|
|||||||
if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
|
if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
|
||||||
$action .= ' hide-if-no-js';
|
$action .= ' hide-if-no-js';
|
||||||
elseif ($action == 'untrash' && $the_comment_status == 'trash') {
|
elseif ($action == 'untrash' && $the_comment_status == 'trash') {
|
||||||
$trash_meta = get_option('wp_trash_meta');
|
if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true))
|
||||||
if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id]['status'])) {
|
|
||||||
if ($trash_meta['comments'][$comment_id]['status'] == '1')
|
|
||||||
$action .= ' approve';
|
$action .= ' approve';
|
||||||
else
|
else
|
||||||
$action .= ' unapprove';
|
$action .= ' unapprove';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
echo "<span class='$action'>$sep$link</span>";
|
echo "<span class='$action'>$sep$link</span>";
|
||||||
}
|
}
|
||||||
|
@ -819,11 +819,8 @@ function wp_delete_comment($comment_id) {
|
|||||||
|
|
||||||
do_action('delete_comment', $comment_id);
|
do_action('delete_comment', $comment_id);
|
||||||
|
|
||||||
$trash_meta = get_option('wp_trash_meta');
|
delete_comment_meta($comment_id,'_wp_trash_meta_status');
|
||||||
if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) {
|
delete_comment_meta($comment_id,'_wp_trash_meta_time');
|
||||||
unset($trash_meta['comments'][$comment_id]);
|
|
||||||
update_option('wp_trash_meta', $trash_meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
|
if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
|
||||||
return false;
|
return false;
|
||||||
@ -865,10 +862,8 @@ function wp_trash_comment($comment_id = 0) {
|
|||||||
|
|
||||||
do_action('trash_comment', $comment_id);
|
do_action('trash_comment', $comment_id);
|
||||||
|
|
||||||
$trash_meta = get_option('wp_trash_meta', array());
|
add_comment_meta($comment_id,'_wp_trash_meta_status', $comment->comment_approved);
|
||||||
$trash_meta['comments'][$comment_id]['status'] = $comment->comment_approved;
|
add_comment_meta($comment_id,'_wp_trash_meta_time', time() );
|
||||||
$trash_meta['comments'][$comment_id]['time'] = time();
|
|
||||||
update_option('wp_trash_meta', $trash_meta);
|
|
||||||
|
|
||||||
wp_set_comment_status($comment_id, 'trash');
|
wp_set_comment_status($comment_id, 'trash');
|
||||||
|
|
||||||
@ -892,12 +887,8 @@ function wp_untrash_comment($comment_id = 0) {
|
|||||||
|
|
||||||
$comment = array('comment_ID'=>$comment_id, 'comment_approved'=>'0');
|
$comment = array('comment_ID'=>$comment_id, 'comment_approved'=>'0');
|
||||||
|
|
||||||
$trash_meta = get_option('wp_trash_meta');
|
//Either set comment_approved to the value in comment_meta or worse case to false which will mean moderation
|
||||||
if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) {
|
$comment['comment_approved'] = get_comment_meta($comment_id, '_wp_trash_meta_status', true);
|
||||||
$comment['comment_approved'] = $trash_meta['comments'][$comment_id]['status'];
|
|
||||||
unset($trash_meta['comments'][$comment_id]);
|
|
||||||
update_option('wp_trash_meta', $trash_meta);
|
|
||||||
}
|
|
||||||
|
|
||||||
wp_update_comment($comment);
|
wp_update_comment($comment);
|
||||||
|
|
||||||
|
@ -3380,19 +3380,10 @@ function wp_scheduled_delete() {
|
|||||||
wp_delete_post($post['post_id']);
|
wp_delete_post($post['post_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Trashed Comments
|
$comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);
|
||||||
//TODO Come up with a better store for the comment trash meta.
|
|
||||||
$trash_meta = get_option('wp_trash_meta');
|
|
||||||
if ( !is_array($trash_meta) )
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach ( (array) $trash_meta['comments'] as $id => $meta ) {
|
foreach ( (array) $comments_to_delete as $comment ) {
|
||||||
if ( $meta['time'] < $delete_timestamp ) {
|
wp_delete_comment($comment['comment_id']);
|
||||||
wp_delete_comment($id);
|
|
||||||
unset($trash_meta['comments'][$id]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update_option('wp_trash_meta', $trash_meta);
|
|
||||||
}
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user