- Timestamp:
- 10/19/2023 07:07:13 PM (14 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ms-blogs.php
r55990 r56974 492 492 * @global bool $switched 493 493 * @global string $table_prefix 494 * @global string $wp_template_path 495 * @global string $wp_stylesheet_path 494 496 * @global WP_Object_Cache $wp_object_cache 495 497 * … … 533 535 534 536 $wpdb->set_blog_id( $new_blog_id ); 535 $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); 536 $GLOBALS['blog_id'] = $new_blog_id; 537 $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); 538 $GLOBALS['blog_id'] = $new_blog_id; 539 $GLOBALS['wp_template_path'] = null; 540 $GLOBALS['wp_stylesheet_path'] = null; 537 541 538 542 if ( function_exists( 'wp_cache_switch_to_blog' ) ) { … … 601 605 * @global bool $switched 602 606 * @global string $table_prefix 607 * @global string $wp_template_path 608 * @global string $wp_stylesheet_path 603 609 * @global WP_Object_Cache $wp_object_cache 604 610 * … … 626 632 627 633 $wpdb->set_blog_id( $new_blog_id ); 628 $GLOBALS['blog_id'] = $new_blog_id; 629 $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); 634 $GLOBALS['blog_id'] = $new_blog_id; 635 $GLOBALS['table_prefix'] = $wpdb->get_blog_prefix(); 636 $GLOBALS['wp_template_path'] = null; 637 $GLOBALS['wp_stylesheet_path'] = null; 630 638 631 639 if ( function_exists( 'wp_cache_switch_to_blog' ) ) { -
trunk/tests/phpunit/tests/theme.php
r56727 r56974 1060 1060 1061 1061 /** 1062 * Tests whether a switched site retrieves the correct stylesheet directory. 1063 * 1064 * @ticket 59677 1065 * @group ms-required 1066 * 1067 * @covers ::get_stylesheet_directory 1068 */ 1069 public function test_get_stylesheet_directory_with_switched_site() { 1070 $blog_id = self::factory()->blog->create(); 1071 1072 update_blog_option( $blog_id, 'stylesheet', 'switched_stylesheet' ); 1073 1074 // Prime global storage with the current site's data. 1075 get_stylesheet_directory(); 1076 1077 switch_to_blog( $blog_id ); 1078 $switched_stylesheet = get_stylesheet_directory(); 1079 restore_current_blog(); 1080 1081 $this->assertSame( WP_CONTENT_DIR . '/themes/switched_stylesheet', $switched_stylesheet ); 1082 } 1083 1084 /** 1085 * Tests whether a switched site retrieves the correct template directory. 1086 * 1087 * @ticket 59677 1088 * @group ms-required 1089 * 1090 * @covers ::get_template_directory 1091 */ 1092 public function test_get_template_directory_with_switched_site() { 1093 $blog_id = self::factory()->blog->create(); 1094 1095 update_blog_option( $blog_id, 'template', 'switched_template' ); 1096 1097 // Prime global storage with the current site's data. 1098 get_template_directory(); 1099 1100 switch_to_blog( $blog_id ); 1101 $switched_template = get_template_directory(); 1102 restore_current_blog(); 1103 1104 $this->assertSame( WP_CONTENT_DIR . '/themes/switched_template', $switched_template ); 1105 } 1106 1107 /** 1108 * Tests whether a restored site retrieves the correct stylesheet directory. 1109 * 1110 * @ticket 59677 1111 * @group ms-required 1112 * 1113 * @covers ::get_stylesheet_directory 1114 */ 1115 public function test_get_stylesheet_directory_with_restored_site() { 1116 $blog_id = self::factory()->blog->create(); 1117 1118 update_option( 'stylesheet', 'original_stylesheet' ); 1119 update_blog_option( $blog_id, 'stylesheet', 'switched_stylesheet' ); 1120 1121 $stylesheet = get_stylesheet_directory(); 1122 1123 switch_to_blog( $blog_id ); 1124 1125 // Prime global storage with the restored site's data. 1126 get_stylesheet_directory(); 1127 restore_current_blog(); 1128 1129 $this->assertSame( WP_CONTENT_DIR . '/themes/original_stylesheet', $stylesheet ); 1130 } 1131 1132 /** 1133 * Tests whether a restored site retrieves the correct template directory. 1134 * 1135 * @ticket 59677 1136 * @group ms-required 1137 * 1138 * @covers ::get_template_directory 1139 */ 1140 public function test_get_template_directory_with_restored_site() { 1141 $blog_id = self::factory()->blog->create(); 1142 1143 update_option( 'template', 'original_template' ); 1144 update_blog_option( $blog_id, 'template', 'switched_template' ); 1145 1146 $template = get_template_directory(); 1147 1148 switch_to_blog( $blog_id ); 1149 1150 // Prime global storage with the switched site's data. 1151 get_template_directory(); 1152 restore_current_blog(); 1153 1154 $this->assertSame( WP_CONTENT_DIR . '/themes/original_template', $template ); 1155 } 1156 1157 /** 1062 1158 * Helper function to ensure that a block theme is available and active. 1063 1159 */
Note: See TracChangeset
for help on using the changeset viewer.