[wp-trac] [WordPress Trac] #52076: Checking anonymous user's exist capability returns inconsistent results across functions.

WordPress Trac noreply at wordpress.org
Thu Mar 4 00:13:10 UTC 2021


#52076: Checking anonymous user's exist capability returns inconsistent results
across functions.
-------------------------------------------------+-------------------------
 Reporter:  peterwilsoncc                        |       Owner:
                                                 |  peterwilsoncc
     Type:  defect (bug)                         |      Status:  closed
 Priority:  normal                               |   Milestone:  5.8
Component:  Role/Capability                      |     Version:
 Severity:  normal                               |  Resolution:  fixed
 Keywords:  early has-patch needs-dev-note has-  |     Focuses:
  unit-tests                                     |
-------------------------------------------------+-------------------------
Changes (by peterwilsoncc):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"50490" 50490]:
 {{{
 #!CommitTicketReference repository="" revision="50490"
 Roles/Caps: Return same result from `current_user_can` and `user_can()`.

 Ensure `current_user_can()` and `user_can()` return the same results for
 logged out users. For core capabilities this changes `user_can( 0, 'exist'
 )` to return `true` rather than `false` in line with `current_user_can(
 'exist' )` for logged out users.

 Convert `current_user_can()` and `current_user_can_for_blog()` to wrapper
 functions ultimately calling `user_can()`.

 Add anonymous user to primitive capability checks as appropriate. Convert
 `Tests_User_Capabilities::test_other_caps_for_all_roles()` to use a data
 provider and add tests to check whether user exists in the database
 (`WP_User::exists()`) as that intentionally differs from the `exist`
 capability.

 Props jjj, johnbillion, peterwilsoncc, SergeyBiryukov, TimothyBlynJacobs.
 Fixes #52076.
 }}}

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


More information about the wp-trac mailing list