As of https://gerrit.wikimedia.org/r/#/c/236043/ the UserRights hook is deprecated in favor of the new UserGroupsChanged hook.
The differences from UserRights to UserGroupsChanged are:
- $user is passed by value, not by reference.
- UserGroupsChanged is called for autopromote-once groups (e.g. 'autopatrolled' on Wikivoyage or 'uploader' on ruwiki).