Make WordPress Core


Ignore:
Timestamp:
08/25/2009 10:05:15 PM (15 years ago)
Author:
westi
Message:

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

File:
1 edited

Legend:

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

    r11750 r11878  
    33473347 */
    33483348function wp_scheduled_delete() {
     3349    global $wpdb;
     3350
     3351    $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
     3352   
     3353    $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);
     3354   
     3355    foreach ( (array) $posts_to_delete as $post ) {
     3356        wp_delete_post($post['post_id']);
     3357    }
     3358
     3359    //Trashed Comments
     3360    //TODO Come up with a better store for the comment trash meta.
    33493361    $trash_meta = get_option('wp_trash_meta');
    33503362    if ( !is_array($trash_meta) )
    33513363        return;
    3352 
    3353     $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
    33543364
    33553365    foreach ( (array) $trash_meta['comments'] as $id => $meta ) {
     
    33593369        }
    33603370    }
    3361     foreach ( (array) $trash_meta['posts'] as $id => $meta ) {
    3362         if ( $meta['time'] < $delete_timestamp ) {
    3363             wp_delete_post($id);
    3364             unset($trash_meta['posts'][$id]);
    3365         }
    3366     }
    33673371
    33683372    update_option('wp_trash_meta', $trash_meta);
    33693373}
     3374?>
Note: See TracChangeset for help on using the changeset viewer.