wp/wp-admin/includes/class-core-upgrader.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
--- a/wp/wp-admin/includes/class-core-upgrader.php	Tue Dec 15 15:52:01 2020 +0100
+++ b/wp/wp-admin/includes/class-core-upgrader.php	Wed Sep 21 18:19:35 2022 +0200
@@ -48,14 +48,14 @@
 	 *
 	 * @param object $current Response object for whether WordPress is current.
 	 * @param array  $args {
-	 *        Optional. Arguments for upgrading WordPress core. Default empty array.
+	 *     Optional. Arguments for upgrading WordPress core. Default empty array.
 	 *
-	 *        @type bool $pre_check_md5    Whether to check the file checksums before
-	 *                                     attempting the upgrade. Default true.
-	 *        @type bool $attempt_rollback Whether to attempt to rollback the chances if
-	 *                                     there is a problem. Default false.
-	 *        @type bool $do_rollback      Whether to perform this "upgrade" as a rollback.
-	 *                                     Default false.
+	 *     @type bool $pre_check_md5    Whether to check the file checksums before
+	 *                                  attempting the upgrade. Default true.
+	 *     @type bool $attempt_rollback Whether to attempt to rollback the chances if
+	 *                                  there is a problem. Default false.
+	 *     @type bool $do_rollback      Whether to perform this "upgrade" as a rollback.
+	 *                                  Default false.
 	 * }
 	 * @return string|false|WP_Error New WordPress version on success, false or WP_Error on failure.
 	 */
@@ -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 ) ) {
@@ -279,18 +279,20 @@
 		$current_is_development_version = (bool) strpos( $wp_version, '-' );
 
 		// Defaults:
-		$upgrade_dev   = true;
-		$upgrade_minor = true;
-		$upgrade_major = false;
+		$upgrade_dev   = get_site_option( 'auto_update_core_dev', 'enabled' ) === 'enabled';
+		$upgrade_minor = get_site_option( 'auto_update_core_minor', 'enabled' ) === 'enabled';
+		$upgrade_major = get_site_option( 'auto_update_core_major', 'unset' ) === 'enabled';
 
-		// WP_AUTO_UPDATE_CORE = true (all), 'minor', false.
+		// WP_AUTO_UPDATE_CORE = true (all), 'beta', 'rc', 'development', 'branch-development', '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   = false;
 				$upgrade_minor = false;
 				$upgrade_major = false;
-			} elseif ( true === WP_AUTO_UPDATE_CORE ) {
+			} elseif ( true === WP_AUTO_UPDATE_CORE
+				|| in_array( WP_AUTO_UPDATE_CORE, array( 'beta', 'rc', 'development', 'branch-development' ), true )
+			) {
 				// ALL updates for core.
 				$upgrade_dev   = true;
 				$upgrade_minor = true;
@@ -304,7 +306,7 @@
 		}
 
 		// 1: If we're already on that version, not much point in updating?
-		if ( $offered_ver == $wp_version ) {
+		if ( $offered_ver === $wp_version ) {
 			return false;
 		}
 
@@ -321,7 +323,7 @@
 			}
 
 			// Don't claim we can update on update-core.php if we have a non-critical failure logged.
-			if ( $wp_version == $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) ) {
+			if ( $wp_version === $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) ) {
 				return false;
 			}
 
@@ -330,7 +332,7 @@
 			 * 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'] ) {
+			if ( empty( $failure_data['retry'] ) && $wp_version === $failure_data['current'] && $offered_ver === $failure_data['attempted'] ) {
 				return false;
 			}
 		}
@@ -353,7 +355,7 @@
 		}
 
 		// 4: Minor in-branch updates (3.7.0 -> 3.7.1 -> 3.7.2 -> 3.7.4).
-		if ( $current_branch == $new_branch ) {
+		if ( $current_branch === $new_branch ) {
 
 			/**
 			 * Filters whether to enable minor automatic core updates.