Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/12/2017 05:29:02 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Hierarchy: Use post_parent when not empty, and fallback to meta-data.

This fixes a few weird inconsistencies with how deleting content works, because delete_ hooks fire after meta & terms have already been deleted from the database, deleted_ hooks fire after the post itself is deleted from the database, but the post object cache has not yet been cleaned (even though term & meta caches have.)

We also call a few functions like bbp_is_reply() on the deleted $postid, and even though the state of the object-cache should not be relied on, it has not been purged yet.

Relatedly, updates to forum & topic descriptions can more reliably identify their state, so this commit adjusts some logic there also.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/topics/template.php

    r6438 r6528  
    18811881    function bbp_get_topic_forum_id( $topic_id = 0 ) {
    18821882        $topic_id = bbp_get_topic_id( $topic_id );
    1883         $forum_id = get_post_meta( $topic_id, '_bbp_forum_id', true );
     1883        $forum_id = get_post_field( 'post_parent', $topic_id );
     1884
     1885        // Meta-data fallback
     1886        if ( empty( $forum_id ) ) {
     1887            $forum_id = get_post_meta( $topic_id, '_bbp_forum_id', true );
     1888        }
     1889
     1890        // Filter
     1891        if ( ! empty( $forum_id ) ) {
     1892            $forum_id = bbp_get_forum_id( $forum_id );
     1893        }
    18841894
    18851895        // Filter & return
     
    36763686        $voice_count = sprintf( _n( '%s voice', '%s voices', $vc_int, 'bbpress' ), $voice_count );
    36773687
    3678         // Topic has replies
    3679         $last_reply = bbp_get_topic_last_reply_id( $topic_id );
    3680         if ( ! empty( $last_reply ) ) {
    3681             $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_reply, 'size' => $r['size'] ) );
    3682             $retstr          = sprintf( esc_html__( 'This topic contains %1$s, has %2$s, and was last updated by %3$s %4$s.', 'bbpress' ), $reply_count, $voice_count, $last_updated_by, $time_since );
     3688        // Topic has activity (could be from reply or topic author)
     3689        $last_active = bbp_get_topic_last_active_id( $topic_id );
     3690        if ( ! empty( $last_active ) ) {
     3691            $last_updated_by = bbp_get_author_link( array( 'post_id' => $last_active, 'size' => $r['size'] ) );
     3692            $retstr          = sprintf( esc_html__( 'This topic has %1$s, %2$s, and was last updated %3$s by %4$s.', 'bbpress' ), $reply_count, $voice_count, $time_since, $last_updated_by );
    36833693
    36843694        // Topic has no replies
    36853695        } elseif ( ! empty( $voice_count ) && ! empty( $reply_count ) ) {
    3686             $retstr = sprintf( esc_html__( 'This topic contains %1$s and has %2$s.', 'bbpress' ), $voice_count, $reply_count );
     3696            $retstr = sprintf( esc_html__( 'This topic has %1$s and %2$s.', 'bbpress' ), $voice_count, $reply_count );
    36873697
    36883698        // Topic has no replies and no voices
     
    41124122
    41134123/**
    4114  * Allow topic rows to have adminstrative actions
     4124 * Allow topic rows to have administrative actions
    41154125 *
    41164126 * @since 2.1.0 bbPress (r3653)
Note: See TracChangeset for help on using the changeset viewer.