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:
parent
9507d22243
commit
4542fbb2ae
|
@ -1251,9 +1251,6 @@ class Core_Upgrader extends WP_Upgrader {
|
||||||
|
|
||||||
$wp_dir = trailingslashit($wp_filesystem->abspath());
|
$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;
|
$partial = true;
|
||||||
if ( $parsed_args['do_rollback'] )
|
if ( $parsed_args['do_rollback'] )
|
||||||
$partial = false;
|
$partial = false;
|
||||||
|
@ -1384,14 +1381,14 @@ class Core_Upgrader extends WP_Upgrader {
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_files() {
|
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;
|
return false;
|
||||||
|
|
||||||
foreach ( $checksums[ $wp_version ] as $file => $checksum ) {
|
foreach ( $checksums as $file => $checksum ) {
|
||||||
// Skip files which get updated
|
// Skip files which get updated
|
||||||
if ( 'wp-content' == substr( $file, 0, 10 ) )
|
if ( 'wp-content' == substr( $file, 0, 10 ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -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
|
// Check to see which files don't really need updating - only available for 3.7 and higher
|
||||||
if ( function_exists( 'get_core_checksums' ) ) {
|
if ( function_exists( 'get_core_checksums' ) ) {
|
||||||
$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( current( $checksums ) ) ) // Compat code for 3.7-beta2
|
||||||
foreach( $checksums[ $wp_version ] as $file => $checksum ) {
|
$checksums = current( $checksums );
|
||||||
|
if ( is_array( $checksums ) ) {
|
||||||
|
foreach( $checksums as $file => $checksum ) {
|
||||||
if ( 'wp-content' == substr( $file, 0, 10 ) )
|
if ( 'wp-content' == substr( $file, 0, 10 ) )
|
||||||
continue;
|
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;
|
$skip[] = $file;
|
||||||
else
|
else
|
||||||
$check_is_writable[ $file ] = ABSPATH . $file;
|
$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
|
// Check to make sure everything copied correctly, ignoring the contents of wp-content
|
||||||
$skip = array( 'wp-content' );
|
$skip = array( 'wp-content' );
|
||||||
$failed = array();
|
$failed = array();
|
||||||
if ( ! empty( $checksums[ $wp_version ] ) && is_array( $checksums[ $wp_version ] ) ) {
|
if ( is_array( $checksums ) ) {
|
||||||
foreach ( $checksums[ $wp_version ] as $file => $checksum ) {
|
foreach ( $checksums as $file => $checksum ) {
|
||||||
if ( 0 === strpos( $file, 'wp-content' ) )
|
if ( 0 === strpos( $file, 'wp-content' ) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -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
|
* @since 3.7.0
|
||||||
*
|
*
|
||||||
* @param $version string|array A single version, or an array of versions to fetch
|
* @param string $version Version string to query.
|
||||||
*
|
* @param string $locale Locale to query.
|
||||||
* @return bool|array False on failure, otherwise the array of checksums, keyed by version
|
* @return bool|array False on failure. An array of checksums on success.
|
||||||
*/
|
*/
|
||||||
function get_core_checksums( $version ) {
|
function get_core_checksums( $version, $locale ) {
|
||||||
if ( ! is_array( $version ) )
|
|
||||||
$version = array( $version );
|
|
||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
||||||
// Check to see if we have cached copies available, if we do, no need to request them
|
$url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' );
|
||||||
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, '&' );
|
|
||||||
|
|
||||||
if ( wp_http_supports( array( 'ssl' ) ) )
|
if ( wp_http_supports( array( 'ssl' ) ) )
|
||||||
$url = set_url_scheme( $url, 'https' );
|
$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'] ) )
|
if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Cache the checksums for later
|
return $body['checksums'];
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismiss_core_update( $update ) {
|
function dismiss_core_update( $update ) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue