Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/14/2015 12:31:42 AM (10 years ago)
Author:
johnjamesjacoby
Message:

Abstraction: Use bbp_db(), bbp_rewrite() & friends, introduced in r5823 & r5826.

This commit improves the stability of bbPress in the WordPress environment by reducing global variable exposure. It also comes with minimal opcode improvements in some circumstances where $GLOBALS is preferred over defining via global statements.

Some additional surrounding cleanup directly related to functions & methods being altered is also being performed here.

Fixes #2786.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/capabilities.php

    r5770 r5827  
    383383 * @since bbPress (r3405)
    384384 *
    385  * @global WPDB $wpdb
    386385 * @param int $user_id Optional. User ID to spam. Defaults to displayed user.
    387386
     
    420419
    421420    // Arm the torpedos
    422     global $wpdb;
     421    $bbp_db = bbp_db();
    423422
    424423    // Get the blog IDs of the user to mark as spam
     
    427426    // If user has no blogs, they are a guest on this site
    428427    if ( empty( $blogs ) ) {
    429         $blogs[ $wpdb->blogid ] = array();
     428        $blogs[ $bbp_db->blogid ] = array();
    430429    }
    431430
     
    441440
    442441        // Get topics and replies
    443         $posts = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_status = '%s' AND post_type IN ( {$post_types} )", $user_id, bbp_get_public_status_id() ) );
     442        $query = $bbp_db->prepare( "SELECT ID FROM {$bbp_db->posts} WHERE post_author = %d AND post_status = '%s' AND post_type IN ( {$post_types} )", $user_id, bbp_get_public_status_id() );
     443        $posts = $bbp_db->get_col( $query );
    444444
    445445        // Loop through posts and spam them
     
    475475 * @since bbPress (r3405)
    476476 *
    477  * @global WPDB $wpdb
    478477 * @param int $user_id Optional. User ID to unspam. Defaults to displayed user.
    479478 *
     
    511510
    512511    // Arm the torpedos
    513     global $wpdb;
     512    $bbp_db = bbp_db();
    514513
    515514    // Get the blog IDs of the user to mark as spam
     
    518517    // If user has no blogs, they are a guest on this site
    519518    if ( empty( $blogs ) ) {
    520         $blogs[ $wpdb->blogid ] = array();
     519        $blogs[ $bbp_db->blogid ] = array();
    521520    }
    522521
     
    532531
    533532        // Get topics and replies
    534         $posts = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_status = '%s' AND post_type IN ( {$post_types} )", $user_id, bbp_get_spam_status_id() ) );
     533        $query = $bbp_db->prepare( "SELECT ID FROM {$bbp_db->posts} WHERE post_author = %d AND post_status = '%s' AND post_type IN ( {$post_types} )", $user_id, bbp_get_spam_status_id() );
     534        $posts = $bbp_db->get_col( $query );
    535535
    536536        // Loop through posts and spam them
Note: See TracChangeset for help on using the changeset viewer.