Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/12/2017 09:23:32 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Engagements: Revert part of r6525, and adjust some actions.

  • Engagements will need to be "public only" for 2.6, and we can reconsider what private/hidden engagements look like later
  • Make sure that engagements are saved before voice counts are done
  • Use new is_public style wrapper function for topics & replies where appropriate
  • Remove a few current_filter() checks that should no longer be necessary with current action hook implementation
  • There may be more clean-up necessary here, but this is required to bring all unit-tests back to passing as they've been written, specifically things hooked to the bbp_insert_topic and bbp_insert_reply hooks

See #3068. Hat-tip netweb.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/engagements.php

    r6529 r6534  
    196196    $topic_id = bbp_get_topic_id( $topic_id );
    197197    $bbp_db   = bbp_db();
     198    $statii   = "'" . implode( "', '", bbp_get_public_topic_statuses() ) . "'";
    198199
    199200    // A cool UNION query!
     
    201202SELECT DISTINCT( post_author ) FROM (
    202203    SELECT post_author FROM {$bbp_db->posts}
    203         WHERE ( ID = %d AND post_type = %s )
     204        WHERE ( ID = %d AND post_status IN ({$statii}) AND post_type = %s )
    204205UNION
    205206    SELECT post_author FROM {$bbp_db->posts}
    206         WHERE ( post_parent = %d AND post_type = %s )
     207        WHERE ( post_parent = %d AND post_status = %s AND post_type = %s )
    207208) as u1";
    208209
    209210    // Prepare & get results
    210     $query   = $bbp_db->prepare( $sql, $topic_id, bbp_get_topic_post_type(), $topic_id, bbp_get_reply_post_type() );
     211    $query   = $bbp_db->prepare( $sql, $topic_id, bbp_get_topic_post_type(), $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type() );
    211212    $results = $bbp_db->get_col( $query );
    212213
     
    439440function bbp_update_topic_engagements( $topic_id = 0 ) {
    440441
    441     // Check post type
     442    // Is a reply
    442443    if ( bbp_is_reply( $topic_id ) ) {
     444
     445        // Bail if reply isn't published
     446        if ( ! bbp_is_reply_published( $topic_id ) ) {
     447            return;
     448        }
     449
    443450        $author_id = bbp_get_reply_author_id( $topic_id );
    444451        $topic_id  = bbp_get_reply_topic_id( $topic_id );
     452
     453    // Is a topic
    445454    } elseif ( bbp_is_topic( $topic_id ) ) {
    446455        $author_id = bbp_get_topic_author_id( $topic_id );
    447456        $topic_id  = bbp_get_topic_id( $topic_id );
     457
     458    // Is unknown
    448459    } else {
     460        return;
     461    }
     462
     463    // Bail if topic is not public
     464    if ( ! bbp_is_topic_public( $topic_id ) ) {
    449465        return;
    450466    }
Note: See TracChangeset for help on using the changeset viewer.