Skip to:
Content

bbPress.org

Changeset 5783


Ignore:
Timestamp:
05/22/2015 11:45:43 PM (7 years ago)
Author:
netweb
Message:

Tools: Forums should not include forum meta key _bbp_forum_id, forums with this meta key were due to either:
1) Incorrectly added by the bbp_admin_repair_forum_meta() repair tool
2) Incorrectly added by an old version of one of the included bbPress importers, these were fixed in r5526

Props netweb. Fixes #2669

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/tools.php

    r5770 r5783  
    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'                ),
     
    12881288
    12891289/**
    1290  * Recaches the forum for each post
     1290 * Recaches the parent forum meta for each topic and reply
    12911291 *
    12921292 * @since bbPress (r3876)
     
    12941294 * @uses wpdb::query() To run our recount sql queries
    12951295 * @uses is_wp_error() To check if the executed query returned {@link WP_Error}
    1296  * @uses bbp_get_forum_post_type() To get the forum post type
    12971296 * @uses bbp_get_topic_post_type() To get the topic post type
    12981297 * @uses bbp_get_reply_post_type() To get the reply post type
     
    13111310
    13121311    // Post types and status
    1313     $fpt = bbp_get_forum_post_type();
    13141312    $tpt = bbp_get_topic_post_type();
    13151313    $rpt = bbp_get_reply_post_type();
    13161314
    1317     // Next, give all the topics with replies the ID their last reply.
    1318     if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`)
    1319             ( SELECT `forum`.`ID`, '_bbp_forum_id', `forum`.`post_parent`
    1320             FROM `$wpdb->posts`
    1321                 AS `forum`
    1322             WHERE `forum`.`post_type` = '{$fpt}'
    1323             GROUP BY `forum`.`ID` );" ) ) ) {
    1324         return array( 2, sprintf( $statement, $result ) );
    1325     }
    1326 
    1327     // Next, give all the topics with replies the ID their last reply.
     1315    // Next, give all the topics their parent forum id.
    13281316    if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`)
    13291317            ( SELECT `topic`.`ID`, '_bbp_forum_id', `topic`.`post_parent`
     
    13321320            WHERE `topic`.`post_type` = '{$tpt}'
    13331321            GROUP BY `topic`.`ID` );" ) ) ) {
    1334         return array( 3, sprintf( $statement, $result ) );
    1335     }
    1336 
    1337     // Next, give all the topics with replies the ID their last reply.
     1322        return array( 2, sprintf( $statement, $result ) );
     1323    }
     1324
     1325    // Next, give all the replies their parent forum id.
    13381326    if ( is_wp_error( $wpdb->query( "INSERT INTO `$wpdb->postmeta` (`post_id`, `meta_key`, `meta_value`)
    13391327            ( SELECT `reply`.`ID`, '_bbp_forum_id', `topic`.`post_parent`
     
    13461334                AND `reply`.`post_type` = '{$rpt}'
    13471335            GROUP BY `reply`.`ID` );" ) ) ) {
    1348         return array( 4, sprintf( $statement, $result ) );
     1336        return array( 3, sprintf( $statement, $result ) );
    13491337    }
    13501338
Note: See TracChangeset for help on using the changeset viewer.