diff --git a/wp-admin/update-core.php b/wp-admin/update-core.php index 49850d1f39..672e827157 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 3b710569fa..70db531c54 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; }