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.

Built from https://develop.svn.wordpress.org/trunk@25801


git-svn-id: http://core.svn.wordpress.org/trunk@25713 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-10-15 23:03:10 +00:00
parent 9507d22243
commit 4542fbb2ae
4 changed files with 22 additions and 50 deletions

View File

@ -1251,9 +1251,6 @@ class Core_Upgrader extends WP_Upgrader {
$wp_dir = trailingslashit($wp_filesystem->abspath());
// Pre-cache the checksums for the versions we care about
get_core_checksums( array( $wp_version, $current->version ) );
$partial = true;
if ( $parsed_args['do_rollback'] )
$partial = false;
@ -1384,14 +1381,14 @@ class Core_Upgrader extends WP_Upgrader {
}
function check_files() {
global $wp_version;
global $wp_version, $wp_local_package;
$checksums = get_core_checksums( $wp_version );
$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
if ( empty( $checksums[ $wp_version ] ) || ! is_array( $checksums[ $wp_version ] ) )
if ( ! is_array( $checksums ) )
return false;
foreach ( $checksums[ $wp_version ] as $file => $checksum ) {
foreach ( $checksums as $file => $checksum ) {
// Skip files which get updated
if ( 'wp-content' == substr( $file, 0, 10 ) )
continue;

View File

@ -696,12 +696,16 @@ function update_core($from, $to) {
// Check to see which files don't really need updating - only available for 3.7 and higher
if ( function_exists( 'get_core_checksums' ) ) {
$checksums = get_core_checksums( $wp_version );
if ( ! empty( $checksums[ $wp_version ] ) && is_array( $checksums[ $wp_version ] ) ) {
foreach( $checksums[ $wp_version ] as $file => $checksum ) {
$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
if ( is_array( current( $checksums ) ) ) // Compat code for 3.7-beta2
$checksums = current( $checksums );
if ( is_array( $checksums ) ) {
foreach( $checksums as $file => $checksum ) {
if ( 'wp-content' == substr( $file, 0, 10 ) )
continue;
if ( file_exists( ABSPATH . $file ) && md5_file( ABSPATH . $file ) === $checksum )
if ( ! file_exists( ABSPATH . $file ) )
continue;
if ( md5_file( ABSPATH . $file ) === $checksum )
$skip[] = $file;
else
$check_is_writable[ $file ] = ABSPATH . $file;
@ -745,8 +749,8 @@ function update_core($from, $to) {
// Check to make sure everything copied correctly, ignoring the contents of wp-content
$skip = array( 'wp-content' );
$failed = array();
if ( ! empty( $checksums[ $wp_version ] ) && is_array( $checksums[ $wp_version ] ) ) {
foreach ( $checksums[ $wp_version ] as $file => $checksum ) {
if ( is_array( $checksums ) ) {
foreach ( $checksums as $file => $checksum ) {
if ( 0 === strpos( $file, 'wp-content' ) )
continue;

View File

@ -91,33 +91,18 @@ function find_core_auto_update() {
}
/**
* Gets and caches the checksums for the given versions of WordPress
* Gets and caches the checksums for the given version of WordPress.
*
* @since 3.7.0
*
* @param $version string|array A single version, or an array of versions to fetch
*
* @return bool|array False on failure, otherwise the array of checksums, keyed by version
* @param string $version Version string to query.
* @param string $locale Locale to query.
* @return bool|array False on failure. An array of checksums on success.
*/
function get_core_checksums( $version ) {
if ( ! is_array( $version ) )
$version = array( $version );
function get_core_checksums( $version, $locale ) {
$return = array();
// Check to see if we have cached copies available, if we do, no need to request them
foreach ( $version as $i => $v ) {
if ( $checksums = get_site_transient( "core_checksums_$v" ) ) {
unset( $version[ $i ] );
$return[ $v ] = $checksums;
}
}
// We had cached copies for all of the versions!
if ( empty( $version ) )
return $return;
$url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( array( 'version' => $version ), null, '&' );
$url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' );
if ( wp_http_supports( array( 'ssl' ) ) )
$url = set_url_scheme( $url, 'https' );
@ -137,21 +122,7 @@ function get_core_checksums( $version ) {
if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) )
return false;
// Cache the checksums for later
foreach ( $version as $v ) {
if ( ! isset( $body['checksums'][ $v ] ) )
$body['checksums'][ $v ] = false;
set_site_transient( "core_checksums_$v", $body['checksums'][ $v ], HOUR_IN_SECONDS );
$return[ $v ] = $body['checksums'][ $v ];
}
// If the API didn't return anything for a version, explicitly set it's return value to false
foreach ( $return as $v => $r ) {
if ( empty( $r ) )
$return[ $v ] = false;
}
return $return;
return $body['checksums'];
}
function dismiss_core_update( $update ) {

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '3.7-beta2-25800';
$wp_version = '3.7-beta2-25801';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.