Opened 6 years ago
#44634 new defect (bug)
multisite: WP_User compatibility keys inacessible after switch_to_blog
Reported by: | flaviozavan | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.9.7 |
Component: | Users | Keywords: | |
Focuses: | Cc: |
Description
Some WP_User attributes are accessed using $back_compat_keys and get_user_meta:
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-user.php#L121
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-user.php#L312
$back_compat_keys is static and defined when the first WP_User is instantiated.
This process hardcodes $wpdb->prefix into some keys (e.g. user_level), preventing it from functioning correctly after switch_to_blog().
Additionally, unsetting any of these attributes for one user will unset it for all Users, due to $back_compat_keys being static:
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-user.php#L374
Note: See
TracTickets for help on using
tickets.