WordPress.org

Make WordPress Core

Ticket #11442: 11442.diff

File 11442.diff, 1.4 KB (added by nacin, 5 years ago)
  • wp-includes/functions.php

     
    35113511 
    35123512        $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS); 
    35133513 
    3514         $posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A); 
     3514        $posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT m.post_id FROM $wpdb->postmeta AS m, $wpdb->posts AS p WHERE p.ID = m.post_id AND p.post_status = 'trash' AND m.meta_key = '_wp_trash_meta_time' AND m.meta_value < '%d'", $delete_timestamp), ARRAY_A); 
    35153515 
    35163516        foreach ( (array) $posts_to_delete as $post ) { 
    35173517                wp_delete_post($post['post_id']); 
    35183518        } 
    35193519 
    3520         $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); 
     3520        $comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT m.comment_id FROM $wpdb->commentmeta AS m, $wpdb->comments AS c WHERE c.comment_ID = m.comment_id AND c.comment_approved = 'trash' AND m.meta_key = '_wp_trash_meta_time' AND m.meta_value < '%d'", $delete_timestamp), ARRAY_A); 
    35213521 
    35223522        foreach ( (array) $comments_to_delete as $comment ) { 
    35233523                wp_delete_comment($comment['comment_id']);