WordPress.org

Make WordPress Core

Ticket #21789: 21789.diff

File 21789.diff, 5.6 KB (added by dd32, 3 years ago)
  • wp-admin/includes/update-core.php

     
    614614 
    615615        @set_time_limit( 300 ); 
    616616 
    617         $php_version    = phpversion(); 
    618         $mysql_version  = $wpdb->db_version(); 
    619         $required_php_version = '5.2.4'; 
    620         $required_mysql_version = '5.0'; 
    621         $wp_version = '3.4'; 
    622         $php_compat     = version_compare( $php_version, $required_php_version, '>=' ); 
    623         if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) 
    624                 $mysql_compat = true; 
    625         else 
    626                 $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ); 
    627  
    628         if ( !$mysql_compat || !$php_compat ) 
    629                 $wp_filesystem->delete($from, true); 
    630  
    631         if ( !$mysql_compat && !$php_compat ) 
    632                 return new WP_Error( 'php_mysql_not_compatible', sprintf( __('The update cannot be installed 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.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) ); 
    633         elseif ( !$php_compat ) 
    634                 return new WP_Error( 'php_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version ) ); 
    635         elseif ( !$mysql_compat ) 
    636                 return new WP_Error( 'mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version ) ); 
    637  
    638617        // Sanity check the unzipped distribution 
    639618        apply_filters('update_feedback', __('Verifying the unpacked files…')); 
    640619        $distro = ''; 
     
    650629                return new WP_Error('insane_distro', __('The update could not be unpacked') ); 
    651630        } 
    652631 
     632        $version_file = $wp_filesystem->wp_content_dir() . '/upgrade/version.php'; 
     633        if ( !$wp_filesystem->copy( $from . $distro . '/wp-includes/version.php', $version_file, true ) ) { 
     634                $wp_filesystem->delete( $from, true ); 
     635                return new WP_Error( 'copy_failed', __('Could not copy files.') ); 
     636        } 
     637        $wp_filesystem->chmod($version_file, FS_CHMOD_FILE); 
     638 
     639        // load new $wp_version, $required_php_version, $required_mysql_version 
     640        include WP_CONTENT_DIR . '/upgrade/version.php'; 
     641 
     642        $php_version         = phpversion(); 
     643        $mysql_version       = $wpdb->db_version(); 
     644        $old_wp_version      = $GLOBALS['wp_version']; // $wp_version in local scope == new version 
     645        $upgrading_nonstable = ( false !== strpos( $old_wp_version . $wp_version, '-' )  ); // The old/new version is a non-stable release 
     646 
     647        $php_compat     = version_compare( $php_version, $required_php_version, '>=' ); 
     648        if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) 
     649                $mysql_compat = true; 
     650        else 
     651                $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ); 
     652 
     653        if ( !$mysql_compat || !$php_compat ) { 
     654                // Clean out temporary files 
     655                $wp_filesystem->delete( $version_file, true ); 
     656                $wp_filesystem->delete( $from, true ); 
     657        } 
     658 
     659        if ( !$mysql_compat && !$php_compat ) 
     660                return new WP_Error( 'php_mysql_not_compatible', sprintf( __('The update cannot be installed 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.'), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) ); 
     661        elseif ( !$php_compat ) 
     662                return new WP_Error( 'php_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $wp_version, $required_php_version, $php_version ) ); 
     663        elseif ( !$mysql_compat ) 
     664                return new WP_Error( 'mysql_not_compatible', sprintf( __('The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $wp_version, $required_mysql_version, $mysql_version ) ); 
     665 
    653666        apply_filters('update_feedback', __('Installing the latest version…')); 
    654667 
    655668        // Create maintenance file to signal that we are upgrading 
     
    684697        // Copy New bundled plugins & themes 
    685698        // This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue. 
    686699        if ( !is_wp_error($result) && ( ! defined('CORE_UPGRADE_SKIP_NEW_BUNDLED') || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) { 
    687                 $old_version = $GLOBALS['wp_version']; // $wp_version in local scope == new version 
    688700                foreach ( (array) $_new_bundled_files as $file => $introduced_version ) { 
    689701                        // If $introduced version is greater than what the site was previously running 
    690                         if ( version_compare($introduced_version, $old_version, '>') ) { 
     702                        if ( version_compare( $introduced_version, $old_wp_version, '>' ) || $upgrading_nonstable ) { 
    691703                                $directory = ('/' == $file[ strlen($file)-1 ]); 
    692704                                list($type, $filename) = explode('/', $file, 2); 
    693705 
     
    699711                                        continue; 
    700712 
    701713                                if ( ! $directory ) { 
    702                                         if ( $wp_filesystem->exists($dest . $filename) ) 
     714                                        if ( $wp_filesystem->exists($dest . $filename) && ! $upgrading_nonstable ) 
    703715                                                continue; 
    704716 
    705717                                        if ( ! $wp_filesystem->copy($from . $distro . 'wp-content/' . $file, $dest . $filename, FS_CHMOD_FILE) ) 
    706718                                                $result = new WP_Error('copy_failed', __('Could not copy file.'), $dest . $filename); 
    707719                                } else { 
    708                                         if ( $wp_filesystem->is_dir($dest . $filename) ) 
     720                                        if ( $wp_filesystem->is_dir($dest . $filename)  && ! $upgrading_nonstable ) 
    709721                                                continue; 
    710722 
    711723                                        $wp_filesystem->mkdir($dest . $filename, FS_CHMOD_DIR);