[Bug report] WP_Roles
-
Dear WordPress team,
I am learning your WP_Role-System by try and error and found following pretty annoying:
If adding a role, you check if it is set in the
$wp_roles->roles
– but if you remove it, you check$wp_roles->role_objects
although you just update$wp_roles->roles
into the database.
Finally you get a mess: I try to activate Roles during the activation-hook, but he finds Roles with the same name in the$wp_roles->roles
. If I write$wp_roles->remove_role($name);
in the line above the$wp_roles->add_role($name)
it cannot find the name in the$wp_roles->role_objects
and therefore doesn’t unset the role in$wp_roles->roles
.I changed following:
wp-includes/capabilities.php
FROM:function remove_role( $role ) { if ( ! isset( $this->role_objects[$role] )) return; unset( $this->role_objects[$role] ); unset( $this->role_names[$role] ); unset( $this->roles[$role] ); if ( $this->use_db ) update_option( $this->role_key, $this->roles ); }
TO:
function remove_role( $role ) { if ( ! isset( $this->roles[$role] )) return; unset( $this->role_objects[$role] ); unset( $this->role_names[$role] ); unset( $this->roles[$role] ); if ( $this->use_db ) update_option( $this->role_key, $this->roles ); }
It’s only the line
if ( ! isset( $this->roles[$role] ))
set toroles
instead ofrole_objects
.I personally think this is a mistake in the logic, cause I would check both times the same variable and it’s no bit change.
I’d be happy if you see it my way and change it, otherwise I will be changing future releases too (but I don’t like messing with the core).Thanks,
P.S.: I just didn’t know, where to report bugs to, SORRY!
- The topic ‘[Bug report] WP_Roles’ is closed to new replies.