Skip to:
Content

bbPress.org

Changeset 6189


Ignore:
Timestamp:
12/27/2016 11:57:33 PM (4 years ago)
Author:
johnjamesjacoby
Message:

Tools: Use get_results(), and don't delete usermeta.

(Maybe we should have a separate clean-up tool once it's confirmed to be OK.)

See #2959.

File:
1 edited

Legend:

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

    r6188 r6189  
    22292229    $changed   = $total = 0;
    22302230    $key       = $bbp_db->prefix . '_bbp_favorites';
    2231     $favorites = $bbp_db->get_col( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = '{$key}'" );
     2231    $favorites = $bbp_db->get_results( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = '{$key}'" );
    22322232
    22332233    // Bail if no closed topics found
     
    22372237
    22382238    // Loop through each user's favorites
    2239     foreach ( $favorites as $meta_id => $meta ) {
     2239    foreach ( $favorites as $meta ) {
    22402240
    22412241        // Get post IDs
     
    22482248
    22492249            // Skip if already exists
    2250             if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d" ), $post_id, '_bbp_favorite', $meta->user_id ) ) {
     2250            if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d", $post_id, '_bbp_favorite', $meta->user_id ) ) ) {
    22512251                continue;
    22522252            }
     
    22642264        // Delete user meta if everything was copied successfully
    22652265        if ( $changed === $to_change ) {
    2266             delete_metadata_by_mid( 'user', $meta_id );
     2266            //delete_metadata_by_mid( 'user', $meta->umeta_id );
    22672267        }
    22682268    }
     
    22922292    $changed       = $total = 0;
    22932293    $key           = $bbp_db->prefix . '_bbp_subscriptions';
    2294     $subscriptions = $bbp_db->get_col( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = '{$key}'" );
     2294    $subscriptions = $bbp_db->get_results( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = '{$key}'" );
    22952295
    22962296    // Bail if no closed topics found
     
    23002300
    23012301    // Loop through each user's favorites
    2302     foreach ( $subscriptions as $meta_id => $meta ) {
     2302    foreach ( $subscriptions as $meta ) {
    23032303
    23042304        // Get post IDs
     
    23112311
    23122312            // Skip if already exists
    2313             if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d" ), $post_id, '_bbp_subscription', $meta->user_id ) ) {
     2313            if ( $bbp_db->get_var( $bbp_db->prepare( "SELECT COUNT(*) FROM {$bbp_db->postmeta} WHERE post_id = %d AND meta_key = %s AND meta_value = %d", $post_id, '_bbp_subscription', $meta->user_id ) ) ) {
    23142314                continue;
    23152315            }
     
    23272327        // Delete user meta if everything was copied successfully
    23282328        if ( $changed === $to_change ) {
    2329             delete_metadata_by_mid( 'user', $meta_id );
     2329            //delete_metadata_by_mid( 'user', $meta->umeta_id );
    23302330        }
    23312331    }
Note: See TracChangeset for help on using the changeset viewer.