[wp-trac] [WordPress Trac] #47678: Modernize/simplify current_user_can()

WordPress Trac noreply at wordpress.org
Thu Jul 11 06:43:10 UTC 2019


#47678: Modernize/simplify current_user_can()
---------------------------------------------+-----------------------------
 Reporter:  jrf                              |       Owner:  jrf
     Type:  defect (bug)                     |      Status:  assigned
 Priority:  normal                           |   Milestone:  5.3
Component:  Role/Capability                  |     Version:  trunk
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  coding-
                                             |  standards
---------------------------------------------+-----------------------------
Changes (by pento):

 * keywords:  has-patch 2nd-opinion has-unit-tests => has-patch has-unit-
     tests commit
 * owner:  (none) => jrf
 * status:  new => assigned
 * milestone:  Awaiting Review => 5.3


Comment:

 Interestingly, this has existed since
 [https://core.trac.wordpress.org/browser/trunk/wp-
 includes/capabilities.php?rev=2703 nearly the beginning of time].

 I suspect that it originated as a copy/pasta bug when the feature was
 being written: the similar behaviour in `WP_User::has_cap()` was copied
 and modified to suit the desired behaviour of `current_user_can()`.
 Unfortunately, I haven't been able to locate any relevant discussion
 around it, so it seems it just slipped under the radar at the time.

 Due to the giant "here be dragons" signs all over the roles/capabilities
 code, it's not really surprising that redundant code like this has quietly
 existed the entire time, given that it works.

 I'm cool with both removing the redundant code, and introducing the spread
 operator here.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47678#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list