From f4b232f74ca98d57d0208ae3a32d7826d4777e9e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 29 May 2023 16:26:22 +0000 Subject: [PATCH] Coding Standards: Use strict comparison in `wp-admin/includes/schema.php`. Follow-up to [12756], [12862], [12880], [13070], [14485], [17928], [18899], [41348], [43628]. Props faisalahammad, aristath, poena, afercia, SergeyBiryukov. Fixes #58042, #58047. See #57839. Built from https://develop.svn.wordpress.org/trunk@55866 git-svn-id: http://core.svn.wordpress.org/trunk@55378 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/schema.php | 30 ++++++++++++++++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 79fb80c205..ceb1011462 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -38,7 +38,7 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) { $charset_collate = $wpdb->get_charset_collate(); - if ( $blog_id && $blog_id != $wpdb->blogid ) { + if ( $blog_id && (int) $blog_id !== $wpdb->blogid ) { $old_blog_id = $wpdb->set_blog_id( $blog_id ); } @@ -983,6 +983,8 @@ endif; function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) { global $wpdb, $current_site, $wp_rewrite; + $network_id = (int) $network_id; + $errors = new WP_Error(); if ( '' === $domain ) { $errors->add( 'empty_domain', __( 'You must provide a domain name.' ) ); @@ -994,11 +996,13 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam // Check for network collision. $network_exists = false; if ( is_multisite() ) { - if ( get_network( (int) $network_id ) ) { + if ( get_network( $network_id ) ) { $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); } } else { - if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) { + if ( $network_id === (int) $wpdb->get_var( + $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) + ) ) { $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); } } @@ -1011,7 +1015,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam return $errors; } - if ( 1 == $network_id ) { + if ( 1 === $network_id ) { $wpdb->insert( $wpdb->site, array( @@ -1040,7 +1044,17 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam ) ); - $site_user = get_userdata( (int) $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", 'admin_user_id', $network_id ) ) ); + $site_user = get_userdata( + (int) $wpdb->get_var( + $wpdb->prepare( + "SELECT meta_value + FROM $wpdb->sitemeta + WHERE meta_key = %s AND site_id = %d", + 'admin_user_id', + $network_id + ) + ) + ); /* * When upgrading from single to multisite, assume the current site will @@ -1102,7 +1116,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam ); if ( is_wp_error( $page ) ) { $errstr = $page->get_error_message(); - } elseif ( 200 == wp_remote_retrieve_response_code( $page ) ) { + } elseif ( 200 === wp_remote_retrieve_response_code( $page ) ) { $vhost_ok = true; } @@ -1168,11 +1182,11 @@ function populate_network_meta( $network_id, array $meta = array() ) { $stylesheet = get_option( 'stylesheet' ); $allowed_themes = array( $stylesheet => true ); - if ( $template != $stylesheet ) { + if ( $template !== $stylesheet ) { $allowed_themes[ $template ] = true; } - if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template ) { + if ( WP_DEFAULT_THEME !== $stylesheet && WP_DEFAULT_THEME !== $template ) { $allowed_themes[ WP_DEFAULT_THEME ] = true; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 9f1b619e6b..c70113f283 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3-alpha-55865'; +$wp_version = '6.3-alpha-55866'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.