Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/30/2016 10:28:36 AM (8 years ago)
Author:
netweb
Message:

General Performance: Introduce increase/decrease helper count functions

Previously when a new topic or reply was created, a bunch of queries to recalculate the topic and reply counts for topics and forums were ran. Now these have been replaced with more efficient increase/decrease helper functions to get the current value and just "bump" the count based on the action (new topic-reply/split-topic/move-topic/spam-trash-topic/etc...)

Props thebrandonallen, tharsheblows, netweb
See #1799

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/actions.php

    r6034 r6036  
    256256add_action( 'bbp_unapproved_reply', 'bbp_update_reply_walker' );
    257257
    258 // Users topic & reply counts
     258// Update forum topic/reply counts.
     259add_action( 'bbp_new_reply',        'bbp_increase_forum_reply_count'        );
     260add_action( 'bbp_new_topic',        'bbp_increase_forum_topic_count'        );
     261add_action( 'bbp_trashed_reply',    'bbp_decrease_forum_reply_count'        );
     262add_action( 'bbp_trashed_topic',    'bbp_decrease_forum_topic_count'        );
     263add_action( 'bbp_trashed_topic',    'bbp_increase_forum_topic_count_hidden' );
     264add_action( 'bbp_untrashed_reply',  'bbp_increase_forum_reply_count'        );
     265add_action( 'bbp_untrashed_topic',  'bbp_increase_forum_topic_count'        );
     266add_action( 'bbp_untrashed_topic',  'bbp_decrease_forum_topic_count_hidden' );
     267add_action( 'bbp_spammed_reply',    'bbp_decrease_forum_reply_count'        );
     268add_action( 'bbp_spammed_topic',    'bbp_decrease_forum_topic_count'        );
     269add_action( 'bbp_spammed_topic',    'bbp_increase_forum_topic_count_hidden' );
     270add_action( 'bbp_unspammed_reply',  'bbp_increase_forum_reply_count'        );
     271add_action( 'bbp_unspammed_topic',  'bbp_increase_forum_topic_count'        );
     272add_action( 'bbp_unspammed_topic',  'bbp_decrease_forum_topic_count_hidden' );
     273add_action( 'bbp_approved_reply',   'bbp_increase_forum_reply_count'        );
     274add_action( 'bbp_approved_topic',   'bbp_increase_forum_topic_count'        );
     275add_action( 'bbp_approved_topic',   'bbp_decrease_forum_topic_count_hidden' );
     276add_action( 'bbp_unapproved_reply', 'bbp_decrease_forum_reply_count'        );
     277add_action( 'bbp_unapproved_topic', 'bbp_decrease_forum_topic_count'        );
     278add_action( 'bbp_unapproved_topic', 'bbp_increase_forum_topic_count_hidden' );
     279
     280// Update forum reply counts for approved/unapproved topics.
     281add_action( 'bbp_approved_topic',   'bbp_approved_unapproved_topic_update_forum_reply_count' );
     282add_action( 'bbp_unapproved_topic', 'bbp_approved_unapproved_topic_update_forum_reply_count' );
     283
     284// Update topic reply counts.
     285add_action( 'bbp_new_reply',        'bbp_increase_topic_reply_count'        );
     286add_action( 'bbp_trashed_reply',    'bbp_decrease_topic_reply_count'        );
     287add_action( 'bbp_trashed_reply',    'bbp_increase_topic_reply_count_hidden' );
     288add_action( 'bbp_untrashed_reply',  'bbp_increase_topic_reply_count'        );
     289add_action( 'bbp_untrashed_reply',  'bbp_decrease_topic_reply_count_hidden' );
     290add_action( 'bbp_spammed_reply',    'bbp_decrease_topic_reply_count'        );
     291add_action( 'bbp_spammed_reply',    'bbp_increase_topic_reply_count_hidden' );
     292add_action( 'bbp_unspammed_reply',  'bbp_increase_topic_reply_count'        );
     293add_action( 'bbp_unspammed_reply',  'bbp_decrease_topic_reply_count_hidden' );
     294add_action( 'bbp_approved_reply',   'bbp_increase_topic_reply_count'        );
     295add_action( 'bbp_approved_reply',   'bbp_decrease_topic_reply_count_hidden' );
     296add_action( 'bbp_unapproved_reply', 'bbp_decrease_topic_reply_count'        );
     297add_action( 'bbp_unapproved_reply', 'bbp_increase_topic_reply_count_hidden' );
     298
     299// Users topic & reply counts.
    259300add_action( 'bbp_new_topic',     'bbp_increase_user_topic_count' );
    260301add_action( 'bbp_new_reply',     'bbp_increase_user_reply_count' );
     
    267308add_action( 'bbp_spam_topic',    'bbp_decrease_user_topic_count' );
    268309add_action( 'bbp_spam_reply',    'bbp_decrease_user_reply_count' );
     310
     311// Insert topic/reply counts.
     312add_action( 'bbp_insert_topic', 'bbp_insert_topic_update_counts', 10, 2 );
     313add_action( 'bbp_insert_reply', 'bbp_insert_reply_update_counts', 10, 3 );
    269314
    270315// Topic status transition helpers for replies
Note: See TracChangeset for help on using the changeset viewer.