Coding Standards: Use strict comparison in wp-admin/includes/class-wp-automatic-updater.php.

Includes minor code layout fixes for better readability.

See #52627.
Built from https://develop.svn.wordpress.org/trunk@50762


git-svn-id: http://core.svn.wordpress.org/trunk@50371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-04-16 12:01:15 +00:00
parent ad48a15387
commit afb02cb315
2 changed files with 29 additions and 7 deletions

View File

@ -151,7 +151,9 @@ class WP_Automatic_Updater {
} }
// If we can't do an auto core update, we may still be able to email the user. // If we can't do an auto core update, we may still be able to email the user.
if ( ! $skin->request_filesystem_credentials( false, $context, $allow_relaxed_file_ownership ) || $this->is_vcs_checkout( $context ) ) { if ( ! $skin->request_filesystem_credentials( false, $context, $allow_relaxed_file_ownership )
|| $this->is_vcs_checkout( $context )
) {
if ( 'core' === $type ) { if ( 'core' === $type ) {
$this->send_core_update_notification_email( $item ); $this->send_core_update_notification_email( $item );
} }
@ -256,7 +258,7 @@ class WP_Automatic_Updater {
// Don't notify if we've already notified the same email address of the same version. // Don't notify if we've already notified the same email address of the same version.
if ( $notified if ( $notified
&& get_site_option( 'admin_email' ) === $notified['email'] && get_site_option( 'admin_email' ) === $notified['email']
&& $notified['version'] == $item->current && $notified['version'] === $item->current
) { ) {
return false; return false;
} }
@ -633,7 +635,7 @@ class WP_Automatic_Updater {
if ( $notified if ( $notified
&& 'fail' === $notified['type'] && 'fail' === $notified['type']
&& get_site_option( 'admin_email' ) === $notified['email'] && get_site_option( 'admin_email' ) === $notified['email']
&& $notified['version'] == $core_update->current && $notified['version'] === $core_update->current
) { ) {
$send = false; $send = false;
} }
@ -682,7 +684,13 @@ class WP_Automatic_Updater {
$next_user_core_update = $core_update; $next_user_core_update = $core_update;
} }
$newer_version_available = ( 'upgrade' === $next_user_core_update->response && version_compare( $next_user_core_update->version, $core_update->version, '>' ) ); if ( 'upgrade' === $next_user_core_update->response
&& version_compare( $next_user_core_update->version, $core_update->version, '>' )
) {
$newer_version_available = true;
} else {
$newer_version_available = false;
}
/** /**
* Filters whether to send an email following an automatic background core update. * Filters whether to send an email following an automatic background core update.
@ -1189,7 +1197,7 @@ class WP_Automatic_Updater {
); );
} else { } else {
$body[] = sprintf( $body[] = sprintf(
/* translators: 1: Theme name, 2: Version number. */ /* translators: 1: Theme name, 2: Version number. */
__( '- %1$s version %2$s' ), __( '- %1$s version %2$s' ),
$item->name, $item->name,
$item->item->new_version $item->item->new_version
@ -1280,6 +1288,7 @@ class WP_Automatic_Updater {
// Core. // Core.
if ( isset( $this->update_results['core'] ) ) { if ( isset( $this->update_results['core'] ) ) {
$result = $this->update_results['core'][0]; $result = $this->update_results['core'][0];
if ( $result->result && ! is_wp_error( $result->result ) ) { if ( $result->result && ! is_wp_error( $result->result ) ) {
/* translators: %s: WordPress version. */ /* translators: %s: WordPress version. */
$body[] = sprintf( __( 'SUCCESS: WordPress was successfully updated to %s' ), $result->name ); $body[] = sprintf( __( 'SUCCESS: WordPress was successfully updated to %s' ), $result->name );
@ -1288,6 +1297,7 @@ class WP_Automatic_Updater {
$body[] = sprintf( __( 'FAILED: WordPress failed to update to %s' ), $result->name ); $body[] = sprintf( __( 'FAILED: WordPress failed to update to %s' ), $result->name );
$failures++; $failures++;
} }
$body[] = ''; $body[] = '';
} }
@ -1296,7 +1306,9 @@ class WP_Automatic_Updater {
if ( ! isset( $this->update_results[ $type ] ) ) { if ( ! isset( $this->update_results[ $type ] ) ) {
continue; continue;
} }
$success_items = wp_list_filter( $this->update_results[ $type ], array( 'result' => true ) ); $success_items = wp_list_filter( $this->update_results[ $type ], array( 'result' => true ) );
if ( $success_items ) { if ( $success_items ) {
$messages = array( $messages = array(
'plugin' => __( 'The following plugins were successfully updated:' ), 'plugin' => __( 'The following plugins were successfully updated:' ),
@ -1310,7 +1322,8 @@ class WP_Automatic_Updater {
$body[] = ' * ' . sprintf( __( 'SUCCESS: %s' ), $name ); $body[] = ' * ' . sprintf( __( 'SUCCESS: %s' ), $name );
} }
} }
if ( $success_items != $this->update_results[ $type ] ) {
if ( $success_items !== $this->update_results[ $type ] ) {
// Failed updates. // Failed updates.
$messages = array( $messages = array(
'plugin' => __( 'The following plugins failed to update:' ), 'plugin' => __( 'The following plugins failed to update:' ),
@ -1319,6 +1332,7 @@ class WP_Automatic_Updater {
); );
$body[] = $messages[ $type ]; $body[] = $messages[ $type ];
foreach ( $this->update_results[ $type ] as $item ) { foreach ( $this->update_results[ $type ] as $item ) {
if ( ! $item->result || is_wp_error( $item->result ) ) { if ( ! $item->result || is_wp_error( $item->result ) ) {
/* translators: %s: Name of plugin / theme / translation. */ /* translators: %s: Name of plugin / theme / translation. */
@ -1327,10 +1341,12 @@ class WP_Automatic_Updater {
} }
} }
} }
$body[] = ''; $body[] = '';
} }
$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); $site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
if ( $failures ) { if ( $failures ) {
$body[] = trim( $body[] = trim(
__( __(
@ -1367,18 +1383,23 @@ Thanks! -- The WordPress Team"
if ( ! isset( $this->update_results[ $type ] ) ) { if ( ! isset( $this->update_results[ $type ] ) ) {
continue; continue;
} }
foreach ( $this->update_results[ $type ] as $update ) { foreach ( $this->update_results[ $type ] as $update ) {
$body[] = $update->name; $body[] = $update->name;
$body[] = str_repeat( '-', strlen( $update->name ) ); $body[] = str_repeat( '-', strlen( $update->name ) );
foreach ( $update->messages as $message ) { foreach ( $update->messages as $message ) {
$body[] = ' ' . html_entity_decode( str_replace( '…', '...', $message ) ); $body[] = ' ' . html_entity_decode( str_replace( '…', '...', $message ) );
} }
if ( is_wp_error( $update->result ) ) { if ( is_wp_error( $update->result ) ) {
$results = array( 'update' => $update->result ); $results = array( 'update' => $update->result );
// If we rolled back, we want to know an error that occurred then too. // If we rolled back, we want to know an error that occurred then too.
if ( 'rollback_was_required' === $update->result->get_error_code() ) { if ( 'rollback_was_required' === $update->result->get_error_code() ) {
$results = (array) $update->result->get_error_data(); $results = (array) $update->result->get_error_data();
} }
foreach ( $results as $result_type => $result ) { foreach ( $results as $result_type => $result ) {
if ( ! is_wp_error( $result ) ) { if ( ! is_wp_error( $result ) ) {
continue; continue;
@ -1397,6 +1418,7 @@ Thanks! -- The WordPress Team"
} }
} }
} }
$body[] = ''; $body[] = '';
} }
} }

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.8-alpha-50761'; $wp_version = '5.8-alpha-50762';
/** /**
* 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.