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/replies/functions.php

    r6526 r6529  
    964964        if ( empty( $topic_id ) ) {
    965965            $topic_id = bbp_get_reply_topic_id( $reply_id );
    966 
    967             // Make every effort to get topic id
    968             // https://bbpress.trac.wordpress.org/ticket/2529
    969             if ( empty( $topic_id ) && ( current_filter() === 'bbp_deleted_reply' ) ) {
    970                 $topic_id = get_post_field( 'post_parent', $reply_id );
    971             }
    972966        }
    973967
     
    20652059 * Called after deleting a reply
    20662060 *
     2061 * @since 2.0.0 bbPress (r2993)
     2062 *
    20672063 * @uses bbp_get_reply_id() To get the reply id
    20682064 * @uses bbp_is_reply() To check if the passed id is a reply
     
    20822078 * Called after trashing a reply
    20832079 *
     2080 * @since 2.0.0 bbPress (r2993)
     2081 *
    20842082 * @uses bbp_get_reply_id() To get the reply id
    20852083 * @uses bbp_is_reply() To check if the passed id is a reply
     
    20982096/**
    20992097 * Called after untrashing (restoring) a reply
     2098 *
     2099 * @since 2.0.0 bbPress (r2993)
    21002100 *
    21012101 * @uses bbp_get_reply_id() To get the reply id
Note: See TracChangeset for help on using the changeset viewer.