Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/26/2012 05:43:43 PM (11 years ago)
Author:
johnjamesjacoby
Message:

Deleting:

  • When deleting a forum or topic, make sure all child content is deleted also.
  • Also add some inline doc, and unset query variables, and clean up messy inline comparisons.
  • Props MZAWeb.
  • Fixes #2059.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/topics/functions.php

    r4522 r4524  
    29352935
    29362936    // Topic is being permanently deleted, so its replies gotta go too
    2937     if ( $replies = new WP_Query( array(
     2937    // Note that we get all post statuses here
     2938    $replies = new WP_Query( array(
    29382939        'suppress_filters' => true,
    29392940        'post_type'        => bbp_get_reply_post_type(),
    2940         'post_status'      => 'any',
     2941        'post_status'      => array_keys( get_post_stati() ),
    29412942        'post_parent'      => $topic_id,
    29422943        'posts_per_page'   => -1,
    29432944        'nopaging'         => true,
    29442945        'fields'           => 'id=>parent'
    2945     ) ) ) {
     2946    ) );
     2947
     2948    // Loop through and delete child replies
     2949    if ( ! empty( $replies->posts ) ) {
    29462950        foreach ( $replies->posts as $reply ) {
    29472951            wp_delete_post( $reply->ID, true );
     
    29512955        wp_reset_postdata();
    29522956    }
     2957
     2958    // Cleanup
     2959    unset( $replies );
    29532960}
    29542961
     
    29772984
    29782985    // Topic is being trashed, so its replies are trashed too
    2979     if ( $replies = new WP_Query( array(
     2986    $replies = new WP_Query( array(
    29802987        'suppress_filters' => true,
    29812988        'post_type'        => bbp_get_reply_post_type(),
     
    29852992        'nopaging'         => true,
    29862993        'fields'           => 'id=>parent'
    2987     ) ) ) {
     2994    ) );
     2995
     2996    if ( !empty( $replies->posts ) ) {
    29882997
    29892998        // Prevent debug notices
     
    30043013        wp_reset_postdata();
    30053014    }
     3015
     3016    // Cleanup
     3017    unset( $replies );
    30063018}
    30073019
Note: See TracChangeset for help on using the changeset viewer.