Remove the user rights link from the Contributions/DeletedContributions pages for anonymous users, as you can't set user rights on anonymous users.
Change-Id: I21551aa6c9ec14c5cda997f2c78fe7434df6d371
# Add a link to change user rights for privileged users
$userrightsPage = new UserrightsPage();
$userrightsPage->setContext( $this->getContext() );
- if ( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
+ if ( $userrightsPage->userCanChangeRights( $target ) ) {
$tools[] = Linker::linkKnown(
SpecialPage::getTitleFor( 'Userrights', $username ),
$this->msg( 'sp-contributions-userrights' )->escaped()
# Add a link to change user rights for privileged users
$userrightsPage = new UserrightsPage();
$userrightsPage->setContext( $this->getContext() );
- if( $id !== null && $userrightsPage->userCanChangeRights( User::newFromId( $id ) ) ) {
+ if( $userrightsPage->userCanChangeRights( $userObj ) ) {
$tools[] = Linker::linkKnown(
SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ),
$this->msg( 'sp-contributions-userrights' )->escaped()
public function userCanChangeRights( $user, $checkIfSelf = true ) {
$available = $this->changeableGroups();
+ if ( $user->getId() == 0 ) {
+ return false;
+ }
return !empty( $available['add'] )
|| !empty( $available['remove'] )
|| ( ( $this->isself || !$checkIfSelf ) &&