WordPress.org

Make WordPress Core

Changeset 25801


Ignore:
Timestamp:
10/15/13 23:02:28 (4 years ago)
Author:
nacin
Message:

Significantly simplify get_core_checksums(), as the caching and chunking was causing too much grief.

Make sure we only do our pre-flight is_writable check when the file exists.

see #18201. see #22704.

Location:
trunk/src
Files:
4 edited

Legend:

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

    r25787 r25801  
    12521252        $wp_dir = trailingslashit($wp_filesystem->abspath()); 
    12531253 
    1254         // Pre-cache the checksums for the versions we care about 
    1255         get_core_checksums( array( $wp_version, $current->version ) ); 
    1256  
    12571254        $partial = true; 
    12581255        if ( $parsed_args['do_rollback'] ) 
     
    13851382 
    13861383    function check_files() { 
    1387         global $wp_version; 
    1388  
    1389         $checksums = get_core_checksums( $wp_version ); 
    1390  
    1391         if ( empty( $checksums[ $wp_version ] ) || ! is_array( $checksums[ $wp_version ] ) ) 
     1384        global $wp_version, $wp_local_package; 
     1385 
     1386        $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' ); 
     1387 
     1388        if ( ! is_array( $checksums ) ) 
    13921389            return false; 
    13931390 
    1394         foreach ( $checksums[ $wp_version ] as $file => $checksum ) { 
     1391        foreach ( $checksums as $file => $checksum ) { 
    13951392            // Skip files which get updated 
    13961393            if ( 'wp-content' == substr( $file, 0, 10 ) ) 
  • trunk/src/wp-admin/includes/update-core.php

    r25800 r25801  
    697697    // Check to see which files don't really need updating - only available for 3.7 and higher 
    698698    if ( function_exists( 'get_core_checksums' ) ) { 
    699         $checksums = get_core_checksums( $wp_version ); 
    700         if ( ! empty( $checksums[ $wp_version ] ) && is_array( $checksums[ $wp_version ] ) ) { 
    701             foreach( $checksums[ $wp_version ] as $file => $checksum ) { 
     699        $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' ); 
     700        if ( is_array( current( $checksums ) ) ) // Compat code for 3.7-beta2 
     701            $checksums = current( $checksums ); 
     702        if ( is_array( $checksums ) ) { 
     703            foreach( $checksums as $file => $checksum ) { 
    702704                if ( 'wp-content' == substr( $file, 0, 10 ) ) 
    703705                    continue; 
    704                 if ( file_exists( ABSPATH . $file ) && md5_file( ABSPATH . $file ) === $checksum ) 
     706                if ( ! file_exists( ABSPATH . $file ) ) 
     707                    continue; 
     708                if ( md5_file( ABSPATH . $file ) === $checksum ) 
    705709                    $skip[] = $file; 
    706710                else 
     
    746750    $skip = array( 'wp-content' ); 
    747751    $failed = array(); 
    748     if ( ! empty( $checksums[ $wp_version ] ) && is_array( $checksums[ $wp_version ] ) ) { 
    749         foreach ( $checksums[ $wp_version ] as $file => $checksum ) { 
     752    if ( is_array( $checksums ) ) { 
     753        foreach ( $checksums as $file => $checksum ) { 
    750754            if ( 0 === strpos( $file, 'wp-content' ) ) 
    751755                continue; 
  • trunk/src/wp-admin/includes/update.php

    r25783 r25801  
    9292 
    9393/** 
    94  * Gets and caches the checksums for the given versions of WordPress 
     94 * Gets and caches the checksums for the given version of WordPress. 
    9595 * 
    9696 * @since 3.7.0 
    9797 * 
    98  * @param $version string|array A single version, or an array of versions to fetch 
    99  * 
    100  * @return bool|array False on failure, otherwise the array of checksums, keyed by version 
    101  */ 
    102 function get_core_checksums( $version ) { 
    103     if ( ! is_array( $version ) ) 
    104         $version = array( $version ); 
    105  
     98 * @param string $version Version string to query. 
     99 * @param string $locale  Locale to query. 
     100 * @return bool|array False on failure. An array of checksums on success. 
     101 */ 
     102function get_core_checksums( $version, $locale ) { 
    106103    $return = array(); 
    107104 
    108     // Check to see if we have cached copies available, if we do, no need to request them 
    109     foreach ( $version as $i => $v ) { 
    110         if ( $checksums = get_site_transient( "core_checksums_$v" ) ) { 
    111             unset( $version[ $i ] ); 
    112             $return[ $v ] = $checksums; 
    113         } 
    114     } 
    115  
    116     // We had cached copies for all of the versions! 
    117     if ( empty( $version ) ) 
    118         return $return; 
    119  
    120     $url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( array( 'version' => $version ), null, '&' ); 
     105    $url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' ); 
    121106 
    122107    if ( wp_http_supports( array( 'ssl' ) ) ) 
     
    138123        return false; 
    139124 
    140     // Cache the checksums for later 
    141     foreach ( $version as $v ) { 
    142         if ( ! isset( $body['checksums'][ $v ] ) ) 
    143             $body['checksums'][ $v ] = false; 
    144         set_site_transient( "core_checksums_$v", $body['checksums'][ $v ], HOUR_IN_SECONDS ); 
    145         $return[ $v ] = $body['checksums'][ $v ]; 
    146     } 
    147  
    148     // If the API didn't return anything for a version, explicitly set it's return value to false 
    149     foreach ( $return as $v => $r ) { 
    150         if ( empty( $r ) ) 
    151             $return[ $v ] = false; 
    152     } 
    153  
    154     return $return; 
     125    return $body['checksums']; 
    155126} 
    156127 
  • trunk/src/wp-includes/version.php

    r25800 r25801  
    55 * @global string $wp_version 
    66 */ 
    7 $wp_version = '3.7-beta2-25800-src'; 
     7$wp_version = '3.7-beta2-25801-src'; 
    88 
    99/** 
Note: See TracChangeset for help on using the changeset viewer.