Make WordPress Core


Ignore:
Timestamp:
05/16/2020 06:40:52 PM (4 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/upgrade.php

    r47786 r47808  
    863863    if ( $posts ) {
    864864        foreach ( $posts as $post ) {
    865             if ( '' == $post->post_name ) {
     865            if ( '' === $post->post_name ) {
    866866                $newtitle = sanitize_title( $post->post_title );
    867867                $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_name = %s WHERE ID = %d", $newtitle, $post->ID ) );
     
    872872    $categories = $wpdb->get_results( "SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories" );
    873873    foreach ( $categories as $category ) {
    874         if ( '' == $category->category_nicename ) {
     874        if ( '' === $category->category_nicename ) {
    875875            $newtitle = sanitize_title( $category->cat_name );
    876876            $wpdb->update( $wpdb->categories, array( 'category_nicename' => $newtitle ), array( 'cat_ID' => $category->cat_ID ) );
     
    948948    $users = $wpdb->get_results( "SELECT ID, user_nickname, user_nicename FROM $wpdb->users" );
    949949    foreach ( $users as $user ) {
    950         if ( '' == $user->user_nicename ) {
     950        if ( '' === $user->user_nicename ) {
    951951            $newname = sanitize_title( $user->user_nickname );
    952952            $wpdb->update( $wpdb->users, array( 'user_nicename' => $newname ), array( 'ID' => $user->ID ) );
     
    983983     * <michel_v> I just slapped myself silly for not thinking about it earlier.
    984984     */
    985     $got_gmt_fields = ! ( $wpdb->get_var( "SELECT MAX(post_date_gmt) FROM $wpdb->posts" ) == '0000-00-00 00:00:00' );
     985    $got_gmt_fields = ( '0000-00-00 00:00:00' !== $wpdb->get_var( "SELECT MAX(post_date_gmt) FROM $wpdb->posts" ) );
    986986
    987987    if ( ! $got_gmt_fields ) {
     
    12271227                $type   = 'post';
    12281228
    1229                 if ( 'static' == $status ) {
     1229                if ( 'static' === $status ) {
    12301230                    $status = 'publish';
    12311231                    $type   = 'page';
    1232                 } elseif ( 'attachment' == $status ) {
     1232                } elseif ( 'attachment' === $status ) {
    12331233                    $status = 'inherit';
    12341234                    $type   = 'attachment';
     
    13581358        $term_id  = (int) $post->category_id;
    13591359        $taxonomy = 'category';
    1360         if ( ! empty( $post->rel_type ) && 'tag' == $post->rel_type ) {
     1360        if ( ! empty( $post->rel_type ) && 'tag' === $post->rel_type ) {
    13611361            $taxonomy = 'tag';
    13621362        }
     
    14761476    $terms = $wpdb->get_results( "SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy" );
    14771477    foreach ( (array) $terms as $term ) {
    1478         if ( ( 'post_tag' == $term->taxonomy ) || ( 'category' == $term->taxonomy ) ) {
     1478        if ( 'post_tag' === $term->taxonomy || 'category' === $term->taxonomy ) {
    14791479            $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND post_status = 'publish' AND post_type = 'post' AND term_taxonomy_id = %d", $term->term_taxonomy_id ) );
    14801480        } else {
     
    18161816
    18171817    if ( $wp_current_db_version < 20080 ) {
    1818         if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) {
     1818        if ( 'yes' === $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) {
    18191819            $uninstall_plugins = get_option( 'uninstall_plugins' );
    18201820            delete_option( 'uninstall_plugins' );
     
    22922292            $indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" );
    22932293            foreach ( $indexes as $index ) {
    2294                 if ( 'domain_path' == $index->Key_name && 'domain' == $index->Column_name && 140 != $index->Sub_part ) {
     2294                if ( 'domain_path' === $index->Key_name && 'domain' === $index->Column_name && 140 != $index->Sub_part ) {
    22952295                    $upgrade = true;
    22962296                    break;
     
    25022502    if ( $options ) {
    25032503        foreach ( $options as $option ) {
    2504             if ( 'siteurl' == $option->option_name || 'home' == $option->option_name || 'category_base' == $option->option_name ) {
     2504            if ( 'siteurl' === $option->option_name || 'home' === $option->option_name || 'category_base' === $option->option_name ) {
    25052505                $option->option_value = untrailingslashit( $option->option_value );
    25062506            }
     
    25362536    $option = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s", $setting ) );
    25372537
    2538     if ( 'home' === $setting && '' == $option ) {
     2538    if ( 'home' === $setting && '' === $option ) {
    25392539        return __get_option( 'siteurl' );
    25402540    }
    25412541
    2542     if ( 'siteurl' === $setting || 'home' === $setting || 'category_base' === $setting || 'tag_base' === $setting ) {
     2542    if ( in_array( $setting, array( 'siteurl', 'home', 'category_base', 'tag_base' ), true ) ) {
    25432543        $option = untrailingslashit( $option );
    25442544    }
     
    29162916                // For each column in the index.
    29172917                foreach ( $index_data['columns'] as $column_data ) {
    2918                     if ( '' != $index_columns ) {
     2918                    if ( '' !== $index_columns ) {
    29192919                        $index_columns .= ',';
    29202920                    }
     
    32713271
    32723272    foreach ( (array) $plugins as $plugin ) {
    3273         if ( basename( $plugin ) == 'widgets.php' ) {
     3273        if ( 'widgets.php' === basename( $plugin ) ) {
    32743274            array_splice( $plugins, array_search( $plugin, $plugins, true ), 1 );
    32753275            update_option( 'active_plugins', $plugins );
Note: See TracChangeset for help on using the changeset viewer.