Skip to:
Content

bbPress.org

Changeset 7135


Ignore:
Timestamp:
08/14/2020 05:49:20 PM (17 months ago)
Author:
johnjamesjacoby
Message:

Repair Tools: rebuild forum forum IDs.

This commit adds back the _bbp_forum_id meta data for Forums that was previously deleted inside the bbp_admin_repair_forum_meta() repair function.

Props ikovalyov.

In branches/2.6, for 2.6.6.

See #3310.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/src/includes/admin/tools/repair.php

    r6934 r7135  
    426426
    427427    if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) {
    428         return array( 1, sprintf( $statement, $result ) );
     428        return array( 1, sprintf( $statement, $result ) );
    429429    }
    430430
     
    468468
    469469    if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) {
    470         return array( 1, sprintf( $statement, $result ) );
     470        return array( 1, sprintf( $statement, $result ) );
    471471    }
    472472
     
    992992    }
    993993
    994     // Loop through forums
    995     foreach ( $forums as $forum_id ) {
     994    // Loop through forums
     995    foreach ( $forums as $forum_id ) {
    996996        if ( ! bbp_is_forum_category( $forum_id ) ) {
    997997            bbp_update_forum( array( 'forum_id' => $forum_id ) );
     
    11071107
    11081108        // If we don't have a postmeta _bbp_status value
    1109         if( empty( $topic_status ) ) {
     1109        if ( empty( $topic_status ) ) {
    11101110            update_post_meta( $closed_topic, '_bbp_status', 'publish' );
    11111111            ++$changed; // Keep a count to display at the end
     
    11641164    $tpt = bbp_get_topic_post_type();
    11651165    $rpt = bbp_get_reply_post_type();
     1166    $fmt = bbp_get_forum_post_type();
    11661167
    11671168    // Next, give all the topics their parent forum id.
     
    11721173            WHERE `topic`.`post_type` = '{$tpt}'
    11731174            GROUP BY `topic`.`ID` )" ) ) ) {
     1175        return array( 2, sprintf( $statement, $result ) );
     1176    }
     1177
     1178    // Next, give all the forums their parent forum id.
     1179    if ( is_wp_error( $bbp_db->query( "INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`)
     1180            ( SELECT `forum`.`ID`, '_bbp_forum_id', `forum`.`post_parent`
     1181            FROM `$bbp_db->posts`
     1182                AS `forum`
     1183            WHERE `forum`.`post_type` = '{$fmt}'
     1184            GROUP BY `forum`.`ID` )" ) ) ) {
    11741185        return array( 2, sprintf( $statement, $result ) );
    11751186    }
Note: See TracChangeset for help on using the changeset viewer.