Ticket #40503: 40503.2.diff
| File 40503.2.diff, 4.6 KB (added by , 9 years ago) |
|---|
-
src/wp-includes/ms-functions.php
1152 1152 * 'spam', 'deleted', or 'lang_id') the given site status(es) will be 1153 1153 * updated. Otherwise, keys and values will be used to set options for 1154 1154 * the new site. Default empty array. 1155 * @param int $ site_id Optional. Only relevant on multi-network installs.1155 * @param int $network_id Optional. Only relevant on multi-network installs. 1156 1156 * @return int|WP_Error Returns WP_Error object on failure, int $blog_id on success 1157 1157 */ 1158 function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $ site_id = 1 ) {1158 function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $network_id = 1 ) { 1159 1159 $defaults = array( 1160 1160 'public' => 0, 1161 'WPLANG' => get_ site_option('WPLANG' ),1161 'WPLANG' => get_network_option( $network_id, 'WPLANG' ), 1162 1162 ); 1163 1163 $meta = wp_parse_args( $meta, $defaults ); 1164 1164 … … 1174 1174 $path = '/'; 1175 1175 1176 1176 // Check if the domain has been used already. We should return an error message. 1177 if ( domain_exists($domain, $path, $ site_id) )1177 if ( domain_exists($domain, $path, $network_id) ) 1178 1178 return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) ); 1179 1179 1180 1180 if ( ! wp_installing() ) { 1181 1181 wp_installing( true ); 1182 1182 } 1183 1183 1184 if ( ! $blog_id = insert_blog($domain, $path, $ site_id) )1184 if ( ! $blog_id = insert_blog($domain, $path, $network_id) ) 1185 1185 return new WP_Error('insert_blog', __('Could not create site.')); 1186 1186 1187 1187 switch_to_blog($blog_id); … … 1212 1212 * @param int $user_id User ID. 1213 1213 * @param string $domain Site domain. 1214 1214 * @param string $path Site path. 1215 * @param int $ site_id SiteID. Only relevant on multi-network installs.1215 * @param int $network_id Network ID. Only relevant on multi-network installs. 1216 1216 * @param array $meta Meta data. Used to set initial site options. 1217 1217 */ 1218 do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $ site_id, $meta );1218 do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $network_id, $meta ); 1219 1219 1220 1220 wp_cache_set( 'last_changed', microtime(), 'sites' ); 1221 1221 -
tests/phpunit/tests/multisite/site.php
10 10 */ 11 11 class Tests_Multisite_Site extends WP_UnitTestCase { 12 12 protected $suppress = false; 13 protected static $network_ids; 13 14 14 15 function setUp() { 15 16 global $wpdb; … … 23 24 parent::tearDown(); 24 25 } 25 26 27 public static function wpSetUpBeforeClass( $factory ) { 28 self::$network_ids = array( 29 'wordpress.org/' => array( 'domain' => 'wordpress.org', 'path' => '/' ), 30 'make.wordpress.org/' => array( 'domain' => 'make.wordpress.org', 'path' => '/' ), 31 ); 32 33 foreach ( self::$network_ids as &$id ) { 34 $id = $factory->network->create( $id ); 35 } 36 unset( $id ); 37 } 38 39 public static function wpTearDownAfterClass() { 40 global $wpdb; 41 42 foreach( self::$network_ids as $id ) { 43 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) ); 44 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) ); 45 } 46 } 47 26 48 function test_switch_restore_blog() { 27 49 global $_wp_switched_stack, $wpdb; 28 50 … … 981 1003 } 982 1004 983 1005 /** 1006 * @ticket 40503 1007 */ 1008 function test_different_network_language() { 1009 $network = get_network( self::$network_ids['make.wordpress.org/'] ); 1010 1011 add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 ); 1012 update_network_option( self::$network_ids['make.wordpress.org/'], 'WPLANG', 'wibble' ); 1013 remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 ); 1014 1015 // No locale, use default locale. 1016 add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 ); 1017 $blog_id = wpmu_create_blog( $network->domain, '/de-de/', 'New Blog', get_current_user_id(), array(), $network->id ); 1018 remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 ); 1019 1020 $this->assertSame( get_network_option( self::$network_ids['make.wordpress.org/'], 'WPLANG' ), get_blog_option( $blog_id, 'WPLANG' ) ); 1021 } 1022 1023 /** 984 1024 * Allows to set the WPLANG option to any language. 985 1025 * 986 1026 * @param string $value The sanitized option value.