diff --git a/wp-includes/update.php b/wp-includes/update.php index 41d1d7b292..0baa2fa2d3 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -23,7 +23,7 @@ function wp_version_check() { if ( defined('WP_INSTALLING') ) return; - global $wp_version; + global $wp_version, $wpdb; $php_version = phpversion(); $current = get_option( 'update_core' ); @@ -40,7 +40,12 @@ function wp_version_check() { $new_option->last_checked = time(); // this gets set whether we get a response or not, so if something is down or misconfigured it won't delay the page load for more than 3 seconds, twice a day $new_option->version_checked = $wp_version; - $url = "http://api.wordpress.org/core/version-check/1.2/?version=$wp_version&php=$php_version&locale=$locale"; + if ( method_exists( $wpdb, 'db_version' ) ) + $mysql_version = preg_replace('/[^0-9.].*/', '', $wpdb->db_version($wpdb->users)); + else + $mysql_version = 'N/A'; + + $url = "http://api.wordpress.org/core/version-check/1.2/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version"; $options = array('timeout' => 3); $options['headers'] = array( diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php index 7b6c6f090f..f14efb1fdf 100644 --- a/wp-includes/wp-db.php +++ b/wp-includes/wp-db.php @@ -904,8 +904,7 @@ class wpdb { { global $wp_version; // Make sure the server has MySQL 4.0 - $mysql_version = preg_replace('|[^0-9\.]|', '', @mysql_get_server_info($this->dbh)); - if ( version_compare($mysql_version, '4.0.0', '<') ) + if ( version_compare($this->db_version(), '4.0.0', '<') ) return new WP_Error('database_version',sprintf(__('ERROR: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version)); } @@ -920,7 +919,7 @@ class wpdb { */ function supports_collation() { - return ( version_compare(mysql_get_server_info($this->dbh), '4.1.0', '>=') ); + return ( version_compare($this->db_version(), '4.1.0', '>=') ); } /** @@ -968,6 +967,13 @@ class wpdb { return $caller; } + /** + * The database version number + * @return false|string false on failure, version number on success + */ + function db_version() { + return preg_replace('/[^0-9.].*/', '', mysql_get_server_info( $this->dbh )); + } } if ( ! isset($wpdb) ) {