WordPress.org

Make WordPress Core

Ticket #11639: 11639-update-core.2.diff

File 11639-update-core.2.diff, 1.5 KB (added by nacin, 4 years ago)

$wp_filesystem->copy returns false, not WP_Error.

  • update-core.php

     
    219219 
    220220        @set_time_limit( 300 ); 
    221221 
     222        $versions_file = $wp_filesystem->wp_content_dir() . 'upgrade/version-current.php'; 
     223        if ( !$wp_filesystem->copy($from . '/wordpress/wp-includes/version.php', $versions_file) ) { 
     224                $wp_filesystem->delete($from, true); 
     225                return new WP_Error( 'copy_failed', __('Could not copy files.') ); 
     226        } 
     227 
     228        $wp_filesystem->chmod($versions_file, FS_CHMOD_FILE); 
     229        require_once( WP_CONTENT_DIR . '/upgrade/version-current.php' ); 
     230        $wp_filesystem->delete($versions_file); 
     231 
    222232        $php_version    = phpversion(); 
    223233        $mysql_version  = $wpdb->db_version(); 
    224         $required_php_version = '4.3'; 
    225         $required_mysql_version = '4.1.2'; 
    226         $wp_version = '2.9'; 
    227234        $php_compat     = version_compare( $php_version, $required_php_version, '>=' ); 
    228235        $mysql_compat   = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' ); 
    229236 
     237        if ( !$mysql_compat || !$php_compat ) 
     238                $wp_filesystem->delete($from, true); 
     239 
    230240        if ( !$mysql_compat && !$php_compat ) 
    231241                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 ) ); 
    232242        elseif ( !$php_compat )