Multisite: Fix coding standard errors after [43654].

See #41333.


git-svn-id: https://develop.svn.wordpress.org/trunk@43655 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Felix Arntz 2018-09-24 15:22:01 +00:00
parent 1795dbe25a
commit c12a0cf4f3
3 changed files with 21 additions and 16 deletions

View File

@ -83,6 +83,7 @@
</rule> </rule>
<rule ref="WordPress.DB.PreparedSQL.NotPrepared"> <rule ref="WordPress.DB.PreparedSQL.NotPrepared">
<exclude-pattern>/tests/phpunit/tests/admin/includesSchema\.php</exclude-pattern> <exclude-pattern>/tests/phpunit/tests/admin/includesSchema\.php</exclude-pattern>
<exclude-pattern>/tests/phpunit/tests/multisite/site\.php</exclude-pattern>
</rule> </rule>
<!-- Whitelist the I18n functions file from issues identified by the I18n sniff <!-- Whitelist the I18n functions file from issues identified by the I18n sniff

View File

@ -58,7 +58,7 @@ function get_blogaddress_by_id( $blog_id ) {
*/ */
function get_blogaddress_by_name( $blogname ) { function get_blogaddress_by_name( $blogname ) {
if ( is_subdomain_install() ) { if ( is_subdomain_install() ) {
if ( $blogname == 'main' ) { if ( 'main' === $blogname ) {
$blogname = 'www'; $blogname = 'www';
} }
$url = rtrim( network_home_url(), '/' ); $url = rtrim( network_home_url(), '/' );
@ -178,12 +178,12 @@ function get_blog_details( $fields = null, $get_all = true ) {
$blog_id = (int) $blog_id; $blog_id = (int) $blog_id;
$all = $get_all == true ? '' : 'short'; $all = $get_all ? '' : 'short';
$details = wp_cache_get( $blog_id . $all, 'blog-details' ); $details = wp_cache_get( $blog_id . $all, 'blog-details' );
if ( $details ) { if ( $details ) {
if ( ! is_object( $details ) ) { if ( ! is_object( $details ) ) {
if ( $details == -1 ) { if ( -1 == $details ) {
return false; return false;
} else { } else {
// Clear old pre-serialized objects. Cache clients do better with that. // Clear old pre-serialized objects. Cache clients do better with that.
@ -203,7 +203,7 @@ function get_blog_details( $fields = null, $get_all = true ) {
// If short was requested and full cache is set, we can return. // If short was requested and full cache is set, we can return.
if ( $details ) { if ( $details ) {
if ( ! is_object( $details ) ) { if ( ! is_object( $details ) ) {
if ( $details == -1 ) { if ( -1 == $details ) {
return false; return false;
} else { } else {
// Clear old pre-serialized objects. Cache clients do better with that. // Clear old pre-serialized objects. Cache clients do better with that.
@ -1175,10 +1175,12 @@ function wp_uninitialize_site( $site_id ) {
return new WP_Error( 'site_already_uninitialized', __( 'The site appears to be already uninitialized.' ) ); return new WP_Error( 'site_already_uninitialized', __( 'The site appears to be already uninitialized.' ) );
} }
$users = get_users( array( $users = get_users(
'blog_id' => $site->id, array(
'fields' => 'ids', 'blog_id' => $site->id,
) ); 'fields' => 'ids',
)
);
// Remove users from the site. // Remove users from the site.
if ( ! empty( $users ) ) { if ( ! empty( $users ) ) {
@ -1229,7 +1231,7 @@ function wp_uninitialize_site( $site_id ) {
// Get indexed directory from stack // Get indexed directory from stack
$dir = $stack[ $index ]; $dir = $stack[ $index ];
// phpcs:disable Generic.PHP.NoSilencedErrors.Discouraged // phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged
$dh = @opendir( $dir ); $dh = @opendir( $dir );
if ( $dh ) { if ( $dh ) {
$file = @readdir( $dh ); $file = @readdir( $dh );
@ -1259,7 +1261,7 @@ function wp_uninitialize_site( $site_id ) {
} }
} }
// phpcs:enable Generic.PHP.NoSilencedErrors.Discouraged // phpcs:enable WordPress.PHP.NoSilencedErrors.Discouraged
if ( $switch ) { if ( $switch ) {
restore_current_blog(); restore_current_blog();
} }

View File

@ -60,11 +60,13 @@ if ( is_multisite() ) :
unset( $id ); unset( $id );
remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 ); remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 );
self::$uninitialized_site_id = wp_insert_site( array( self::$uninitialized_site_id = wp_insert_site(
'domain' => 'uninitialized.org', array(
'path' => '/', 'domain' => 'uninitialized.org',
'site_id' => self::$network_ids['make.wordpress.org/'], 'path' => '/',
) ); 'site_id' => self::$network_ids['make.wordpress.org/'],
)
);
add_action( 'wp_initialize_site', 'wp_initialize_site', 10, 2 ); add_action( 'wp_initialize_site', 'wp_initialize_site', 10, 2 );
} }
@ -2306,8 +2308,8 @@ if ( is_multisite() ) :
$args $args
) )
); );
$passed_args = $this->wp_initialize_site_args;
$passed_args = $this->wp_initialize_site_args;
$this->wp_initialize_site_args = null; $this->wp_initialize_site_args = null;
$this->assertEqualSetsWithIndex( $args, $passed_args ); $this->assertEqualSetsWithIndex( $args, $passed_args );