[wp-trac] [WordPress Trac] #19222: Undefined index and incorrect behaviour in WP_User::set_role().

WordPress Trac wp-trac at lists.automattic.com
Thu Nov 10 00:53:17 UTC 2011


#19222: Undefined index and incorrect behaviour in WP_User::set_role().
-----------------------------------------+------------------------------
 Reporter:  elyobo                       |       Owner:
     Type:  defect (bug)                 |      Status:  new
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  General                      |     Version:  3.3
 Severity:  minor                        |  Resolution:
 Keywords:  reporter-feedback has-patch  |
-----------------------------------------+------------------------------

Comment (by elyobo):

 The ordering is in place when I instantiate a new WP_User, e.g.

 {{{
 $id   = 1; // Some user ID
 $role = 'some_role';
 $user = new WP_User($id);
 $user->set_role($role);
 }}}


 We do remove the standard wordpress roles, because we implement our own
 structure, so perhaps this is the cause.  It seems that we should be able
 to do this without breaking core though .

 Regardless of the cause, assuming the existence of array index zero is
 potentially buggy.  In this case things still work, because the check in
 that line will fail (if permissive error reporting is used; ours is
 agressive, so this throws an exception) and it continues through the
 function to set the roles.  In other areas the same logic may cause bigger
 problems.

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


More information about the wp-trac mailing list