From 61f8b8f569d624f4599261de2fffae40fc1db417 Mon Sep 17 00:00:00 2001 From: westi Date: Sat, 6 Oct 2007 08:18:33 +0000 Subject: [PATCH] Move database class loading to a shared function to ensure all of WordPress is wp-content/wp-db.php aware. Fixes #5128 props ComputerGuru. git-svn-id: http://svn.automattic.com/wordpress/trunk@6198 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/setup-config.php | 5 ++++- wp-includes/functions.php | 17 +++++++++++++++++ wp-settings.php | 6 +----- 3 files changed, 22 insertions(+), 6 deletions(-) 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;