Skip to:
Content

bbPress.org

Ticket #2669: 2669.diff

File 2669.diff, 3.5 KB (added by netweb, 7 years ago)
  • src/includes/admin/tools.php

     
    284284function bbp_admin_repair_list() {
    285285        $repair_list = array(
    286286                0  => array( 'bbp-sync-topic-meta',          __( 'Recalculate parent topic for each reply',           'bbpress' ), 'bbp_admin_repair_topic_meta'               ),
    287                 5  => array( 'bbp-sync-forum-meta',          __( 'Recalculate parent forum for each reply',          'bbpress' ), 'bbp_admin_repair_forum_meta'               ),
     287                5  => array( 'bbp-sync-forum-meta',          __( 'Recalculate parent forum for each topic and reply', 'bbpress' ), 'bbp_admin_repair_forum_meta'               ),
    288288                10 => array( 'bbp-sync-forum-visibility',    __( 'Recalculate private and hidden forums',             'bbpress' ), 'bbp_admin_repair_forum_visibility'         ),
    289289                15 => array( 'bbp-sync-all-topics-forums',   __( 'Recalculate last activity in each topic and forum', 'bbpress' ), 'bbp_admin_repair_freshness'                ),
    290290                20 => array( 'bbp-sync-all-topics-sticky',   __( 'Recalculate sticky relationship of each topic',     'bbpress' ), 'bbp_admin_repair_sticky'                   ),
     
    12351235}
    12361236
    12371237/**
    1238  * Recaches the forum for each post
     1238 * Recaches the parent forum meta for each topic and reply
    12391239 *
    12401240 * @since bbPress (r3876)
    12411241 *
    12421242 * @uses wpdb::query() To run our recount sql queries
    12431243 * @uses is_wp_error() To check if the executed query returned {@link WP_Error}
    1244  * @uses bbp_get_forum_post_type() To get the forum post type
    12451244 * @uses bbp_get_topic_post_type() To get the topic post type
    12461245 * @uses bbp_get_reply_post_type() To get the reply post type
    12471246 * @return array An array of the status code and the message
     
    12581257        }
    12591258
    12601259        // Post types and status
    1261         $fpt = bbp_get_forum_post_type();
    12621260        $tpt = bbp_get_topic_post_type();
    12631261        $rpt = bbp_get_reply_post_type();
    12641262
    1265         // Next, give all the topics with replies the ID their last reply.
     1263        // Next, give all the topics their parent forum id.
    12661264        if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`)
    1267                         ( SELECT `forum`.`ID`, '_bbp_forum_id', `forum`.`post_parent`
    1268                         FROM `$wpdb->posts`
    1269                                 AS `forum`
    1270                         WHERE `forum`.`post_type` = '{$fpt}'
    1271                         GROUP BY `forum`.`ID` );" ) ) ) {
    1272                 return array( 2, sprintf( $statement, $result ) );
    1273         }
    1274 
    1275         // Next, give all the topics with replies the ID their last reply.
    1276         if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`)
    12771265                        ( SELECT `topic`.`ID`, '_bbp_forum_id', `topic`.`post_parent`
    12781266                        FROM `$wpdb->posts`
    12791267                                AS `topic`
    12801268                        WHERE `topic`.`post_type` = '{$tpt}'
    12811269                        GROUP BY `topic`.`ID` );" ) ) ) {
    1282                 return array( 3, sprintf( $statement, $result ) );
     1270                return array( 2, sprintf( $statement, $result ) );
    12831271        }
    12841272
    1285         // Next, give all the topics with replies the ID their last reply.
     1273        // Next, give all the replies their parent forum id.
    12861274        if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`)
    12871275                        ( SELECT `reply`.`ID`, '_bbp_forum_id', `topic`.`post_parent`
    12881276                        FROM `$wpdb->posts`
     
    12931281                        WHERE `topic`.`post_type` = '{$tpt}'
    12941282                                AND `reply`.`post_type` = '{$rpt}'
    12951283                        GROUP BY `reply`.`ID` );" ) ) ) {
    1296                 return array( 4, sprintf( $statement, $result ) );
     1284                return array( 3, sprintf( $statement, $result ) );
    12971285        }
    12981286
    12991287        // Complete results