Skip to:
Content

bbPress.org


Ignore:
Timestamp:
09/09/2011 09:43:33 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Fix issue when topics and replies are flagged as spam/trash where they would still update last active data for ancestors. Fixes #1631.
Fix issue when trashing and deleting a topic, replies may not be properly queried and updated. Fixes #1629.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-reply-functions.php

    r3468 r3501  
    610610
    611611        // Set transient for throttle check (only on new, not edit)
    612         if ( empty( $is_edit ) )
     612        if ( empty( $is_edit ) ) {
    613613            set_transient( '_bbp_' . bbp_current_author_ip() . '_last_posted', time() );
     614        }
    614615
    615616        // Website is optional
    616         if ( !empty( $bbp_anonymous_website ) )
     617        if ( !empty( $bbp_anonymous_website ) ) {
    617618            update_post_meta( $reply_id, '_bbp_anonymous_website', $bbp_anonymous_website, false );
     619        }
    618620
    619621    } else {
    620         if ( empty( $is_edit ) && !current_user_can( 'throttle' ) )
     622        if ( empty( $is_edit ) && !current_user_can( 'throttle' ) ) {
    621623            update_user_meta( $author_id, '_bbp_last_posted', time() );
     624        }
    622625    }
    623626
     
    628631
    629632        // Subscribed and unsubscribing
    630         if ( true == $subscribed && false == $subscheck )
     633        if ( true == $subscribed && false == $subscheck ) {
    631634            bbp_remove_user_subscription( $author_id, $topic_id );
    632635
    633636        // Subscribing
    634         elseif ( false == $subscribed && true == $subscheck )
     637        } elseif ( false == $subscribed && true == $subscheck ) {
    635638            bbp_add_user_subscription( $author_id, $topic_id );
     639        }
    636640    }
    637641
     
    728732
    729733            // Last reply and active ID's
    730             bbp_update_topic_last_reply_id  ( $ancestor, $reply_id  );
    731             bbp_update_topic_last_active_id ( $ancestor, $active_id );
     734            bbp_update_topic_last_reply_id ( $ancestor, $reply_id  );
     735            bbp_update_topic_last_active_id( $ancestor, $active_id );
    732736
    733737            // Get the last active time if none was passed
    734             if ( empty( $last_active_time ) )
     738            $topic_last_active_time = $last_active_time;
     739            if ( empty( $last_active_time ) ) {
    735740                $topic_last_active_time = get_post_field( 'post_date', bbp_get_topic_last_active_id( $ancestor ) );
    736             else
    737                 $topic_last_active_time = $last_active_time;
    738 
    739             bbp_update_topic_last_active_time  ( $ancestor, $topic_last_active_time );
     741            }
     742
     743            // Only update if reply is published
     744            if ( bbp_is_reply_published( $reply_id ) ) {
     745                bbp_update_topic_last_active_time( $ancestor, $topic_last_active_time );
     746            }
    740747
    741748            // Counts
     
    754761            bbp_update_forum_last_active_id( $ancestor, $active_id );
    755762
    756             if ( empty( $last_active_time ) )
     763            // Get the last active time if none was passed
     764            $forum_last_active_time = $last_active_time;
     765            if ( empty( $last_active_time ) ) {
    757766                $forum_last_active_time = get_post_field( 'post_date', bbp_get_forum_last_active_id( $ancestor ) );
    758             else
    759                 $forum_last_active_time = $last_active_time;
    760 
    761             bbp_update_forum_last_active_time( $ancestor, $forum_last_active_time );
     767            }
     768
     769            // Only update if reply is published
     770            if ( bbp_is_reply_published( $reply_id ) ) {
     771                bbp_update_forum_last_active_time( $ancestor, $forum_last_active_time );
     772            }
    762773
    763774            // Counts
Note: See TracChangeset for help on using the changeset viewer.