Skip to content

Commit c8d4bc7

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@58994 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 852848a commit c8d4bc7

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

src/wp-admin/includes/upgrade.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ function wp_install_defaults( $user_id ) {
460460
* Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.)
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,
466466
array(
@@ -639,16 +639,16 @@ function wp_new_blog_notification( $blog_title, $blog_url, $user_id, $password )
639639
*
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
}
654654

@@ -700,10 +700,10 @@ function wp_upgrade() {
700700
function upgrade_all() {
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
}
709709

@@ -926,7 +926,7 @@ function upgrade_100() {
926926
foreach ( $allposts as $post ) {
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,
932932
array(
@@ -1099,7 +1099,7 @@ function upgrade_130() {
10991099
// Some versions have multiple duplicate option_name rows with the same values.
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 ) );
11051105
if ( $dupe_ids ) {
@@ -1449,7 +1449,7 @@ function upgrade_230() {
14491449
$links = $wpdb->get_results( "SELECT link_id, link_category FROM $wpdb->links" );
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
}
14551455
if ( ! isset( $link_cat_id_map[ $link->link_category ] ) ) {
@@ -1674,7 +1674,7 @@ function upgrade_290() {
16741674
* Previously, setting depth to 1 would redundantly disable threading,
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 );
16801680
}
@@ -2551,7 +2551,7 @@ function upgrade_network() {
25512551
$upgrade = false;
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;
25572557
}
@@ -3121,7 +3121,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
31213121
$fieldtype_base = strtok( $fieldtype_without_parentheses, ' ' );
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 ) ) {
31273127
if ( array_search( $fieldtype_lowercased, $text_fields, true ) < array_search( $tablefield_type_lowercased, $text_fields, true ) ) {
@@ -3161,7 +3161,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
31613161
// Get the default value from the array.
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}'";
31673167

@@ -3200,7 +3200,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
32003200
'fieldname' => $tableindex->Column_name,
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
}
32063206

@@ -3552,7 +3552,7 @@ function make_site_theme() {
35523552

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 );
35583558
}

0 commit comments

Comments
 (0)