Skip to:
Content

bbPress.org

Changeset 6593


Ignore:
Timestamp:
06/19/2017 10:46:31 AM (8 years ago)
Author:
johnjamesjacoby
Message:

Tools: Use delete_metadata() to remove favs & subs without a foreach loop.

File:
1 edited

Legend:

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

    r6573 r6593  
    550550    }
    551551
    552     delete_metadata( 'user', false, $meta_key, false, true );
    553 
    554     // Loop through each user's favorites
    555     foreach ( $favs as $meta ) {
    556 
    557         // Get post IDs
    558         $post_ids  = explode( ',', $meta->meta_value );
    559         $total     = $total + count( $post_ids );
    560 
    561         delete_metadata_by_mid( 'user', $meta->umeta_id );
    562     }
    563 
    564     // Cleanup
    565     unset( $favs, $post_ids );
    566 
    567     // Complete results
    568     $result = sprintf( _n( 'Complete! %d favorites upgraded.', 'Complete! %d favorites upgraded.', $total, 'bbpress' ), $total );
     552    // Delete all user-meta with this key
     553    delete_metadata( 'user', false, $key, false, true );
     554    $total = count( $favs );
     555
     556    // Complete results
     557    $result = sprintf( _n( 'Complete! %d favorites deleted.', 'Complete! %d favorites deleted.', $total, 'bbpress' ), $total );
    569558
    570559    return array( 0, sprintf( $statement, $result ) );
     
    597586    }
    598587
    599     // Loop through each user's favorites
    600     foreach ( $subs as $meta ) {
    601 
    602         // Get post IDs
    603         $post_ids  = explode( ',', $meta->meta_value );
    604         $total     = $total + count( $post_ids );
    605 
    606         delete_metadata_by_mid( 'user', $meta->umeta_id );
    607     }
    608 
    609     // Cleanup
    610     unset( $subs, $post_ids );
    611 
    612     // Complete results
    613     $result = sprintf( _n( 'Complete! %d topic subscription upgraded.', 'Complete! %d topic subscriptions upgraded.', $total, 'bbpress' ), $total );
     588    // Delete all user-meta with this key
     589    delete_metadata( 'user', false, $key, false, true );
     590    $total = count( $subs );
     591
     592    // Complete results
     593    $result = sprintf( _n( 'Complete! %d topic subscription deleted.', 'Complete! %d topic subscriptions deleted.', $total, 'bbpress' ), $total );
    614594
    615595    return array( 0, sprintf( $statement, $result ) );
     
    642622    }
    643623
    644     // Loop through each user's favorites
    645     foreach ( $subs as $meta ) {
    646 
    647         // Get post IDs
    648         $post_ids  = explode( ',', $meta->meta_value );
    649         $total     = $total + count( $post_ids );
    650 
    651         delete_metadata_by_mid( 'user', $meta->umeta_id );
    652     }
    653 
    654     // Cleanup
    655     unset( $subs, $post_ids );
    656 
    657     // Complete results
    658     $result = sprintf( _n( 'Complete! %d forum subscription upgraded.', 'Complete! %d forum subscriptions upgraded.', $total, 'bbpress' ), $total );
    659 
    660     return array( 0, sprintf( $statement, $result ) );
    661 }
     624    // Delete all user-meta with this key
     625    delete_metadata( 'user', false, $key, false, true );
     626    $total = count( $subs );
     627
     628    // Complete results
     629    $result = sprintf( _n( 'Complete! %d forum subscription deleted.', 'Complete! %d forum subscriptions deleted.', $total, 'bbpress' ), $total );
     630
     631    return array( 0, sprintf( $statement, $result ) );
     632}
Note: See TracChangeset for help on using the changeset viewer.