Make WordPress Core

Changeset 58994


Ignore:
Timestamp:
09/05/2024 02:57:46 PM (5 weeks ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison in wp-admin/includes/upgrade.php.

Follow-up to [725], [1575], [1975], [2037], [2966], [3670], [4738], [11958], [12776], [14080], [14485], [32378].

Props faisalahammad, mujuonly, aristath, poena, afercia, SergeyBiryukov.
Fixes #58041, #61607.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/upgrade.php

    r58975 r58994  
    461461             * TODO: Get previous_blog_id.
    462462             */
    463             if ( ! is_super_admin( $user_id ) && 1 != $user_id ) {
     463            if ( ! is_super_admin( $user_id ) && 1 !== $user_id ) {
    464464                $wpdb->delete(
    465465                    $wpdb->usermeta,
     
    640640     * @since 2.1.0
    641641     *
    642      * @global int  $wp_current_db_version The old (current) database version.
    643      * @global int  $wp_db_version         The new database version.
     642     * @global int $wp_current_db_version The old (current) database version.
     643     * @global int $wp_db_version         The new database version.
    644644     */
    645645    function wp_upgrade() {
    646646        global $wp_current_db_version, $wp_db_version;
    647647
    648         $wp_current_db_version = __get_option( 'db_version' );
     648        $wp_current_db_version = (int) __get_option( 'db_version' );
    649649
    650650        // We are up to date. Nothing to do.
    651         if ( $wp_db_version == $wp_current_db_version ) {
     651        if ( $wp_db_version === $wp_current_db_version ) {
    652652            return;
    653653        }
     
    701701    global $wp_current_db_version, $wp_db_version;
    702702
    703     $wp_current_db_version = __get_option( 'db_version' );
     703    $wp_current_db_version = (int) __get_option( 'db_version' );
    704704
    705705    // We are up to date. Nothing to do.
    706     if ( $wp_db_version == $wp_current_db_version ) {
     706    if ( $wp_db_version === $wp_current_db_version ) {
    707707        return;
    708708    }
     
    927927            // Check to see if it's already been imported.
    928928            $cat = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category ) );
    929             if ( ! $cat && 0 != $post->post_category ) { // If there's no result.
     929            if ( ! $cat && 0 !== (int) $post->post_category ) { // If there's no result.
    930930                $wpdb->insert(
    931931                    $wpdb->post2cat,
     
    11001100    $options = $wpdb->get_results( "SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name" );
    11011101    foreach ( $options as $option ) {
    1102         if ( 1 != $option->dupes ) { // Could this be done in the query?
     1102        if ( $option->dupes > 1 ) { // Could this be done in the query?
    11031103            $limit    = $option->dupes - 1;
    11041104            $dupe_ids = $wpdb->get_col( $wpdb->prepare( "SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit ) );
     
    14501450        if ( ! empty( $links ) ) {
    14511451            foreach ( $links as $link ) {
    1452                 if ( 0 == $link->link_category ) {
     1452                if ( 0 === (int) $link->link_category ) {
    14531453                    continue;
    14541454                }
     
    16751675         * but now 2 is the minimum depth to avoid confusion.
    16761676         */
    1677         if ( get_option( 'thread_comments_depth' ) == '1' ) {
     1677        if ( 1 === (int) get_option( 'thread_comments_depth' ) ) {
    16781678            update_option( 'thread_comments_depth', 2 );
    16791679            update_option( 'thread_comments', 0 );
     
    25522552            $indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" );
    25532553            foreach ( $indexes as $index ) {
    2554                 if ( 'domain_path' === $index->Key_name && 'domain' === $index->Column_name && 140 != $index->Sub_part ) {
     2554                if ( 'domain_path' === $index->Key_name && 'domain' === $index->Column_name && '140' !== $index->Sub_part ) {
    25552555                    $upgrade = true;
    25562556                    break;
     
    31223122
    31233123                // Is actual field type different from the field type in query?
    3124                 if ( $tablefield->Type != $fieldtype ) {
     3124                if ( $tablefield->Type !== $fieldtype ) {
    31253125                    $do_change = true;
    31263126                    if ( in_array( $fieldtype_lowercased, $text_fields, true ) && in_array( $tablefield_type_lowercased, $text_fields, true ) ) {
     
    31623162                if ( preg_match( "| DEFAULT '(.*?)'|i", $cfields[ $tablefield_field_lowercased ], $matches ) ) {
    31633163                    $default_value = $matches[1];
    3164                     if ( $tablefield->Default != $default_value ) {
     3164                    if ( $tablefield->Default !== $default_value ) {
    31653165                        // Add a query to change the column's default value
    31663166                        $cqueries[] = "ALTER TABLE {$table} ALTER COLUMN `{$tablefield->Field}` SET DEFAULT '{$default_value}'";
     
    32013201                    'subpart'   => $tableindex->Sub_part,
    32023202                );
    3203                 $index_ary[ $keyname ]['unique']     = ( 0 == $tableindex->Non_unique ) ? true : false;
     3203                $index_ary[ $keyname ]['unique']     = ( '0' === $tableindex->Non_unique ) ? true : false;
    32043204                $index_ary[ $keyname ]['index_type'] = $tableindex->Index_type;
    32053205            }
     
    35533553    // Make the new site theme active.
    35543554    $current_template = __get_option( 'template' );
    3555     if ( WP_DEFAULT_THEME == $current_template ) {
     3555    if ( WP_DEFAULT_THEME === $current_template ) {
    35563556        update_option( 'template', $template );
    35573557        update_option( 'stylesheet', $template );
Note: See TracChangeset for help on using the changeset viewer.