WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/20/2010 07:13:47 PM (9 years ago)
Author:
nacin
Message:

Always include wp-db.php. Prevents a conditional include and allows db dropins to cleanly extend the wpdb class. Move require_wp_db() to load.php for consistency with bootloader helpers. fixes #14508.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/load.php

    r15558 r15638  
    306306        }
    307307    }
     308}
     309
     310/**
     311 * Load the correct database class file.
     312 *
     313 * This function is used to load the database class file either at runtime or by
     314 * wp-admin/setup-config.php. We must globalize $wpdb to ensure that it is
     315 * defined globally by the inline code in wp-db.php.
     316 *
     317 * @since 2.5.0
     318 * @global $wpdb WordPress Database Object
     319 */
     320function require_wp_db() {
     321    global $wpdb;
     322
     323    require_once( ABSPATH . WPINC . '/wp-db.php' );
     324    if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
     325        require_once( WP_CONTENT_DIR . '/db.php' );
     326
     327    if ( isset( $wpdb ) )
     328        return;
     329
     330    $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
    308331}
    309332
Note: See TracChangeset for help on using the changeset viewer.