Make WordPress Core


Ignore:
Timestamp:
09/21/2013 06:48:20 AM (11 years ago)
Author:
dd32
Message:

Upgrader: Perform a MD5 file verification check on the files during upgrade. This ensures that both a Partial upgrade build can be used, and that all the files were copied into place correctly.
Props pento for initial patch. Fixes #18201

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r25496 r25540  
    11121112        $wp_dir = trailingslashit($wp_filesystem->abspath());
    11131113
     1114        // Pre-cache the checksums for the versions we care about
     1115        get_core_checksums( array( $wp_version, $current->version ) );
     1116
     1117        $no_partial = false;
     1118        if ( ! $this->check_files() )
     1119            $no_partial = true;
     1120
    11141121        // If partial update is returned from the API, use that, unless we're doing a reinstall.
    11151122        // If we cross the new_bundled version number, then use the new_bundled zip.
    11161123        // Don't though if the constant is set to skip bundled items.
    11171124        // If the API returns a no_content zip, go with it. Finally, default to the full zip.
    1118         if ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version )
     1125        if ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && ! $no_partial )
    11191126            $to_download = 'partial';
    11201127        elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' )
     
    12061213    }
    12071214
     1215    function check_files() {
     1216        global $wp_version;
     1217
     1218        $checksums = get_core_checksums( $wp_version );
     1219
     1220        if ( empty( $checksums[ $wp_version ] ) || ! is_array( $checksums[ $wp_version ] ) )
     1221            return false;
     1222
     1223        foreach ( $checksums[ $wp_version ] as $file => $checksum ) {
     1224            if ( md5_file( ABSPATH . $file ) !== $checksum )
     1225                return false;
     1226        }
     1227
     1228        return true;
     1229    }
    12081230}
    12091231
Note: See TracChangeset for help on using the changeset viewer.