[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:21:34 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         |   Keywords:
--------------------------+-----------------------------
 set_role in WP_User assumes that if the count of roles is one, then the
 only role present is at index 0; it seems that this is not always the
 case.

 This is easily fixed by using current($this->roles) instead of
 $this->roles[0]; the behaviour is otherwise the same, but it will work
 without triggering a notice and will correctly short circuit the function
 when the only element is at a non-zero index.

 A patch against the current SVN trunk is attached.

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


More information about the wp-trac mailing list