Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/12/2017 05:41:49 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Engagements: Keep topic engagement counts up-to-date.

This changes the way the old 'voice count' works with the new engagements API in the following ways:

  • Introduce new function to update voice count meta when necessary
  • Modify recalculation function with a $force parameter, and only recalculate the counts when the engagements have changed by default
  • Hook the above functions in where appropriate, largely when deleting replies (this is a unique case where a fully deleted reply needs to check if the author of the current reply has a previously public reply in that same topic already, which should not trigger a recalculation.)
  • We are silently moving the bbp_delete_ actions onto the before_delete_post hook, so that all term & meta-data is available to them (which helps with race conditions mentioned in r6528)

Engagements are now hooked in and listening in the most efficient way possible, at least until a common & shared walker is introduced for the entire tree.

See: #3068.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/forums/functions.php

    r6499 r6529  
    19901990
    19911991    // Only update topic count if we're deleting a topic, or in the dashboard.
    1992     if ( in_array( current_filter(), array( 'bbp_deleted_topic', 'save_post' ), true ) ) {
     1992    if ( in_array( current_filter(), array( 'bbp_delete_topic', 'save_post' ), true ) ) {
    19931993        bbp_update_forum_reply_count(        $r['forum_id'] );
    19941994        bbp_update_forum_topic_count(        $r['forum_id'] );
     
    27712771 * Called after deleting a forum
    27722772 *
     2773 * Try not to use this action. All meta & taxonomy terms have already been
     2774 * deleted, making them impossible to use.
     2775 *
    27732776 * @since 2.1.0 bbPress (r3668)
     2777 * @since 2.6.0 bbPress (r6526) Not recommend for usage
    27742778 *
    27752779 * @uses bbp_get_forum_id() To get the forum id
Note: See TracChangeset for help on using the changeset viewer.