Make WordPress Core

Changeset 56974

Timestamp:
10/19/2023 07:07:13 PM (9 months ago)
Author:
flixos90
Message:

Multisite: Ensure that switching sites resets the current theme directory globals.

The globals introduced in [56635] to cache the current theme directories in memory were not considering switching sites in a multisite network. This changeset addresses the bug including test coverage.

Props codex-m, jeremyfelt.
Fixes #59677.
See #18298.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-blogs.php

    r55990 r56974  
    492492 * @global bool            $switched
    493493 * @global string          $table_prefix
     494
     495
    494496 * @global WP_Object_Cache $wp_object_cache
    495497 *
     
    533535
    534536    $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;
    537541
    538542    if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
     
    601605 * @global bool            $switched
    602606 * @global string          $table_prefix
     607
     608
    603609 * @global WP_Object_Cache $wp_object_cache
    604610 *
     
    626632
    627633    $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;
    630638
    631639    if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
  • trunk/tests/phpunit/tests/theme.php

    r56727 r56974  
    10601060
    10611061    /**
     1062
     1063
     1064
     1065
     1066
     1067
     1068
     1069
     1070
     1071
     1072
     1073
     1074
     1075
     1076
     1077
     1078
     1079
     1080
     1081
     1082
     1083
     1084
     1085
     1086
     1087
     1088
     1089
     1090
     1091
     1092
     1093
     1094
     1095
     1096
     1097
     1098
     1099
     1100
     1101
     1102
     1103
     1104
     1105
     1106
     1107
     1108
     1109
     1110
     1111
     1112
     1113
     1114
     1115
     1116
     1117
     1118
     1119
     1120
     1121
     1122
     1123
     1124
     1125
     1126
     1127
     1128
     1129
     1130
     1131
     1132
     1133
     1134
     1135
     1136
     1137
     1138
     1139
     1140
     1141
     1142
     1143
     1144
     1145
     1146
     1147
     1148
     1149
     1150
     1151
     1152
     1153
     1154
     1155
     1156
     1157
    10621158     * Helper function to ensure that a block theme is available and active.
    10631159     */
Note: See TracChangeset for help on using the changeset viewer.