WordPress.org

Make WordPress Core

Changeset 12523


Ignore:
Timestamp:
12/23/2009 06:35:12 PM (9 years ago)
Author:
ryan
Message:

Check required php and mysql versions in the update response and notify if the server environment does not meet those requirements. fixes #11562

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/update-core.php

    r12497 r12523  
    1414
    1515function list_core_update( $update ) {
    16     global $wp_local_package;
     16    global $wp_local_package, $wpdb;
    1717    $version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ?
    1818            $update->current : sprintf("%s&ndash;<strong>%s</strong>", $update->current, $update->locale);
     
    2222    $submit = __('Upgrade Automatically');
    2323    $form_action = 'update-core.php?action=do-core-upgrade';
     24    $php_version    = phpversion();
     25    $mysql_version  = $wpdb->db_version();
     26    $show_buttons = true;
    2427    if ( 'development' == $update->response ) {
    2528        $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:');
     
    3134            $form_action = 'update-core.php?action=do-core-reinstall';
    3235        } else {
    33             $message =  sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string);
     36            $php_compat     = version_compare( $php_version, $update->php_version, '>=' );
     37            $mysql_compat   = version_compare( $mysql_version, $update->mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
     38            if ( !$mysql_compat && !$php_compat )
     39                $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 );
     40            elseif ( !$php_compat )
     41                $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 );
     42            elseif ( !$mysql_compat )
     43                $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 );
     44            else
     45                $message =  sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string);
     46            if ( !$mysql_compat || !$php_compat )
     47                $show_buttons = false;
    3448        }
    3549        $download = sprintf(__('Download %s'), $version_string);
     
    4256    wp_nonce_field('upgrade-core');
    4357    echo '<p>';
    44     echo '<input id="upgrade" class="button" type="submit" value="' . esc_attr($submit) . '" name="upgrade" />&nbsp;';
    4558    echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
    4659    echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
    47     echo '<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a>&nbsp;';
     60    if ( $show_buttons ) {
     61        echo '<input id="upgrade" class="button" type="submit" value="' . esc_attr($submit) . '" name="upgrade" />&nbsp;';
     62        echo '<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a>&nbsp;';
     63    }
    4864    if ( 'en_US' != $update->locale )
    4965        if ( !isset( $update->dismissed ) || !$update->dismissed )
  • trunk/wp-includes/update.php

    r12348 r12523  
    4545        $mysql_version = 'N/A';
    4646    $local_package = isset( $wp_local_package )? $wp_local_package : '';
    47     $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";
     47    $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";
    4848
    4949    $options = array(
     
    7575        if ( isset( $returns[4] ) )
    7676            $new_option->locale = esc_attr( $returns[4] );
     77        if ( isset( $returns[5] ) )
     78            $new_option->php_version = esc_attr( $returns[5] );
     79        if ( isset( $returns[6] ) )
     80            $new_option->mysql_version = esc_attr( $returns[6] );
    7781        $new_options[] = $new_option;
    7882    }
Note: See TracChangeset for help on using the changeset viewer.