Ticket #23016: 23016.patch
| File 23016.patch, 2.0 KB (added by johnjamesjacoby, 5 months ago) |
|---|
-
wp-includes/capabilities.php
95 95 */ 96 96 function _init () { 97 97 global $wpdb, $wp_user_roles; 98 98 99 $this->role_key = $wpdb->prefix . 'user_roles'; 100 99 101 if ( ! empty( $wp_user_roles ) ) { 100 $this->roles = $wp_user_roles;102 $this->roles = $wp_user_roles; 101 103 $this->use_db = false; 102 104 } else { 103 105 $this->roles = get_option( $this->role_key ); 104 106 } 105 107 106 if ( empty( $this->roles ) ) 107 return; 108 do_action_ref_array( 'wp_roles_init', array( &$this ) ); 108 109 109 $this->role_objects = array();110 $this->role_names = array();111 foreach ( array_keys( $this->roles ) as $role ) {112 $this->role_objects[$role] = new WP_Role( $role, $this->roles[$role]['capabilities'] );113 $this->role_names[$role] = $this->roles[$role]['name'];114 }115 }116 117 /**118 * Reinitialize the object119 *120 * Recreates the role objects. This is typically called only by switch_to_blog()121 * after switching wpdb to a new blog ID.122 *123 * @since 3.5.0124 * @access public125 */126 function reinit() {127 // There is no need to reinit if using the wp_user_roles global.128 if ( ! $this->use_db )129 return;130 131 global $wpdb, $wp_user_roles;132 133 // Duplicated from _init() to avoid an extra function call.134 $this->role_key = $wpdb->prefix . 'user_roles';135 $this->roles = get_option( $this->role_key );136 110 if ( empty( $this->roles ) ) 137 111 return; 138 112 139 113 $this->role_objects = array(); 140 $this->role_names =array();114 $this->role_names = array(); 141 115 foreach ( array_keys( $this->roles ) as $role ) { 142 116 $this->role_objects[$role] = new WP_Role( $role, $this->roles[$role]['capabilities'] ); 143 $this->role_names[$role] = $this->roles[$role]['name'];117 $this->role_names[$role] = $this->roles[$role]['name']; 144 118 } 145 119 } 146 120 -
wp-includes/ms-blogs.php
542 542 } 543 543 544 544 if ( did_action( 'init' ) ) { 545 $wp_roles ->reinit();545 $wp_roles = new WP_Roles(); 546 546 $current_user = wp_get_current_user(); 547 547 $current_user->for_blog( $new_blog ); 548 548 }
