wp/wp-admin/includes/class-wp-site-health-auto-updates.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
--- a/wp/wp-admin/includes/class-wp-site-health-auto-updates.php	Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-admin/includes/class-wp-site-health-auto-updates.php	Fri Sep 05 18:40:08 2025 +0200
@@ -7,6 +7,7 @@
  * @since 5.2.0
  */
 
+#[AllowDynamicProperties]
 class WP_Site_Health_Auto_Updates {
 	/**
 	 * WP_Site_Health_Auto_Updates constructor.
@@ -19,7 +20,7 @@
 
 
 	/**
-	 * Run tests to determine if auto-updates can run.
+	 * Runs tests to determine if auto-updates can run.
 	 *
 	 * @since 5.2.0
 	 *
@@ -41,7 +42,7 @@
 
 		$tests = array_filter( $tests );
 		$tests = array_map(
-			static function( $test ) {
+			static function ( $test ) {
 				$test = (object) $test;
 
 				if ( empty( $test->severity ) ) {
@@ -57,7 +58,7 @@
 	}
 
 	/**
-	 * Test if auto-updates related constants are set correctly.
+	 * Tests if auto-updates related constants are set correctly.
 	 *
 	 * @since 5.2.0
 	 * @since 5.5.1 The `$value` parameter can accept an array.
@@ -73,9 +74,10 @@
 		if ( defined( $constant ) && ! in_array( constant( $constant ), $acceptable_values, true ) ) {
 			return array(
 				'description' => sprintf(
-					/* translators: %s: Name of the constant used. */
-					__( 'The %s constant is defined and enabled.' ),
-					"<code>$constant</code>"
+					/* translators: 1: Name of the constant used. 2: Value of the constant used. */
+					__( 'The %1$s constant is defined as %2$s' ),
+					"<code>$constant</code>",
+					'<code>' . esc_html( var_export( constant( $constant ), true ) ) . '</code>'
 				),
 				'severity'    => 'fail',
 			);
@@ -83,7 +85,7 @@
 	}
 
 	/**
-	 * Check if updates are intercepted by a filter.
+	 * Checks if updates are intercepted by a filter.
 	 *
 	 * @since 5.2.0
 	 *
@@ -105,7 +107,7 @@
 	}
 
 	/**
-	 * Check if automatic updates are disabled by a filter.
+	 * Checks if automatic updates are disabled by a filter.
 	 *
 	 * @since 5.2.0
 	 *
@@ -126,7 +128,7 @@
 	}
 
 	/**
-	 * Check if automatic updates are disabled.
+	 * Checks if automatic updates are disabled.
 	 *
 	 * @since 5.3.0
 	 *
@@ -150,7 +152,7 @@
 	}
 
 	/**
-	 * Check if automatic updates have tried to run, but failed, previously.
+	 * Checks if automatic updates have tried to run, but failed, previously.
 	 *
 	 * @since 5.2.0
 	 *
@@ -166,7 +168,7 @@
 		if ( ! empty( $failed['critical'] ) ) {
 			$description  = __( 'A previous automatic background update ended with a critical failure, so updates are now disabled.' );
 			$description .= ' ' . __( 'You would have received an email because of this.' );
-			$description .= ' ' . __( "When you've been able to update using the \"Update now\" button on Dashboard > Updates, we'll clear this error for future update attempts." );
+			$description .= ' ' . __( "When you've been able to update using the \"Update now\" button on Dashboard > Updates, this error will be cleared for future update attempts." );
 			$description .= ' ' . sprintf(
 				/* translators: %s: Code of error shown. */
 				__( 'The error code was %s.' ),
@@ -183,7 +185,7 @@
 			$description .= ' ' . __( 'You would have received an email because of this.' );
 		}
 
