Make WordPress Core


Ignore:
Timestamp:
05/12/2020 06:30:03 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Use strict comparison in some wp-admin files.

Props pikamander2, mukesh27, SergeyBiryukov.
Fixes #49239.

File:
1 edited

Legend:

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

    r47597 r47785  
    23472347        $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
    23482348
    2349         if ( $wpdb->get_var( $query ) == $table_name ) {
     2349        if ( $wpdb->get_var( $query ) === $table_name ) {
    23502350                return true;
    23512351        }
    … …  
    23552355
    23562356        // We cannot directly tell that whether this succeeded!
    2357         if ( $wpdb->get_var( $query ) == $table_name ) {
     2357        if ( $wpdb->get_var( $query ) === $table_name ) {
    23582358                return true;
    23592359        }
     2360
    23602361        return false;
    23612362}
    … …  
    23742375function drop_index( $table, $index ) {
    23752376        global $wpdb;
     2377
    23762378        $wpdb->hide_errors();
     2379
    23772380        $wpdb->query( "ALTER TABLE `$table` DROP INDEX `$index`" );
     2381
    23782382        // Now we need to take out all the extra ones we may have created.
    23792383        for ( $i = 0; $i < 25; $i++ ) {
    23802384                $wpdb->query( "ALTER TABLE `$table` DROP INDEX `{$index}_$i`" );
    23812385        }
     2386
    23822387        $wpdb->show_errors();
     2388
    23832389        return true;
    23842390}
    … …  
    23972403function add_clean_index( $table, $index ) {
    23982404        global $wpdb;
     2405
    23992406        drop_index( $table, $index );
    24002407        $wpdb->query( "ALTER TABLE `$table` ADD INDEX ( `$index` )" );
     2408
    24012409        return true;
    24022410}
    … …  
    24162424function maybe_add_column( $table_name, $column_name, $create_ddl ) {
    24172425        global $wpdb;
     2426
    24182427        foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    2419                 if ( $column == $column_name ) {
     2428                if ( $column === $column_name ) {
    24202429                        return true;
    24212430                }
    … …  
    24272436        // We cannot directly tell that whether this succeeded!
    24282437        foreach ( $wpdb->get_col( "DESC $table_name", 0 ) as $column ) {
    2429                 if ( $column == $column_name ) {
     2438                if ( $column === $column_name ) {
    24302439                        return true;
    24312440                }
    24322441        }
     2442
    24332443        return false;
    24342444}
Note: See TracChangeset for help on using the changeset viewer.