Ticket #33620: 33620.2.diff
File 33620.2.diff, 3.0 KB (added by , 9 years ago) |
---|
-
src/wp-includes/ms-functions.php
1317 1317 * @param string $blog_title The title of the new site. 1318 1318 */ 1319 1319 function install_blog( $blog_id, $blog_title = '' ) { 1320 global $wpdb, $wp_roles ;1320 global $wpdb, $wp_roles, $current_site; 1321 1321 1322 1322 // Cast for security 1323 1323 $blog_id = (int) $blog_id; … … 1339 1339 // populate_roles() clears previous role definitions so we start over. 1340 1340 $wp_roles = new WP_Roles(); 1341 1341 1342 $ url= untrailingslashit( $url );1342 $siteurl = $home = untrailingslashit( $url ); 1343 1343 1344 update_option( 'siteurl', $url ); 1345 update_option( 'home', $url ); 1344 if ( ! is_subdomain_install() ) { 1345 1346 if ( 'https' === parse_url( get_network_option( 'siteurl' ), PHP_URL_SCHEME ) ) { 1347 $siteurl = set_url_scheme( $siteurl, 'https' ); 1348 } 1349 if ( 'https' === parse_url( get_home_url( $current_site->blog_id ), PHP_URL_SCHEME ) ) { 1350 $home = set_url_scheme( $home, 'https' ); 1351 } 1352 1353 } 1354 1355 update_option( 'siteurl', $siteurl ); 1356 update_option( 'home', $home ); 1346 1357 1347 1358 if ( get_site_option( 'ms_files_rewriting' ) ) 1348 1359 update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" ); -
tests/phpunit/tests/multisite/site.php
1000 1000 $blogaddress = get_blogaddress_by_id( 42 ); 1001 1001 $this->assertEquals( '', $blogaddress ); 1002 1002 } 1003 1004 /** 1005 * @ticket 33620 1006 * @dataProvider data_new_blog_url_schemes 1007 */ 1008 function test_new_blog_url_schemes( $home_scheme, $siteurl_scheme, $force_ssl_admin ) { 1009 $current_site = get_current_site(); 1010 1011 $home = get_option( 'home' ); 1012 $siteurl = get_site_option( 'siteurl' ); 1013 $admin = force_ssl_admin(); 1014 1015 // Setup: 1016 update_option( 'home', set_url_scheme( $home, $home_scheme ) ); 1017 update_site_option( 'siteurl', set_url_scheme( $siteurl, $siteurl_scheme ) ); 1018 force_ssl_admin( $force_ssl_admin ); 1019 1020 // Install: 1021 $new = wpmu_create_blog( $current_site->domain, '/new-blog/', 'New Blog', get_current_user_id() ); 1022 1023 // Reset: 1024 update_option( 'home', $home ); 1025 update_site_option( 'siteurl', $siteurl ); 1026 force_ssl_admin( $admin ); 1027 1028 // Assert: 1029 $this->assertNotWPError( $new ); 1030 $this->assertSame( $home_scheme, parse_url( get_blog_option( $new, 'home' ), PHP_URL_SCHEME ) ); 1031 $this->assertSame( $siteurl_scheme, parse_url( get_blog_option( $new, 'siteurl' ), PHP_URL_SCHEME ) ); 1032 } 1033 1034 function data_new_blog_url_schemes() { 1035 return array( 1036 array( 1037 'https', 1038 'https', 1039 false, 1040 ), 1041 array( 1042 'http', 1043 'https', 1044 false, 1045 ), 1046 array( 1047 'https', 1048 'http', 1049 false, 1050 ), 1051 array( 1052 'http', 1053 'http', 1054 false, 1055 ), 1056 array( 1057 'http', 1058 'http', 1059 true, 1060 ), 1061 ); 1062 } 1063 1003 1064 } 1004 1065 1005 1066 endif;