From 810bf31f83b9dfbab1bcf53cedd4bcfd72097222 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 23 Dec 2009 18:35:12 +0000 Subject: [PATCH] Check required php and mysql versions in the update response and notify if the server environment does not meet those requirements. fixes #11562 git-svn-id: http://svn.automattic.com/wordpress/trunk@12523 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/update-core.php | 24 ++++++++++++++++++++---- wp-includes/update.php | 6 +++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/wp-admin/update-core.php b/wp-admin/update-core.php index 49850d1f3..672e82715 100644 --- a/wp-admin/update-core.php +++ b/wp-admin/update-core.php @@ -13,7 +13,7 @@ if ( ! current_user_can('update_plugins') ) wp_die(__('You do not have sufficient permissions to update plugins for this blog.')); function list_core_update( $update ) { - global $wp_local_package; + global $wp_local_package, $wpdb; $version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ? $update->current : sprintf("%s–%s", $update->current, $update->locale); $current = false; @@ -21,6 +21,9 @@ function list_core_update( $update ) { $current = true; $submit = __('Upgrade Automatically'); $form_action = 'update-core.php?action=do-core-upgrade'; + $php_version = phpversion(); + $mysql_version = $wpdb->db_version(); + $show_buttons = true; if ( 'development' == $update->response ) { $message = __('You are using a development version of WordPress. You can upgrade to the latest nightly build automatically or download the nightly build and install it manually:'); $download = __('Download nightly build'); @@ -30,7 +33,18 @@ function list_core_update( $update ) { $submit = __('Re-install Automatically'); $form_action = 'update-core.php?action=do-core-reinstall'; } else { - $message = sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string); + $php_compat = version_compare( $php_version, $update->php_version, '>=' ); + $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' ); + if ( !$mysql_compat && !$php_compat ) + $message = sprintf( __('You cannot upgrade because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version ); + elseif ( !$php_compat ) + $message = sprintf( __('You cannot upgrade because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $update->current, $update->php_version, $php_version ); + elseif ( !$mysql_compat ) + $message = sprintf( __('You cannot upgrade because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $update->current, $update->mysql_version, $mysql_version ); + else + $message = sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string); + if ( !$mysql_compat || !$php_compat ) + $show_buttons = false; } $download = sprintf(__('Download %s'), $version_string); } @@ -41,10 +55,12 @@ function list_core_update( $update ) { echo '
'; wp_nonce_field('upgrade-core'); echo '

'; - echo ' '; echo ''; echo ''; - echo '' . $download . ' '; + if ( $show_buttons ) { + echo ' '; + echo '' . $download . ' '; + } if ( 'en_US' != $update->locale ) if ( !isset( $update->dismissed ) || !$update->dismissed ) echo ''; diff --git a/wp-includes/update.php b/wp-includes/update.php index 3b710569f..70db531c5 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -44,7 +44,7 @@ function wp_version_check() { else $mysql_version = 'N/A'; $local_package = isset( $wp_local_package )? $wp_local_package : ''; - $url = "http://api.wordpress.org/core/version-check/1.3/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package"; + $url = "http://api.wordpress.org/core/version-check/1.4/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package"; $options = array( 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), @@ -74,6 +74,10 @@ function wp_version_check() { $new_option->current = esc_attr( $returns[3] ); if ( isset( $returns[4] ) ) $new_option->locale = esc_attr( $returns[4] ); + if ( isset( $returns[5] ) ) + $new_option->php_version = esc_attr( $returns[5] ); + if ( isset( $returns[6] ) ) + $new_option->mysql_version = esc_attr( $returns[6] ); $new_options[] = $new_option; }