WordPress.org

Make WordPress Core

Changeset 12422


Ignore:
Timestamp:
12/17/2009 04:04:47 PM (12 years ago)
Author:
ryan
Message:

Check MySQL and PHP versions when auto upgrading. Props westi, Denis-de-Bernardy, nacin, caesarsgrunt. see #11464

File:
1 edited

Legend:

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

    r12060 r12422  
    216216 */
    217217function update_core($from, $to) {
    218     global $wp_filesystem, $_old_files;
     218    global $wp_filesystem, $_old_files, $wpdb;
    219219
    220220    @set_time_limit( 300 );
     221
     222    $php_version   = phpversion();
     223    $php_compat    = version_compare( $php_version, '4.3', '>=' );
     224    $mysql_version = $wpdb->db_version;
     225    $mysql_compat  = version_compare( $mysql_version, '4.1.2', '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
     226
     227    if ( !$mysql_compat && !$php_compat )
     228        return new WP_Error( 'php_mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress requires PHP version 4.3 or higher and MySQL version 4.1.2 or higher. You are running PHP version %1$s and MySQL version %2$s.'), $php_version, $mysql_version ) );
     229    elseif ( !$php_compat )
     230        return new WP_Error( 'php_not_compatible', sprintf( __('The update cannot be installed because WordPress requires PHP version 4.3 or higher. You are running version %s.'), $php_version ) );
     231    elseif ( !$mysql_compat )
     232        return new WP_Error( 'mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress requires MySQL version 4.1.2 or higher. You are running version %s.'), $mysql_version ) );
    221233
    222234    // Sanity check the unzipped distribution
Note: See TracChangeset for help on using the changeset viewer.