Skip to:
Content

bbPress.org

Ticket #2588: 2588.2.diff

File 2588.2.diff, 1.9 KB (added by netweb, 8 years ago)
  • src/includes/admin/tools.php

     
    641641        if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) {
    642642                return array( 1, sprintf( $statement, $result ) );
    643643        }
    644  
     644
    645645        // Recalculate the metas key _bbp_reply_count and _bbp_total_reply_count for each forum
    646646        $forums = get_posts( array( 'post_type' => bbp_get_forum_post_type(), 'numberposts' => -1 ) );
    647647        if ( !empty( $forums ) ) {
     
    13221322        $statement = __( 'Recalculating reply menu order … %s', 'bbpress' );
    13231323        $result    = __( 'No reply hierachy to recalculate!',          'bbpress' );
    13241324
     1325        // First, delete _bbp_reply_to to self from post meta.
     1326        if ( is_wp_error( $wpdb->query( "DELETE FROM `$wpdb->postmeta` WHERE `meta_key` = '_bbp_reply_to' AND `post_id` = `meta_value`;" ) ) )
     1327                return array( 1, sprintf( $statement, $result ) );
     1328
    13251329        // Post type
    13261330        $rpt = bbp_get_reply_post_type();
    13271331
     
    13391343
    13401344        // Bail if no replies returned
    13411345        if ( empty( $replies ) ) {
    1342                 return array( 1, sprintf( $statement, $result ) );
     1346                return array( 2, sprintf( $statement, $result ) );
    13431347        }
    13441348
    13451349        // Recalculate the menu order position for each reply
  • src/includes/replies/functions.php

     
    11191119                return;
    11201120
    11211121        // Set the reply to
    1122         if ( !empty( $reply_to ) ) {
     1122        if ( ! empty( $reply_to ) ) {
    11231123                update_post_meta( $reply_id, '_bbp_reply_to', $reply_to );
    11241124
    11251125        // Delete the reply to
     
    11271127                delete_post_meta( $reply_id, '_bbp_reply_to' );
    11281128        }
    11291129
    1130         return (int) apply_filters( 'bbp_update_reply_to', (int) $reply_to, $reply_id );
     1130        return (int) apply_filters( 'bbp_update_reply_to', (int) $reply_id, $reply_to );
    11311131}
    11321132
    11331133/**