--- a/wp/wp-admin/includes/class-core-upgrader.php Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/includes/class-core-upgrader.php Tue Dec 15 13:49:49 2020 +0100
@@ -29,7 +29,7 @@
$this->strings['up_to_date'] = __( 'WordPress is at the latest version.' );
$this->strings['locked'] = __( 'Another update is currently in progress.' );
$this->strings['no_package'] = __( 'Update package not available.' );
- /* translators: %s: package URL */
+ /* translators: %s: Package URL. */
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' );
$this->strings['unpack_package'] = __( 'Unpacking the update…' );
$this->strings['copy_failed'] = __( 'Could not copy files.' );
@@ -57,12 +57,12 @@
* @type bool $do_rollback Whether to perform this "upgrade" as a rollback.
* Default false.
* }
- * @return null|false|WP_Error False or WP_Error on failure, null on success.
+ * @return string|false|WP_Error New WordPress version on success, false or WP_Error on failure.
*/
public function upgrade( $current, $args = array() ) {
global $wp_filesystem;
- include( ABSPATH . WPINC . '/version.php' ); // $wp_version;
+ require ABSPATH . WPINC . '/version.php'; // $wp_version;
$start_time = time();
@@ -78,7 +78,7 @@
$this->upgrade_strings();
// Is an update available?
- if ( ! isset( $current->response ) || $current->response == 'latest' ) {
+ if ( ! isset( $current->response ) || 'latest' === $current->response ) {
return new WP_Error( 'up_to_date', $this->strings['up_to_date'] );
}
@@ -104,7 +104,7 @@
*/
if ( $parsed_args['do_rollback'] && $current->packages->rollback ) {
$to_download = 'rollback';
- } elseif ( $current->packages->partial && 'reinstall' != $current->response && $wp_version == $current->partial_version && $partial ) {
+ } elseif ( $current->packages->partial && 'reinstall' !== $current->response && $wp_version == $current->partial_version && $partial ) {
$to_download = 'partial';
} elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' )
&& ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
@@ -115,7 +115,7 @@
$to_download = 'full';
}
- // Lock to prevent multiple Core Updates occurring
+ // Lock to prevent multiple Core Updates occurring.
$lock = WP_Upgrader::create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS );
if ( ! $lock ) {
return new WP_Error( 'locked', $this->strings['locked'] );
@@ -127,6 +127,7 @@
// WARNING: This may be removed in the future.
if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
// Outout the failure error as a normal feedback, and not as an error:
+ /** This filter is documented in wp-admin/includes/update-core.php */
apply_filters( 'update_feedback', $download->get_error_message() );
// Report this failure back to WordPress.org for debugging purposes.
@@ -160,7 +161,8 @@
}
$wp_filesystem->chmod( $wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE );
- require_once( ABSPATH . 'wp-admin/includes/update-core.php' );
+ wp_opcache_invalidate( ABSPATH . 'wp-admin/includes/update-core.php' );
+ require_once ABSPATH . 'wp-admin/includes/update-core.php';
if ( ! function_exists( 'update_core' ) ) {
WP_Upgrader::release_lock( 'core_updater' );
@@ -219,7 +221,7 @@
)
);
- // Clear the current updates
+ // Clear the current updates.
delete_site_transient( 'update_core' );
if ( ! $parsed_args['do_rollback'] ) {
@@ -269,10 +271,11 @@
* @return bool True if we should update to the offered version, otherwise false.
*/
public static function should_update_to_version( $offered_ver ) {
- include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z
+ require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
- $current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y
- $new_branch = implode( '.', array_slice( preg_split( '/[.-]/', $offered_ver ), 0, 2 ) ); // x.y
+ $current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y
+ $new_branch = implode( '.', array_slice( preg_split( '/[.-]/', $offered_ver ), 0, 2 ) ); // x.y
+
$current_is_development_version = (bool) strpos( $wp_version, '-' );
// Defaults:
@@ -283,15 +286,20 @@
// WP_AUTO_UPDATE_CORE = true (all), 'minor', false.
if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) {
if ( false === WP_AUTO_UPDATE_CORE ) {
- // Defaults to turned off, unless a filter allows it
- $upgrade_dev = $upgrade_minor = $upgrade_major = false;
+ // Defaults to turned off, unless a filter allows it.
+ $upgrade_dev = false;
+ $upgrade_minor = false;
+ $upgrade_major = false;
} elseif ( true === WP_AUTO_UPDATE_CORE ) {
- // ALL updates for core
- $upgrade_dev = $upgrade_minor = $upgrade_major = true;
+ // ALL updates for core.
+ $upgrade_dev = true;
+ $upgrade_minor = true;
+ $upgrade_major = true;
} elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) {
- // Only minor updates for core
- $upgrade_dev = $upgrade_major = false;
+ // Only minor updates for core.
+ $upgrade_dev = false;
$upgrade_minor = true;
+ $upgrade_major = false;
}
}
@@ -300,7 +308,7 @@
return false;
}
- // 2: If we're running a newer version, that's a nope
+ // 2: If we're running a newer version, that's a nope.
if ( version_compare( $wp_version, $offered_ver, '>' ) ) {
return false;
}
@@ -317,15 +325,17 @@
return false;
}
- // Cannot update if we're retrying the same A to B update that caused a non-critical failure.
- // Some non-critical failures do allow retries, like download_failed.
- // 3.7.1 => 3.7.2 resulted in files_not_writable, if we are still on 3.7.1 and still trying to update to 3.7.2.
+ /*
+ * Cannot update if we're retrying the same A to B update that caused a non-critical failure.
+ * Some non-critical failures do allow retries, like download_failed.
+ * 3.7.1 => 3.7.2 resulted in files_not_writable, if we are still on 3.7.1 and still trying to update to 3.7.2.
+ */
if ( empty( $failure_data['retry'] ) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted'] ) {
return false;
}
}
- // 3: 3.7-alpha-25000 -> 3.7-alpha-25678 -> 3.7-beta1 -> 3.7-beta2
+ // 3: 3.7-alpha-25000 -> 3.7-alpha-25678 -> 3.7-beta1 -> 3.7-beta2.
if ( $current_is_development_version ) {
/**
@@ -342,7 +352,7 @@
// Else fall through to minor + major branches below.
}
- // 4: Minor In-branch updates (3.7.0 -> 3.7.1 -> 3.7.2 -> 3.7.4)
+ // 4: Minor in-branch updates (3.7.0 -> 3.7.1 -> 3.7.2 -> 3.7.4).
if ( $current_branch == $new_branch ) {
/**
@@ -355,7 +365,7 @@
return apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor );
}
- // 5: Major version updates (3.7.0 -> 3.8.0 -> 3.9.1)
+ // 5: Major version updates (3.7.0 -> 3.8.0 -> 3.9.1).
if ( version_compare( $new_branch, $current_branch, '>' ) ) {
/**
@@ -368,7 +378,7 @@
return apply_filters( 'allow_major_auto_core_updates', $upgrade_major );
}
- // If we're not sure, we don't want it
+ // If we're not sure, we don't want it.
return false;
}
@@ -377,8 +387,8 @@
*
* @since 3.7.0
*
- * @global string $wp_version
- * @global string $wp_local_package
+ * @global string $wp_version The WordPress version string.
+ * @global string $wp_local_package Locale code of the package.
*
* @return bool True if the checksums match, otherwise false.
*/
@@ -392,8 +402,8 @@
}
foreach ( $checksums as $file => $checksum ) {
- // Skip files which get updated
- if ( 'wp-content' == substr( $file, 0, 10 ) ) {
+ // Skip files which get updated.
+ if ( 'wp-content' === substr( $file, 0, 10 ) ) {
continue;
}
if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) {