Page MenuHomePhabricator

Deprecate the $mRights field in the User class, replacing it with a cache in PermissionManager.
Closed, ResolvedPublic

Description

The $mRights field in User is used to cache a user's effective rights after loading them. Once code for loading and evaluating the user rights has been moved into PermissionManager (per T218558), it should also be cached inside PermissionManager, not on the User object.

Note: PermissionManager typically only needs to load permissions for a single user, so it may be sufficient to just cache the most recently loaded set of permissions, or the most recent three or five.

Note: $mRights is public, it can't just be removed. Access to it should be emulated via the get() and set() methods. Setting this field directly is used a lot in tests, so hard deprecation is not possible right away. Also, such tests need a new way to fore user permissions. This could be done by overriding the PermissionManager service with a mock, but some kind of convenience method for this would probably be in order. Alternatively, PermissionManager could support programmatic setting of user rights when in test model, or it could be done via TestingAccessWrapper.

Event Timeline

daniel created this task.May 14 2019, 4:05 PM

Change 502484 had a related patch set uploaded (by Daniel Kinzler; owner: Vedmaka Wakalaka):
[mediawiki/core@master] Factors out permissions check from User into PermissionManager service

https://gerrit.wikimedia.org/r/502484

Change 502484 merged by jenkins-bot:
[mediawiki/core@master] Factors out permissions check from User into PermissionManager service

https://gerrit.wikimedia.org/r/502484

daniel closed this task as Resolved.May 29 2019, 7:23 PM
kostajh reopened this task as Open.May 30 2019, 2:15 PM
kostajh added a subscriber: kostajh.

Reverted due to T224607. See the note in T218558#5223836

Change 514474 had a related patch set uploaded (by Daniel Kinzler; owner: Vedmaka Wakalaka):
[mediawiki/core@master] Re-apply: Factors out permissions check from User into PermissionManager service

https://gerrit.wikimedia.org/r/514474

Change 514474 merged by jenkins-bot:
[mediawiki/core@master] Re-apply: Factors out permissions check from User into PermissionManager service

https://gerrit.wikimedia.org/r/514474