Skip to:
Content

bbPress.org

Changeset 7263


Ignore:
Timestamp:
06/28/2024 06:52:31 PM (22 months ago)
Author:
johnjamesjacoby
Message:

Tools/Repair: audit post statuses in repair queries.

This change ensures that all of the relevant repair tools are including the expected public post statuses for their related post types.

These changes specifically address possibly missing Closed Topics in the repair tools, while also ensuring that anything filtering the results of the _public_statuses() functions to add their own custom statuses (I.E. archives on WordPress.org) are taken into consideration.

Fixes #3591.

Props GDragoN.

In branches/2.6, for 2.6.10.

File:
1 edited

Legend:

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

    r7135 r7263  
    498498    $result      = esc_html__( 'Failed!', 'bbpress' );
    499499
    500     $sql_select  = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author`";
     500    $sql_type    = bbp_get_topic_post_type();
     501    $sql_status  = "'" . implode( "','", bbp_get_public_topic_statuses() ) . "'";
     502    $sql_select  = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status}) GROUP BY `post_author`";
    501503    $insert_rows = $bbp_db->get_results( $sql_select );
    502504
     
    542544
    543545    // Define variables
    544     $bbp_db    = bbp_db();
     546    $bbp_db      = bbp_db();
    545547    $statement   = esc_html__( 'Counting the number of topics to which each user has replied… %s', 'bbpress' );
    546548    $result      = esc_html__( 'Failed!', 'bbpress' );
    547549
    548     $sql_select  = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author`";
     550    $sql_type    = bbp_get_reply_post_type();
     551    $sql_status  = "'" . implode( "','", bbp_get_public_reply_statuses() ) . "'";
     552    $sql_select  = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status}) GROUP BY `post_author`";
    549553    $insert_rows = $bbp_db->get_results( $sql_select );
    550554
     
    602606    }
    603607
    604     $topics = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "'" );
    605 
     608    $sql_type   = bbp_get_topic_post_type();
     609    $sql_status = "'" . implode( "','", bbp_get_public_topic_statuses() ) . "'";
     610    $sql_select = "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status})";
     611
     612    $topics = $bbp_db->get_col( $sql_select );
    606613    if ( is_wp_error( $topics ) ) {
    607614        return array( 2, sprintf( $statement, $result ) );
     
    668675    }
    669676
    670     $topics = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "'" );
     677    $sql_type    = bbp_get_topic_post_type();
     678    $sql_status  = "'" . implode( "','", bbp_get_public_topic_statuses() ) . "'";
     679    $sql_select  = "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status})";
     680
     681    $topics = $bbp_db->get_col( $sql_select );
    671682    if ( is_wp_error( $topics ) ) {
    672683        return array( 2, sprintf( $statement, $result ) );
     
    733744    }
    734745
    735     $forums = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_forum_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "'" );
     746    $sql_type    = bbp_get_forum_post_type();
     747    $sql_status  = "'" . implode( "','", bbp_get_public_forum_statuses() ) . "'";
     748    $sql_select  = "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$sql_type}' AND `post_status` IN ({$sql_status})";
     749
     750    $forums = $bbp_db->get_col( $sql_select );
    736751    if ( is_wp_error( $forums ) ) {
    737752        return array( 2, sprintf( $statement, $result ) );
Note: See TracChangeset for help on using the changeset viewer.