Making WordPress.org

Changeset 5950


Ignore:
Timestamp:
09/21/2017 07:25:49 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Support Forums: Clear user's topics and reviews count cache on spamming/unspamming, approving/unapproving, and archiving/unarchiving a topic.

See #2967.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-moderators.php

    r5734 r5950  
    513513                        bbp_increase_topic_reply_count_hidden( $topic_id );
    514514                    }
     515
     516                    do_action( 'wporg_bbp_archived_reply', $post->ID );
    515517                } else {
    516518                    bbp_unstick_topic( $post->ID );
     
    530532                        }
    531533                    }
     534
     535                    do_action( 'wporg_bbp_archived_topic', $post->ID );
    532536                }
    533537
     
    574578                        bbp_decrease_topic_reply_count_hidden( $topic_id );
    575579                    }
     580
     581                    do_action( 'wporg_bbp_unarchived_reply', $post->ID );
     582                } else {
     583                    do_action( 'wporg_bbp_unarchived_topic', $post->ID );
    576584                }
    577585
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-users.php

    r5866 r5950  
    3333
    3434        // Clear user's topics and reviews count cache.
    35         add_action( 'bbp_new_topic',                   array( $this, 'clear_user_topics_count_cache' ), 10, 4 );
     35        add_action( 'bbp_new_topic',                   array( $this, 'clear_user_topics_count_cache' ) );
     36        add_action( 'bbp_spammed_topic',               array( $this, 'clear_user_topics_count_cache' ) );
     37        add_action( 'bbp_unspammed_topic',             array( $this, 'clear_user_topics_count_cache' ) );
     38        add_action( 'bbp_approved_topic',              array( $this, 'clear_user_topics_count_cache' ) );
     39        add_action( 'bbp_unapproved_topic',            array( $this, 'clear_user_topics_count_cache' ) );
     40        add_action( 'wporg_bbp_archived_topic',        array( $this, 'clear_user_topics_count_cache' ) );
     41        add_action( 'wporg_bbp_unarchived_topic',      array( $this, 'clear_user_topics_count_cache' ) );
    3642    }
    3743
     
    348354     * Clear user's topics and reviews count cache.
    349355     *
    350      * @param int   $topic_id       Topic ID.
    351      * @param int   $forum_id       Forum ID.
    352      * @param array $anonymous_data Anonymous poster data.
    353      * @param int   $topic_author   Topic author ID.
    354      */
    355     public function clear_user_topics_count_cache( $topic_id, $forum_id, $anonymous_data, $topic_author ) {
    356         if ( Plugin::REVIEWS_FORUM_ID != $forum_id ) {
    357             wp_cache_delete( $topic_author, 'user-topics-count' );
     356     * @param int $topic_id Topic ID.
     357     */
     358    public function clear_user_topics_count_cache( $topic_id ) {
     359        $post = get_post( $topic_id );
     360       
     361        if ( Plugin::REVIEWS_FORUM_ID != $post->post_parent ) {
     362            wp_cache_delete( $post->post_author, 'user-topics-count' );
    358363        } else {
    359             wp_cache_delete( $topic_author, 'user-reviews-count' );
     364            wp_cache_delete( $post->post_author, 'user-reviews-count' );
    360365        }
    361366    }
Note: See TracChangeset for help on using the changeset viewer.