Opened 9 months ago

Closed 8 months ago

Last modified 8 months ago

#21786 closed defect (bug) (fixed)

remove_cap can't unset a negative capability

Reported by: johnjamesjacoby Owned by: ryan
Priority: normal Milestone: 3.5
Component: Role/Capability Version:
Severity: minor Keywords: has-patch needs-unit-tests
Cc:

Description

WP_User::add_cap() accepts two parameters -- the second decides if a user does or does not have the capability. I.E.:

$user->add_cap( 'foo', false );

means a user will not have a capability that any role otherwise allows.

WP_User::remove_cap( 'foo' ) incorrectly does an empty() check rather than ! isset(), preventing negative capabilities from being unset from a users individual capabilities array.

This makes it impossible to revert negative capabilities without first making them positive, and then removing them.

See: #9128

Attachments (1)

21786.patch (383 bytes) - added by johnjamesjacoby 9 months ago.

Download all attachments as: .zip

Change History (5)

  • Milestone changed from Awaiting Review to 3.5
  • Severity changed from normal to minor
  • Owner set to ryan
  • Resolution set to fixed
  • Status changed from new to closed

In [21940]:

Allow remove_cap() to unset a negative capability. Props johnjamesjacoby. fixes #21786

Note: See TracTickets for help on using tickets.