Skip to:
Content

bbPress.org


Ignore:
Timestamp:
07/14/2015 12:31:42 AM (11 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/admin/converter.php

    r5770 r5827  
    630630     */
    631631    public function sync_table( $drop = false ) {
    632         global $wpdb;
    633 
    634         $table_name = $wpdb->prefix . 'bbp_converter_translator';
    635         if ( ! empty( $drop ) && $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name ) {
    636             $wpdb->query( "DROP TABLE {$table_name}" );
     632
     633        $bbp_db     = bbp_db();
     634        $table_name = $bbp_db->prefix . 'bbp_converter_translator';
     635        if ( ! empty( $drop ) && $bbp_db->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name ) {
     636            $bbp_db->query( "DROP TABLE {$table_name}" );
    637637        }
    638638
    639639        require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
    640640
    641         if ( !empty( $wpdb->charset ) ) {
    642             $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    643         }
    644 
    645         if ( !empty( $wpdb->collate ) ) {
    646             $charset_collate .= " COLLATE $wpdb->collate";
     641        if ( !empty( $bbp_db->charset ) ) {
     642            $charset_collate = "DEFAULT CHARACTER SET $bbp_db->charset";
     643        }
     644
     645        if ( !empty( $bbp_db->collate ) ) {
     646            $charset_collate .= " COLLATE $bbp_db->collate";
    647647        }
    648648
     
    676676
    677677    /**
    678      * @var object This is the connection to the WordPress datbase.
     678     * @var object This is the connection to the WordPress database.
    679679     */
    680680    protected $wpdb;
     
    740740
    741741    private function setup_globals() {
    742         global $wpdb;
    743742
    744743        /** Get database connections ******************************************/
    745744
    746         $this->wpdb         = $wpdb;
     745        $this->wpdb         = bbp_db();
    747746        $this->max_rows     = (int) $_POST['_bbp_converter_rows'];
    748747        $this->opdb         = new wpdb( $_POST['_bbp_converter_db_user'], $_POST['_bbp_converter_db_pass'], $_POST['_bbp_converter_db_name'], $_POST['_bbp_converter_db_server'] );
Note: See TracChangeset for help on using the changeset viewer.