-		$description .= ' ' . __( "We'll try again with the next release." );
+		$description .= ' ' . __( 'Another attempt will be made with the next release.' );
 		$description .= ' ' . sprintf(
 			/* translators: %s: Code of error shown. */
 			__( 'The error code was %s.' ),
@@ -196,7 +198,7 @@
 	}
 
 	/**
-	 * Check if WordPress is controlled by a VCS (Git, Subversion etc).
+	 * Checks if WordPress is controlled by a VCS (Git, Subversion etc).
 	 *
 	 * @since 5.2.0
 	 *
@@ -226,7 +228,7 @@
 		// Search all directories we've found for evidence of version control.
 		foreach ( $vcs_dirs as $vcs_dir ) {
 			foreach ( $check_dirs as $check_dir ) {
-				// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition,Squiz.PHP.DisallowMultipleAssignments
+				// phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition,Squiz.PHP.DisallowMultipleAssignments
 				if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) {
 					break 2;
 				}
@@ -266,7 +268,7 @@
 	}
 
 	/**
-	 * Check if we can access files without providing credentials.
+	 * Checks if we can access files without providing credentials.
 	 *
 	 * @since 5.2.0
 	 *
@@ -275,10 +277,10 @@
 	public function test_check_wp_filesystem_method() {
 		// Make sure the `request_filesystem_credentials()` function is available during our REST API call.
 		if ( ! function_exists( 'request_filesystem_credentials' ) ) {
-			require_once ABSPATH . '/wp-admin/includes/file.php';
+			require_once ABSPATH . 'wp-admin/includes/file.php';
 		}
 
-		$skin    = new Automatic_Upgrader_Skin;
+		$skin    = new Automatic_Upgrader_Skin();
 		$success = $skin->request_filesystem_credentials( false, ABSPATH );
 
 		if ( ! $success ) {
@@ -298,7 +300,7 @@
 	}
 
 	/**
-	 * Check if core files are writable by the web user/group.
+	 * Checks if core files are writable by the web user/group.
 	 *
 	 * @since 5.2.0
 	 *
@@ -311,7 +313,7 @@
 
 		require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
 
-		$skin    = new Automatic_Upgrader_Skin;
+		$skin    = new Automatic_Upgrader_Skin();
 		$success = $skin->request_filesystem_credentials( false, ABSPATH );
 
 		if ( ! $success ) {
@@ -326,11 +328,11 @@
 
 		// Make sure the `get_core_checksums()` function is available during our REST API call.
 		if ( ! function_exists( 'get_core_checksums' ) ) {
-			require_once ABSPATH . '/wp-admin/includes/update.php';
+			require_once ABSPATH . 'wp-admin/includes/update.php';
 		}
 
 		$checksums = get_core_checksums( $wp_version, 'en_US' );
-		$dev       = ( false !== strpos( $wp_version, '-' ) );
+		$dev       = ( str_contains( $wp_version, '-' ) );
 		// Get the last stable version's files and test against that.
 		if ( ! $checksums && $dev ) {
 			$checksums = get_core_checksums( (float) $wp_version - 0.1, 'en_US' );
@@ -356,7 +358,7 @@
 
 		$unwritable_files = array();
 		foreach ( array_keys( $checksums ) as $file ) {
-			if ( 'wp-content' === substr( $file, 0, 10 ) ) {
+			if ( str_starts_with( $file, 'wp-content' ) ) {
 				continue;
 			}
 			if ( ! file_exists( ABSPATH . $file ) ) {
@@ -385,7 +387,7 @@
 	}
 
 	/**
-	 * Check if the install is using a development branch and can use nightly packages.
+	 * Checks if the install is using a development branch and can use nightly packages.
 	 *
 	 * @since 5.2.0
 	 *
@@ -394,7 +396,7 @@
 	public function test_accepts_dev_updates() {
 		require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
 		// Only for dev versions.
-		if ( false === strpos( $wp_version, '-' ) ) {
+		if ( ! str_contains( $wp_version, '-' ) ) {
 			return false;
 		}
 
@@ -423,7 +425,7 @@
 	}
 
 	/**
-	 * Check if the site supports automatic minor updates.
+	 * Checks if the site supports automatic minor updates.
 	 *
 	 * @since 5.2.0
 	 *