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.
git-svn-id: http://svn.automattic.com/wordpress/trunk@15638 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bef67a04e2
commit
9e97f25249
|
@ -3100,24 +3100,6 @@ function wp_ob_end_flush_all() {
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the correct database class file.
|
|
||||||
*
|
|
||||||
* This function is used to load the database class file either at runtime or by
|
|
||||||
* wp-admin/setup-config.php We must globalise $wpdb to ensure that it is
|
|
||||||
* defined globally by the inline code in wp-db.php.
|
|
||||||
*
|
|
||||||
* @since 2.5.0
|
|
||||||
* @global $wpdb WordPress Database Object
|
|
||||||
*/
|
|
||||||
function require_wp_db() {
|
|
||||||
global $wpdb;
|
|
||||||
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
|
|
||||||
require_once( WP_CONTENT_DIR . '/db.php' );
|
|
||||||
else
|
|
||||||
require_once( ABSPATH . WPINC . '/wp-db.php' );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load custom DB error or display WordPress DB error.
|
* Load custom DB error or display WordPress DB error.
|
||||||
*
|
*
|
||||||
|
|
|
@ -307,6 +307,29 @@ function wp_set_lang_dir() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the correct database class file.
|
||||||
|
*
|
||||||
|
* This function is used to load the database class file either at runtime or by
|
||||||
|
* wp-admin/setup-config.php. We must globalize $wpdb to ensure that it is
|
||||||
|
* defined globally by the inline code in wp-db.php.
|
||||||
|
*
|
||||||
|
* @since 2.5.0
|
||||||
|
* @global $wpdb WordPress Database Object
|
||||||
|
*/
|
||||||
|
function require_wp_db() {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
require_once( ABSPATH . WPINC . '/wp-db.php' );
|
||||||
|
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) )
|
||||||
|
require_once( WP_CONTENT_DIR . '/db.php' );
|
||||||
|
|
||||||
|
if ( isset( $wpdb ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the database table prefix and the format specifiers for database table columns.
|
* Sets the database table prefix and the format specifiers for database table columns.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1554,12 +1554,4 @@ class wpdb {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! isset( $wpdb ) ) {
|
|
||||||
/**
|
|
||||||
* WordPress Database Object, if it isn't set already in wp-content/db.php
|
|
||||||
* @global object $wpdb Creates a new wpdb object based on wp-config.php Constants for the database
|
|
||||||
* @since 0.71
|
|
||||||
*/
|
|
||||||
$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -67,7 +67,7 @@ require( ABSPATH . WPINC . '/compat.php' );
|
||||||
require( ABSPATH . WPINC . '/functions.php' );
|
require( ABSPATH . WPINC . '/functions.php' );
|
||||||
require( ABSPATH . WPINC . '/classes.php' );
|
require( ABSPATH . WPINC . '/classes.php' );
|
||||||
|
|
||||||
// Include the wpdb class, or a db.php database drop-in if present.
|
// Include the wpdb class and, if present, a db.php database drop-in.
|
||||||
require_wp_db();
|
require_wp_db();
|
||||||
|
|
||||||
// Set the database table prefix and the format specifiers for database table columns.
|
// Set the database table prefix and the format specifiers for database table columns.
|
||||||
|
|
Loading…
Reference in New Issue