diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php index 566fd835d..86e7ceac1 100644 --- a/wp-admin/setup-config.php +++ b/wp-admin/setup-config.php @@ -1,5 +1,8 @@ $line) { diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 1b4517ffb..b33905501 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1415,4 +1415,21 @@ function wp_ob_end_flush_all() while ( @ob_end_flush() ); } +/* + * require_wp_db() - require_once 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 + * + * @global $wpdb + */ +function require_wp_db() +{ + global $wpdb; + if ( file_exists(ABSPATH . 'wp-content/db.php') ) + require_once (ABSPATH . 'wp-content/db.php'); + else + require_once (ABSPATH . WPINC . '/wp-db.php'); +} + ?> diff --git a/wp-settings.php b/wp-settings.php index 88146d6be..215dd6374 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -121,11 +121,7 @@ if ( !defined('PLUGINDIR') ) require (ABSPATH . WPINC . '/compat.php'); require (ABSPATH . WPINC . '/functions.php'); -if ( file_exists(ABSPATH . 'wp-content/db.php') ) - require_once (ABSPATH . 'wp-content/db.php'); -else - require_once (ABSPATH . WPINC . '/wp-db.php'); - +require_wp_db(); // $table_prefix is deprecated as of 2.1 $wpdb->prefix = $table_prefix;