Ticket #37865: 37865.3.diff
| File 37865.3.diff, 4.0 KB (added by , 9 years ago) |
|---|
-
src/wp-includes/ms-functions.php
109 109 * The count is cached and updated twice daily. This is not a live count. 110 110 * 111 111 * @since MU 1.0 112 * @since 3.7.0 The $network_id parameter has been deprecated. 113 * @since 4.8.0 The $network_id parameter is now being used. 112 114 * 113 * @param int $network_id Deprecated, not supported.114 * @return int 115 * @param int|null $network_id ID of the network. Default is the current network. 116 * @return int Number of active sites on the network. 115 117 */ 116 function get_blog_count( $network_id = 0 ) { 117 if ( func_num_args() ) 118 _deprecated_argument( __FUNCTION__, '3.1.0' ); 119 120 return get_site_option( 'blog_count' ); 118 function get_blog_count( $network_id = null ) { 119 return get_network_option( $network_id, 'blog_count' ); 121 120 } 122 121 123 122 /** -
tests/phpunit/tests/multisite/network.php
12 12 protected $plugin_hook_count = 0; 13 13 protected $suppress = false; 14 14 15 protected static $different_network_id; 16 protected static $different_site_ids = array(); 17 15 18 function setUp() { 16 19 global $wpdb; 17 20 parent::setUp(); … … 25 28 parent::tearDown(); 26 29 } 27 30 31 public static function wpSetUpBeforeClass( $factory ) { 32 self::$different_network_id = $factory->network->create( array( 'domain' => 'wordpress.org', 'path' => '/' ) ); 33 34 $sites = array( 35 array( 'domain' => 'wordpress.org', 'path' => '/', 'site_id' => self::$different_network_id ), 36 array( 'domain' => 'wordpress.org', 'path' => '/foo/', 'site_id' => self::$different_network_id ), 37 array( 'domain' => 'wordpress.org', 'path' => '/bar/', 'site_id' => self::$different_network_id ), 38 ); 39 40 foreach ( $sites as $site ) { 41 self::$different_site_ids[] = $factory->blog->create( $site ); 42 } 43 } 44 45 public static function wpTearDownAfterClass() { 46 global $wpdb; 47 48 foreach( self::$different_site_ids as $id ) { 49 wpmu_delete_blog( $id, true ); 50 } 51 52 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", self::$different_network_id ) ); 53 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", self::$different_network_id ) ); 54 55 wp_update_network_site_counts(); 56 } 57 28 58 /** 29 59 * By default, only one network exists and has a network ID of 1. 30 60 */ … … 66 96 function test_get_main_network_id_after_network_delete() { 67 97 global $wpdb, $current_site; 68 98 69 $id = self::factory()->network->create(); 70 $temp_id = $id + 1; 99 $temp_id = self::$different_network_id + 1; 71 100 72 $current_site->id = (int) $id;101 $current_site->id = (int) self::$different_network_id; 73 102 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->site} SET id=%d WHERE id=1", $temp_id ) ); 74 103 $main_network_id = get_main_network_id(); 75 104 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->site} SET id=1 WHERE id=%d", $temp_id ) ); 76 105 77 $this->assertEquals( $id, $main_network_id );106 $this->assertEquals( self::$different_network_id, $main_network_id ); 78 107 } 79 108 80 109 function test_get_main_network_id_filtered() { … … 157 186 } 158 187 159 188 /** 189 * @ticket 37865 190 */ 191 public function test_get_blog_count_on_different_network() { 192 global $current_site, $wpdb; 193 194 // switch_to_network()... 195 $orig_network_id = $current_site->id; 196 $orig_wpdb_network_id = $wpdb->siteid; 197 $current_site->id = self::$different_network_id; 198 $wpdb->siteid = self::$different_network_id; 199 wp_update_network_site_counts(); 200 $current_site->id = $orig_network_id; 201 $wpdb->siteid = $orig_wpdb_network_id; 202 203 $site_count = get_blog_count( self::$different_network_id ); 204 205 $this->assertSame( count( self::$different_site_ids ), $site_count ); 206 } 207 208 /** 160 209 * @ticket 22917 161 210 */ 162 211 function test_enable_live_network_user_counts_filter() {