[wp-trac] [WordPress Trac] #18934: Multisite issue cleaning up empty capabilities

WordPress Trac wp-trac at lists.automattic.com
Mon Nov 21 20:37:23 UTC 2011


#18934: Multisite issue cleaning up empty capabilities
--------------------------+--------------------
 Reporter:  jammitch      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  3.3
Component:  Multisite     |     Version:  3.2.1
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |
--------------------------+--------------------

Comment (by brianlayman):

 Looking at the code this seems to be a very specific band-aid to WPMU.
 There's a good chance this code could be completely removed because the
 original cause doesn't exist anymore.  I suspect it is there to prevent
 the adding of the person to the blog, not the correction of something that
 already happened.

 This is how I read the code:
 The comment (~Line 120 ./wp-admin/user-edit.php) says:
         // WPMU must delete the user from the current blog if WP added him
 after editing.

 The other conditions are that the current user editing a different user:
         if ( $user_id != $current_user->ID ) {

 And the specific SQL check confirms that we have removed all roles from a
 user who had either had a role, or had never had a capability defined.  If
 we meet that criteria, we delete all capabilities we had for them:
         if ( $delete_role ) // stops users being added to current blog
 when they are edited
                 delete_user_meta( $user_id, $blog_prefix . 'capabilities'
 );

 I think this makes the !is_not_network_admin check look weird too because
 that should be for the $user_id we are dealing with and not the current
 user.


 I bet the right fix is to remove this code all together and confirm that
 when $_POST[ 'role' ] == '', no roles are written out.

 Is it safe to do this:
 if ($_POST[ 'role' ] == '') delete_user_meta( $user_id, $blog_prefix .
 'capabilities' );

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18934#comment:7>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list