Skip to:
Content

bbPress.org


Ignore:
Timestamp:
11/09/2019 05:35:42 AM (4 years ago)
Author:
johnjamesjacoby
Message:

Counts (meta-data): full audit of forum/topic/reply, public/non-public counts.

This commit is the result of a full count audit, exposing multiple inconsistencies and voids in relation to how public and non-public counts are (re)calculated.

For instance, hidden forum replies are not counted at all, until now. By introducing a new Repair tool, hidden forum reply counts are now counted.

In addition, there were multiple bugs with topic & reply moderation, where the act of approving or unapproving topics or replies would cause the numbers to be inaccurate, or where topics & replies being caught in moderation were still increasing public counts.

It was also possible to, as a Key Master, publicly reply to unapproved topics, which was a completely unanticipated side-effect of allowing Key Masters to do pretty much anything. Going forward, the default reply status is the topic status, but is still beholden to all existing moderation settings and user role capabilities. This results in a more sane user experience, and prevents the unusual circumstance of there being "0 topics and 30 replies" in public-facing forums.

Certain count increase/decrease actions have been reprioritized to avoid collisions and race conditions, proving once again that ya gotta get up to get down.

See #2838. Fixes #1799.

File:
1 edited

Legend:

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

    r6915 r6923  
    231231
    232232// Subscriptions
    233 add_action( 'bbp_spam_topic',   'bbp_remove_topic_from_all_subscriptions'       );
    234 add_action( 'bbp_trash_topic',  'bbp_remove_topic_from_all_subscriptions'       );
    235 add_action( 'bbp_delete_topic', 'bbp_remove_topic_from_all_subscriptions'       );
    236 add_action( 'bbp_trash_forum',  'bbp_remove_forum_from_all_subscriptions'       );
    237 add_action( 'bbp_delete_forum', 'bbp_remove_forum_from_all_subscriptions'       );
    238 add_action( 'bbp_new_reply',    'bbp_notify_topic_subscribers',           11, 5 );
    239 add_action( 'bbp_new_topic',    'bbp_notify_forum_subscribers',           11, 4 );
     233add_action( 'bbp_spam_topic',   'bbp_remove_topic_from_all_subscriptions' );
     234add_action( 'bbp_trash_topic',  'bbp_remove_topic_from_all_subscriptions' );
     235add_action( 'bbp_delete_topic', 'bbp_remove_topic_from_all_subscriptions' );
     236add_action( 'bbp_trash_forum',  'bbp_remove_forum_from_all_subscriptions' );
     237add_action( 'bbp_delete_forum', 'bbp_remove_forum_from_all_subscriptions' );
     238
     239// Subscription notifications
     240add_action( 'bbp_new_reply',    'bbp_notify_topic_subscribers', 11, 5 );
     241add_action( 'bbp_new_topic',    'bbp_notify_forum_subscribers', 11, 4 );
    240242
    241243// Sticky
     
    264266add_action( 'bbp_unapproved_reply', 'bbp_update_reply_walker' );
    265267
    266 // Update forum topic/reply counts.
    267 add_action( 'bbp_new_reply',        'bbp_increase_forum_reply_count'        );
    268 add_action( 'bbp_new_topic',        'bbp_increase_forum_topic_count'        );
    269 add_action( 'bbp_trashed_reply',    'bbp_decrease_forum_reply_count'        );
    270 add_action( 'bbp_trashed_topic',    'bbp_decrease_forum_topic_count'        );
    271 add_action( 'bbp_untrashed_reply',  'bbp_increase_forum_reply_count'        );
    272 add_action( 'bbp_untrashed_topic',  'bbp_increase_forum_topic_count'        );
    273 add_action( 'bbp_spammed_reply',    'bbp_decrease_forum_reply_count'        );
    274 add_action( 'bbp_spammed_topic',    'bbp_decrease_forum_topic_count'        );
    275 add_action( 'bbp_unspammed_reply',  'bbp_increase_forum_reply_count'        );
    276 add_action( 'bbp_unspammed_topic',  'bbp_increase_forum_topic_count'        );
    277 add_action( 'bbp_approved_reply',   'bbp_increase_forum_reply_count'        );
    278 add_action( 'bbp_approved_topic',   'bbp_increase_forum_topic_count'        );
    279 add_action( 'bbp_unapproved_reply', 'bbp_decrease_forum_reply_count'        );
    280 add_action( 'bbp_unapproved_topic', 'bbp_decrease_forum_topic_count'        );
     268// Update forum reply counts
     269add_action( 'bbp_new_reply',        'bbp_increase_forum_reply_count' );
     270add_action( 'bbp_untrashed_reply',  'bbp_increase_forum_reply_count' );
     271add_action( 'bbp_unspammed_reply',  'bbp_increase_forum_reply_count' );
     272add_action( 'bbp_approved_reply',   'bbp_increase_forum_reply_count' );
     273add_action( 'bbp_trash_reply',      'bbp_decrease_forum_reply_count' );
     274add_action( 'bbp_spam_reply',       'bbp_decrease_forum_reply_count' );
     275add_action( 'bbp_unapprove_reply',  'bbp_decrease_forum_reply_count' );
     276
     277// Update forum hidden reply counts
     278add_action( 'bbp_trashed_reply',    'bbp_increase_forum_reply_count_hidden' );
     279add_action( 'bbp_spammed_reply',    'bbp_increase_forum_reply_count_hidden' );
     280add_action( 'bbp_unapproved_reply', 'bbp_increase_forum_reply_count_hidden' );
     281add_action( 'bbp_untrash_reply',    'bbp_decrease_forum_reply_count_hidden' );
     282add_action( 'bbp_unspam_reply',     'bbp_decrease_forum_reply_count_hidden' );
     283add_action( 'bbp_approve_reply',    'bbp_decrease_forum_reply_count_hidden' );
     284add_action( 'bbp_delete_reply',     'bbp_decrease_forum_reply_count_hidden' );
     285
     286// Update forum topic counts
     287add_action( 'bbp_new_topic',        'bbp_increase_forum_topic_count' );
     288add_action( 'bbp_untrashed_topic',  'bbp_increase_forum_topic_count' );
     289add_action( 'bbp_unspammed_topic',  'bbp_increase_forum_topic_count' );
     290add_action( 'bbp_approved_topic',   'bbp_increase_forum_topic_count' );
     291add_action( 'bbp_trash_topic',      'bbp_decrease_forum_topic_count' );
     292add_action( 'bbp_spam_topic',       'bbp_decrease_forum_topic_count' );
     293add_action( 'bbp_unapprove_topic',  'bbp_decrease_forum_topic_count' );
     294
     295// Update forum hidden topic counts
    281296add_action( 'bbp_trashed_topic',    'bbp_increase_forum_topic_count_hidden' );
    282 add_action( 'bbp_untrashed_topic',  'bbp_decrease_forum_topic_count_hidden' );
    283297add_action( 'bbp_spammed_topic',    'bbp_increase_forum_topic_count_hidden' );
    284 add_action( 'bbp_unspammed_topic',  'bbp_decrease_forum_topic_count_hidden' );
    285 add_action( 'bbp_approved_topic',   'bbp_decrease_forum_topic_count_hidden' );
    286298add_action( 'bbp_unapproved_topic', 'bbp_increase_forum_topic_count_hidden' );
    287 
    288 // Update forum reply counts for approved/unapproved topics.
     299add_action( 'bbp_untrash_topic',    'bbp_decrease_forum_topic_count_hidden' );
     300add_action( 'bbp_unspam_topic',     'bbp_decrease_forum_topic_count_hidden' );
     301add_action( 'bbp_approve_topic',    'bbp_decrease_forum_topic_count_hidden' );
     302add_action( 'bbp_delete_topic',     'bbp_decrease_forum_topic_count_hidden' );
     303
     304// Update topic reply counts
     305add_action( 'bbp_new_reply',        'bbp_increase_topic_reply_count' );
     306add_action( 'bbp_untrashed_reply',  'bbp_increase_topic_reply_count' );
     307add_action( 'bbp_unspammed_reply',  'bbp_increase_topic_reply_count' );
     308add_action( 'bbp_approved_reply',   'bbp_increase_topic_reply_count' );
     309add_action( 'bbp_trash_reply',      'bbp_decrease_topic_reply_count' );
     310add_action( 'bbp_spam_reply',       'bbp_decrease_topic_reply_count' );
     311add_action( 'bbp_unapprove_reply',  'bbp_decrease_topic_reply_count' );
     312
     313// Update topic hidden reply counts
     314add_action( 'bbp_trashed_reply',    'bbp_increase_topic_reply_count_hidden' );
     315add_action( 'bbp_unapproved_reply', 'bbp_increase_topic_reply_count_hidden' );
     316add_action( 'bbp_spammed_reply',    'bbp_increase_topic_reply_count_hidden' );
     317add_action( 'bbp_untrash_reply',    'bbp_decrease_topic_reply_count_hidden' );
     318add_action( 'bbp_unspam_reply',     'bbp_decrease_topic_reply_count_hidden' );
     319add_action( 'bbp_approve_reply',    'bbp_decrease_topic_reply_count_hidden' );
     320add_action( 'bbp_delete_reply',     'bbp_decrease_topic_reply_count_hidden' );
     321
     322// Update forum reply counts for approved/unapproved topics
    289323add_action( 'bbp_approved_topic',   'bbp_approved_unapproved_topic_update_forum_reply_count' );
    290324add_action( 'bbp_unapproved_topic', 'bbp_approved_unapproved_topic_update_forum_reply_count' );
    291325
    292 // Update topic reply counts.
    293 add_action( 'bbp_new_reply',        'bbp_increase_topic_reply_count'        );
    294 add_action( 'bbp_trashed_reply',    'bbp_decrease_topic_reply_count'        );
    295 add_action( 'bbp_untrashed_reply',  'bbp_increase_topic_reply_count'        );
    296 add_action( 'bbp_spammed_reply',    'bbp_decrease_topic_reply_count'        );
    297 add_action( 'bbp_unspammed_reply',  'bbp_increase_topic_reply_count'        );
    298 add_action( 'bbp_approved_reply',   'bbp_increase_topic_reply_count'        );
    299 add_action( 'bbp_unapproved_reply', 'bbp_decrease_topic_reply_count'        );
    300 add_action( 'bbp_trashed_reply',    'bbp_increase_topic_reply_count_hidden' );
    301 add_action( 'bbp_untrashed_reply',  'bbp_decrease_topic_reply_count_hidden' );
    302 add_action( 'bbp_spammed_reply',    'bbp_increase_topic_reply_count_hidden' );
    303 add_action( 'bbp_unspammed_reply',  'bbp_decrease_topic_reply_count_hidden' );
    304 add_action( 'bbp_approved_reply',   'bbp_decrease_topic_reply_count_hidden' );
    305 add_action( 'bbp_unapproved_reply', 'bbp_increase_topic_reply_count_hidden' );
    306 add_action( 'bbp_deleted_reply',    'bbp_decrease_topic_reply_count_hidden' );
    307 
    308 // Users topic & reply counts.
     326// Users topic & reply counts
    309327add_action( 'bbp_new_topic',     'bbp_increase_user_topic_count' );
    310328add_action( 'bbp_new_reply',     'bbp_increase_user_reply_count' );
     
    325343add_action( 'bbp_unspam_topic',  'bbp_unspam_topic_replies'  );
    326344
    327 // Topic engagements on user creation.
     345// Topic engagements on user creation
    328346add_action( 'bbp_new_topic', 'bbp_update_topic_engagements', 20 );
    329347add_action( 'bbp_new_reply', 'bbp_update_topic_engagements', 20 );
     
    344362add_action( 'bbp_insert_reply', 'bbp_update_topic_voice_count', 30 );
    345363
    346 // Recalculate engagements.
     364// Recalculate engagements
    347365add_action( 'bbp_trashed_reply',    'bbp_recalculate_topic_engagements' );
    348366add_action( 'bbp_untrashed_reply',  'bbp_recalculate_topic_engagements' );
     
    360378add_action( 'bbp_deleted_topic',    'bbp_recalculate_topic_engagements' );
    361379
    362 // Update engagement counts.
     380// Update engagement counts
    363381add_action( 'bbp_trashed_reply',    'bbp_update_topic_voice_count', 30 );
    364382add_action( 'bbp_untrashed_reply',  'bbp_update_topic_voice_count', 30 );
Note: See TracChangeset for help on using the changeset viewer.