Skip to:
Content

bbPress.org

Changeset 5489


Ignore:
Timestamp:
09/10/2014 10:52:46 PM (5 years ago)
Author:
johnjamesjacoby
Message:

In bbp_merge_topic_handler() delete last and count metas, and update the reply position after call to wp_update_post(). Fixes bug where merging two topics with odd timestamps could result in orphaned or incorrect meta data and hierarchy positioning. Props netweb. Fixes #2528.

File:
1 edited

Legend:

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

    r5466 r5489  
    12211221
    12221222    // Check if the destination topic is older than the source topic
    1223     if ( strtotime( $destination_topic->post_date ) < strtotime( $source_topic->post_date ) ) {
     1223    if ( strtotime( $source_topic->post_date ) < strtotime( $destination_topic->post_date ) ) {
    12241224
    12251225        // Set destination topic post_date to 1 second before source topic
     
    13001300    // Sticky
    13011301    bbp_unstick_topic( $source_topic->ID );
     1302
     1303    // Delete source topic's last & count meta data
     1304    delete_post_meta( $source_topic->ID, '_bbp_last_reply_id'      );
     1305    delete_post_meta( $source_topic->ID, '_bbp_last_active_id'     );
     1306    delete_post_meta( $source_topic->ID, '_bbp_last_active_time'   );
     1307    delete_post_meta( $source_topic->ID, '_bbp_voice_count'        );
     1308    delete_post_meta( $source_topic->ID, '_bbp_reply_count'        );
     1309    delete_post_meta( $source_topic->ID, '_bbp_reply_count_hidden' );
    13021310
    13031311    // Get the replies of the source topic
     
    13261334                'post_type'   => bbp_get_reply_post_type(),
    13271335                'post_parent' => $destination_topic->ID,
    1328                 'menu_order'  => bbp_get_reply_position_raw( $reply->ID, $destination_topic->ID ),
    13291336                'guid'        => ''
    13301337            ) );
     
    13341341            bbp_update_reply_forum_id( $reply->ID, bbp_get_topic_forum_id( $destination_topic->ID ) );
    13351342
    1336             // Adjust reply to values
    1337             $reply_to = bbp_get_reply_to( $reply->ID );
    1338             if ( empty( $reply_to ) ) {
    1339                 bbp_update_reply_to( $reply->ID, $source_topic->ID );
    1340             }
     1343            // Update the reply position
     1344            bbp_update_reply_position( $reply->ID );
    13411345
    13421346            // Do additional actions per merged reply
Note: See TracChangeset for help on using the changeset viewer.