Skip to:
Content

bbPress.org


Ignore:
Timestamp:
08/15/2015 08:59:51 AM (6 years ago)
Author:
netweb
Message:

Tools: Include pending replies in the count when running the "Count pending, spammed, & trashed replies in each topic" repair tool

This changeset ensures that pending replies are included in the topic meta _bbp_reply_count_hidden count after running the repair tool bbp_admin_repair_topic_hidden_reply_count(), includes unit tests.

Props netweb. Fixes #2849

File:
1 edited

Legend:

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

    r5908 r5916  
    10631063 * @uses bbp_get_trash_status_id() To get the trash status id
    10641064 * @uses bbp_get_spam_status_id() To get the spam status id
     1065 * @uses bbp_get_pending_status_id() To get the pending status id
    10651066 * @return array An array of the status code and the message
    10661067 */
     
    10691070    // Define variables
    10701071    $bbp_db    = bbp_db();
    1071     $statement = __( 'Counting the number of spammed and trashed replies in each topic… %s', 'bbpress' );
     1072    $statement = __( 'Counting the number of pending, spammed, and trashed replies in each topic… %s', 'bbpress' );
    10721073    $result    = __( 'Failed!', 'bbpress' );
    10731074
     
    10811082    $tps = bbp_get_trash_status_id();
    10821083    $sps = bbp_get_spam_status_id();
    1083 
    1084     $sql = "INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$rpt}' AND `post_status` IN ( '{$tps}', '{$sps}' ) GROUP BY `post_parent`);";
     1084    $pps = bbp_get_pending_status_id();
     1085
     1086    $sql = "INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$rpt}' AND `post_status` IN ( '{$tps}', '{$sps}', '{$pps}' ) GROUP BY `post_parent`);";
    10851087    if ( is_wp_error( $bbp_db->query( $sql ) ) ) {
    10861088        return array( 2, sprintf( $statement, $result ) );
Note: See TracChangeset for help on using the changeset viewer.