WordPress.org

Make WordPress Core

Changeset 15638


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.

Location:
trunk
Files:
4 edited

Legend:

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

    r15636 r15638  
    31023102
    31033103/**
    3104  * Load the correct database class file.
    3105  *
    3106  * This function is used to load the database class file either at runtime or by
    3107  * wp-admin/setup-config.php We must globalise $wpdb to ensure that it is
    3108  * defined globally by the inline code in wp-db.php.
    3109  *
    3110  * @since 2.5.0
    3111  * @global $wpdb WordPress Database Object
    3112  */
    3113 function require_wp_db() {
    3114     global $wpdb;
    3115     if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
    3116         require_once( WP_CONTENT_DIR . '/db.php' );
    3117     else
    3118         require_once( ABSPATH . WPINC . '/wp-db.php' );
    3119 }
    3120 
    3121 /**
    31223104 * Load custom DB error or display WordPress DB error.
    31233105 *
  • 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
  • trunk/wp-includes/wp-db.php

    r15564 r15638  
    15551555}
    15561556
    1557 if ( ! isset( $wpdb ) ) {
    1558     /**
    1559      * WordPress Database Object, if it isn't set already in wp-content/db.php
    1560      * @global object $wpdb Creates a new wpdb object based on wp-config.php Constants for the database
    1561      * @since 0.71
    1562      */
    1563     $wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
    1564 }
    15651557?>
  • trunk/wp-settings.php

    r14345 r15638  
    6868require( ABSPATH . WPINC . '/classes.php' );
    6969
    70 // Include the wpdb class, or a db.php database drop-in if present.
     70// Include the wpdb class and, if present, a db.php database drop-in.
    7171require_wp_db();
    7272
Note: See TracChangeset for help on using the changeset viewer.