Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison where static strings are involved.

This reduces the number of WordPress.PHP.StrictComparisons.LooseComparison issues in half, from 1897 to 890.

Includes minor code layout fixes for better readability.

See #49542.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-automatic-updater.php

    r47550 r47808  
    144144                // Only relax the filesystem checks when the update doesn't include new files.
    145145                $allow_relaxed_file_ownership = false;
    146                 if ( 'core' == $type && isset( $item->new_files ) && ! $item->new_files ) {
     146                if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) {
    147147                        $allow_relaxed_file_ownership = true;
    148148                }
     
    150150                // If we can't do an auto core update, we may still be able to email the user.
    151151                if ( ! $skin->request_filesystem_credentials( false, $context, $allow_relaxed_file_ownership ) || $this->is_vcs_checkout( $context ) ) {
    152                         if ( 'core' == $type ) {
     152                        if ( 'core' === $type ) {
    153153                                $this->send_core_update_notification_email( $item );
    154154                        }
     
    157157
    158158                // Next up, is this an item we can update?
    159                 if ( 'core' == $type ) {
     159                if ( 'core' === $type ) {
    160160                        $update = Core_Upgrader::should_update_to_version( $item->current );
    161161                } else {
     
    185185
    186186                if ( ! $update ) {
    187                         if ( 'core' == $type ) {
     187                        if ( 'core' === $type ) {
    188188                                $this->send_core_update_notification_email( $item );
    189189                        }
     
    192192
    193193                // If it's a core update, are we actually compatible with its requirements?
    194                 if ( 'core' == $type ) {
     194                if ( 'core' === $type ) {
    195195                        global $wpdb;
    196196
     
    345345
    346346                $allow_relaxed_file_ownership = false;
    347                 if ( 'core' == $type && isset( $item->new_files ) && ! $item->new_files ) {
     347                if ( 'core' === $type && isset( $item->new_files ) && ! $item->new_files ) {
    348348                        $allow_relaxed_file_ownership = true;
    349349                }
     
    368368                }
    369369
    370                 if ( 'core' == $type ) {
    371                         if ( is_wp_error( $upgrade_result ) && ( 'up_to_date' == $upgrade_result->get_error_code() || 'locked' == $upgrade_result->get_error_code() ) ) {
    372                                 // These aren't actual errors, treat it as a skipped-update instead to avoid triggering the post-core update failure routines.
     370                if ( 'core' === $type ) {
     371                        if ( is_wp_error( $upgrade_result )
     372                                && ( 'up_to_date' === $upgrade_result->get_error_code()
     373                                        || 'locked' === $upgrade_result->get_error_code() )
     374                        ) {
     375                                // These aren't actual errors, treat it as a skipped-update instead
     376                                // to avoid triggering the post-core update failure routines.
    373377                                return false;
    374378                        }
     
    627631
    628632                $next_user_core_update = get_preferred_from_update_core();
     633
    629634                // If the update transient is empty, use the update we just performed.
    630635                if ( ! $next_user_core_update ) {
    631636                        $next_user_core_update = $core_update;
    632637                }
    633                 $newer_version_available = ( 'upgrade' == $next_user_core_update->response && version_compare( $next_user_core_update->version, $core_update->version, '>' ) );
     638
     639                $newer_version_available = ( 'upgrade' === $next_user_core_update->response && version_compare( $next_user_core_update->version, $core_update->version, '>' ) );
    634640
    635641                /**
     
    716722                                // Don't show this message if there is a newer version available.
    717723                                // Potential for confusion, and also not useful for them to know at this point.
    718                                 if ( 'fail' == $type && ! $newer_version_available ) {
     724                                if ( 'fail' === $type && ! $newer_version_available ) {
    719725                                        $body .= __( 'We tried but were unable to update your site automatically.' ) . ' ';
    720726                                }
     
    779785                $body .= "\n\n" . __( 'The WordPress Team' ) . "\n";
    780786
    781                 if ( 'critical' == $type && is_wp_error( $result ) ) {
     787                if ( 'critical' === $type && is_wp_error( $result ) ) {
    782788                        $body .= "\n***\n\n";
    783789                        /* translators: %s: WordPress version. */
     
    788794                        // If we had a rollback and we're still critical, then the rollback failed too.
    789795                        // Loop through all errors (the main WP_Error, the update result, the rollback result) for code, data, etc.
    790                         if ( 'rollback_was_required' == $result->get_error_code() ) {
     796                        if ( 'rollback_was_required' === $result->get_error_code() ) {
    791797                                $errors = array( $result, $result->get_error_data()->update, $result->get_error_data()->rollback );
    792798                        } else {
     
    798804                                        continue;
    799805                                }
     806
    800807                                $error_code = $error->get_error_code();
    801808                                /* translators: %s: Error code. */
    802809                                $body .= "\n\n" . sprintf( __( 'Error code: %s' ), $error_code );
    803                                 if ( 'rollback_was_required' == $error_code ) {
     810
     811                                if ( 'rollback_was_required' === $error_code ) {
    804812                                        continue;
    805813                                }
     814
    806815                                if ( $error->get_error_message() ) {
    807816                                        $body .= "\n" . $error->get_error_message();
    808817                                }
     818
    809819                                $error_data = $error->get_error_data();
    810820                                if ( $error_data ) {
     
    812822                                }
    813823                        }
     824
    814825                        $body .= "\n";
    815826                }
Note: See TracChangeset for help on using the changeset viewer.