From 8fe6767f3b15e706de276e2e484e3cac16cc7ceb Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Sat, 6 Oct 2007 08:40:54 +0000 Subject: [PATCH] Move all calls to mysql_ functions to withiWPDB so that t we don't expect any mysql stuff when we are using a custo$wpdb class. Fixes #5127 props ComputerGuru. git-svn-id: https://develop.svn.wordpress.org/trunk@6199 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/schema.php | 2 +- wp-admin/includes/upgrade.php | 10 ++++------ wp-includes/wp-db.php | 23 ++++++++++++++++++++++- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index f267e43798..922540d2ac 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -3,7 +3,7 @@ $charset_collate = ''; -if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { +if ( $wpdb->supports_collation() ) { if ( ! empty($wpdb->charset) ) $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; if ( ! empty($wpdb->collate) ) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 5dded27306..6f8b8e75e6 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -1239,12 +1239,10 @@ function translate_level_to_role($level) { } function wp_check_mysql_version() { - global $wp_version; - - // Make sure the server has MySQL 4.0 - $mysql_version = preg_replace('|[^0-9\.]|', '', @mysql_get_server_info()); - if ( version_compare($mysql_version, '4.0.0', '<') ) - die(sprintf(__('ERROR: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version)); + global $wpdb; + $result = $wpdb->check_database_version(); + if ( is_wp_error( $result ) ) + die( $result->get_error_message() ); } function maybe_disable_automattic_widgets() { diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index a2b98c7c66..e5537bbead 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -403,8 +403,29 @@ class wpdb { return false; wp_die($message); } + /** + * Checks wether of not the database version is high enough to support the features WordPress uses + * @global $wp_version + */ + function check_database_version() + { + global $wp_version; + // Make sure the server has MySQL 4.0 + $mysql_version = preg_replace('|[^0-9\.]|', '', @mysql_get_server_info()); + if ( version_compare($mysql_version, '4.0.0', '<') ) + return new WP_Error('database_version',sprintf(__('ERROR: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version)); + } + + /** + * This function is called when WordPress is generating the table schema to determine wether or not the current database + * supports or needs the collation statements. + */ + function supports_collation() + { + return ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ); + } } if ( ! isset($wpdb) ) $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); -?> \ No newline at end of file +?>