Drop AuthPlugin and related code, deprecated in 1.27
[lhc/web/wiklou.git] / includes / user / User.php
index 79889ae..1e3ecf2 100644 (file)
@@ -496,7 +496,6 @@ class User implements IDBAccessObject, UserIdentity {
         * @return string
         */
        protected function getCacheKey( WANObjectCache $cache ) {
-               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
                $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
 
                return $cache->makeGlobalKey( 'user', 'id', $lbFactory->getLocalDomainID(), $this->mId );
@@ -520,7 +519,7 @@ class User implements IDBAccessObject, UserIdentity {
         * @since 1.25
         */
        protected function loadFromCache() {
-               $cache = ObjectCache::getMainWANInstance();
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
                $data = $cache->getWithSetCallback(
                        $this->getCacheKey( $cache ),
                        $cache::TTL_HOUR,
@@ -589,14 +588,15 @@ class User implements IDBAccessObject, UserIdentity {
                $name = self::getCanonicalName( $name, $validate );
                if ( $name === false ) {
                        return false;
-               } else {
-                       // Create unloaded user object
-                       $u = new User;
-                       $u->mName = $name;
-                       $u->mFrom = 'name';
-                       $u->setItemLoaded( 'name' );
-                       return $u;
                }
+
+               // Create unloaded user object
+               $u = new User;
+               $u->mName = $name;
+               $u->mFrom = 'name';
+               $u->setItemLoaded( 'name' );
+
+               return $u;
        }
 
        /**
@@ -1126,12 +1126,12 @@ class User implements IDBAccessObject, UserIdentity {
                }
 
                // Preg yells if you try to give it an empty string
-               if ( $wgInvalidUsernameCharacters !== '' ) {
-                       if ( preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name ) ) {
-                               wfDebugLog( 'username', __METHOD__ .
-                                       ": '$name' invalid due to wgInvalidUsernameCharacters" );
-                               return false;
-                       }
+               if ( $wgInvalidUsernameCharacters !== '' &&
+                       preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name )
+               ) {
+                       wfDebugLog( 'username', __METHOD__ .
+                               ": '$name' invalid due to wgInvalidUsernameCharacters" );
+                       return false;
                }
 
                return self::isUsableName( $name );
@@ -1161,19 +1161,20 @@ class User implements IDBAccessObject, UserIdentity {
                $result = $this->checkPasswordValidity( $password );
                if ( $result->isGood() ) {
                        return true;
-               } else {
-                       $messages = [];
-                       foreach ( $result->getErrorsByType( 'error' ) as $error ) {
-                               $messages[] = $error['message'];
-                       }
-                       foreach ( $result->getErrorsByType( 'warning' ) as $warning ) {
-                               $messages[] = $warning['message'];
-                       }
-                       if ( count( $messages ) === 1 ) {
-                               return $messages[0];
-                       }
-                       return $messages;
                }
+
+               $messages = [];
+               foreach ( $result->getErrorsByType( 'error' ) as $error ) {
+                       $messages[] = $error['message'];
+               }
+               foreach ( $result->getErrorsByType( 'warning' ) as $warning ) {
+                       $messages[] = $warning['message'];
+               }
+               if ( count( $messages ) === 1 ) {
+                       return $messages[0];
+               }
+
+               return $messages;
        }
 
        /**
@@ -1214,12 +1215,14 @@ class User implements IDBAccessObject, UserIdentity {
                if ( $result === false ) {
                        $status->merge( $upp->checkUserPassword( $this, $password ), true );
                        return $status;
-               } elseif ( $result === true ) {
+               }
+
+               if ( $result === true ) {
                        return $status;
-               } else {
-                       $status->error( $result );
-                       return $status; // the isValidPassword hook set a string $result and returned true
                }
+
+               $status->error( $result );
+               return $status; // the isValidPassword hook set a string $result and returned true
        }
 
        /**
@@ -1255,10 +1258,7 @@ class User implements IDBAccessObject, UserIdentity {
                        return false;
                }
 
-               // Reject various classes of invalid names
-               $name = AuthManager::callLegacyAuthPlugin(
-                       'getCanonicalName', [ $t->getText() ], $t->getText()
-               );
+               $name = $t->getText();
 
                switch ( $validate ) {
                        case false:
@@ -1465,12 +1465,13 @@ class User implements IDBAccessObject, UserIdentity {
                        $this->mGroupMemberships = null; // deferred
                        $this->getEditCount(); // revalidation for nulls
                        return true;
-               } else {
-                       // Invalid user_id
-                       $this->mId = 0;
-                       $this->loadDefaults();
-                       return false;
                }
+
+               // Invalid user_id
+               $this->mId = 0;
+               $this->loadDefaults();
+
+               return false;
        }
 
        /**
@@ -1663,7 +1664,6 @@ class User implements IDBAccessObject, UserIdentity {
 
                // update groups in external authentication database
                Hooks::run( 'UserGroupsChanged', [ $this, $toPromote, [], false, false, $oldUGMs, $newUGMs ] );
-               AuthManager::callLegacyAuthPlugin( 'updateExternalDBGroups', [ $this, $toPromote ] );
 
                $logEntry = new ManualLogEntry( 'rights', 'autopromote' );
                $logEntry->setPerformer( $this );
@@ -1923,7 +1923,7 @@ class User implements IDBAccessObject, UserIdentity {
                        $this->mBlockedby = $block->getByName();
                        $this->mBlockreason = $block->mReason;
                        $this->mHideName = $block->mHideName;
-                       $this->mAllowUsertalk = !$block->prevents( 'editownusertalk' );
+                       $this->mAllowUsertalk = $block->isUsertalkEditAllowed();
                } else {
                        $this->mBlock = null;
                        $this->mBlockedby = '';
@@ -1975,10 +1975,10 @@ class User implements IDBAccessObject, UserIdentity {
                                if ( $blockIsValid && $useBlockCookie ) {
                                        // Use the block.
                                        return $tmpBlock;
-                               } else {
-                                       // If the block is not valid, remove the cookie.
-                                       Block::clearCookie( $this->getRequest()->response() );
                                }
+
+                               // If the block is not valid, remove the cookie.
+                               Block::clearCookie( $this->getRequest()->response() );
                        } else {
                                // If the block doesn't exist, remove the cookie.
                                Block::clearCookie( $this->getRequest()->response() );
@@ -1997,11 +1997,9 @@ class User implements IDBAccessObject, UserIdentity {
        public function isDnsBlacklisted( $ip, $checkWhitelist = false ) {
                global $wgEnableDnsBlacklist, $wgDnsBlacklistUrls, $wgProxyWhitelist;
 
-               if ( !$wgEnableDnsBlacklist ) {
-                       return false;
-               }
-
-               if ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) ) {
+               if ( !$wgEnableDnsBlacklist ||
+                       ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) )
+               ) {
                        return false;
                }
 
@@ -2045,9 +2043,9 @@ class User implements IDBAccessObject, UserIdentity {
                                        wfDebugLog( 'dnsblacklist', "Hostname $host is {$ipList[0]}, it's a proxy says $basename!" );
                                        $found = true;
                                        break;
-                               } else {
-                                       wfDebugLog( 'dnsblacklist', "Requested $host, not found in $basename." );
                                }
+
+                               wfDebugLog( 'dnsblacklist', "Requested $host, not found in $basename." );
                        }
                }
 
@@ -2167,11 +2165,9 @@ class User implements IDBAccessObject, UserIdentity {
                        if ( isset( $limits['anon'] ) ) {
                                $keys[$cache->makeKey( 'limiter', $action, 'anon' )] = $limits['anon'];
                        }
-               } else {
+               } elseif ( isset( $limits['user'] ) ) {
                        // limits for logged-in users
-                       if ( isset( $limits['user'] ) ) {
-                               $userLimit = $limits['user'];
-                       }
+                       $userLimit = $limits['user'];
                }
 
                // limits for anons and for newbie logged-in users
@@ -2275,7 +2271,8 @@ class User implements IDBAccessObject, UserIdentity {
         * @return bool True if blocked, false otherwise
         */
        public function isBlocked( $bFromReplica = true ) {
-               return $this->getBlock( $bFromReplica ) instanceof Block && $this->getBlock()->prevents( 'edit' );
+               return $this->getBlock( $bFromReplica ) instanceof Block &&
+                       $this->getBlock()->appliesToRight( 'edit' );
        }
 
        /**
@@ -2305,15 +2302,7 @@ class User implements IDBAccessObject, UserIdentity {
                                // Special handling for a user's own talk page. The block is not aware
                                // of the user, so this must be done here.
                                if ( $title->equals( $this->getTalkPage() ) ) {
-                                       // If the block is sitewide, then whatever is set is what is honored.
-                                       if ( $block->isSitewide() ) {
-                                               $blocked = $block->prevents( 'editownusertalk' );
-                                       } else {
-                                               // If the block is partial, ignore 'editownusertalk' unless
-                                               // there is a restriction on the user talk namespace.
-                                               // TODO: To be implemented with Namespace restrictions
-                                               $blocked = $block->appliesToTitle( $title );
-                                       }
+                                       $blocked = $block->appliesToUsertalk( $title );
                                } else {
                                        $blocked = $block->appliesToTitle( $title );
                                }
@@ -2414,10 +2403,8 @@ class User implements IDBAccessObject, UserIdentity {
                if ( $this->mLocked !== null ) {
                        return $this->mLocked;
                }
-               // Avoid PHP 7.1 warning of passing $this by reference
-               $user = $this;
-               $authUser = AuthManager::callLegacyAuthPlugin( 'getUserInstance', [ &$user ], null );
-               $this->mLocked = $authUser && $authUser->isLocked();
+               // Reset for hook
+               $this->mLocked = false;
                Hooks::run( 'UserIsLocked', [ $this, &$this->mLocked ] );
                return $this->mLocked;
        }
@@ -2433,10 +2420,8 @@ class User implements IDBAccessObject, UserIdentity {
                }
                $this->getBlockedStatus();
                if ( !$this->mHideName ) {
-                       // Avoid PHP 7.1 warning of passing $this by reference
-                       $user = $this;
-                       $authUser = AuthManager::callLegacyAuthPlugin( 'getUserInstance', [ &$user ], null );
-                       $this->mHideName = $authUser && $authUser->isHidden();
+                       // Reset for hook
+                       $this->mHideName = false;
                        Hooks::run( 'UserIsHidden', [ $this, &$this->mHideName ] );
                }
                return (bool)$this->mHideName;
@@ -2450,7 +2435,9 @@ class User implements IDBAccessObject, UserIdentity {
                if ( $this->mId === null && $this->mName !== null && self::isIP( $this->mName ) ) {
                        // Special case, we know the user is anonymous
                        return 0;
-               } elseif ( !$this->isItemLoaded( 'id' ) ) {
+               }
+
+               if ( !$this->isItemLoaded( 'id' ) ) {
                        // Don't load if this was initialized from an ID
                        $this->load();
                }
@@ -2475,14 +2462,15 @@ class User implements IDBAccessObject, UserIdentity {
                if ( $this->isItemLoaded( 'name', 'only' ) ) {
                        // Special case optimisation
                        return $this->mName;
-               } else {
-                       $this->load();
-                       if ( $this->mName === false ) {
-                               // Clean up IPs
-                               $this->mName = IP::sanitizeIP( $this->getRequest()->getIP() );
-                       }
-                       return $this->mName;
                }
+
+               $this->load();
+               if ( $this->mName === false ) {
+                       // Clean up IPs
+                       $this->mName = IP::sanitizeIP( $this->getRequest()->getIP() );
+               }
+
+               return $this->mName;
        }
 
        /**
@@ -2628,7 +2616,9 @@ class User implements IDBAccessObject, UserIdentity {
                $talks = [];
                if ( !Hooks::run( 'UserRetrieveNewTalks', [ &$user, &$talks ] ) ) {
                        return $talks;
-               } elseif ( !$this->getNewtalk() ) {
+               }
+
+               if ( !$this->getNewtalk() ) {
                        return [];
                }
                $utp = $this->getTalkPage();
@@ -2641,7 +2631,7 @@ class User implements IDBAccessObject, UserIdentity {
                $rev = $timestamp ? Revision::loadFromTimestamp( $dbr, $utp, $timestamp ) : null;
                return [
                        [
-                               'wiki' => WikiMap::getWikiIdFromDomain( WikiMap::getCurrentWikiDomain() ),
+                               'wiki' => WikiMap::getWikiIdFromDbDomain( WikiMap::getCurrentWikiDbDomain() ),
                                'link' => $utp->getLocalURL(),
                                'rev' => $rev
                        ]
@@ -2656,19 +2646,19 @@ class User implements IDBAccessObject, UserIdentity {
        public function getNewMessageRevisionId() {
                $newMessageRevisionId = null;
                $newMessageLinks = $this->getNewMessageLinks();
-               if ( $newMessageLinks ) {
-                       // Note: getNewMessageLinks() never returns more than a single link
-                       // and it is always for the same wiki, but we double-check here in
-                       // case that changes some time in the future.
-                       if ( count( $newMessageLinks ) === 1
-                               && WikiMap::isCurrentWikiId( $newMessageLinks[0]['wiki'] )
-                               && $newMessageLinks[0]['rev']
-                       ) {
-                               /** @var Revision $newMessageRevision */
-                               $newMessageRevision = $newMessageLinks[0]['rev'];
-                               $newMessageRevisionId = $newMessageRevision->getId();
-                       }
+
+               // Note: getNewMessageLinks() never returns more than a single link
+               // and it is always for the same wiki, but we double-check here in
+               // case that changes some time in the future.
+               if ( $newMessageLinks && count( $newMessageLinks ) === 1
+                       && WikiMap::isCurrentWikiId( $newMessageLinks[0]['wiki'] )
+                       && $newMessageLinks[0]['rev']
+               ) {
+                       /** @var Revision $newMessageRevision */
+                       $newMessageRevision = $newMessageLinks[0]['rev'];
+                       $newMessageRevisionId = $newMessageRevision->getId();
                }
+
                return $newMessageRevisionId;
        }
 
@@ -2708,10 +2698,10 @@ class User implements IDBAccessObject, UserIdentity {
                if ( $dbw->affectedRows() ) {
                        wfDebug( __METHOD__ . ": set on ($field, $id)\n" );
                        return true;
-               } else {
-                       wfDebug( __METHOD__ . " already set ($field, $id)\n" );
-                       return false;
                }
+
+               wfDebug( __METHOD__ . " already set ($field, $id)\n" );
+               return false;
        }
 
        /**
@@ -2728,10 +2718,10 @@ class User implements IDBAccessObject, UserIdentity {
                if ( $dbw->affectedRows() ) {
                        wfDebug( __METHOD__ . ": killed on ($field, $id)\n" );
                        return true;
-               } else {
-                       wfDebug( __METHOD__ . ": already gone ($field, $id)\n" );
-                       return false;
                }
+
+               wfDebug( __METHOD__ . ": already gone ($field, $id)\n" );
+               return false;
        }
 
        /**
@@ -2798,7 +2788,7 @@ class User implements IDBAccessObject, UserIdentity {
                        return;
                }
 
-               $cache = ObjectCache::getMainWANInstance();
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
                $key = $this->getCacheKey( $cache );
                if ( $mode === 'refresh' ) {
                        $cache->delete( $key, 1 );
@@ -3012,25 +3002,30 @@ class User implements IDBAccessObject, UserIdentity {
                if ( !$this->mToken ) {
                        // The user doesn't have a token, return null to indicate that.
                        return null;
-               } elseif ( $this->mToken === self::INVALID_TOKEN ) {
+               }
+
+               if ( $this->mToken === self::INVALID_TOKEN ) {
                        // We return a random value here so existing token checks are very
                        // likely to fail.
                        return MWCryptRand::generateHex( self::TOKEN_LENGTH );
-               } elseif ( $wgAuthenticationTokenVersion === null ) {
+               }
+
+               if ( $wgAuthenticationTokenVersion === null ) {
                        // $wgAuthenticationTokenVersion not in use, so return the raw secret
                        return $this->mToken;
-               } else {
-                       // $wgAuthenticationTokenVersion in use, so hmac it.
-                       $ret = MWCryptHash::hmac( $wgAuthenticationTokenVersion, $this->mToken, false );
-
-                       // The raw hash can be overly long. Shorten it up.
-                       $len = max( 32, self::TOKEN_LENGTH );
-                       if ( strlen( $ret ) < $len ) {
-                               // Should never happen, even md5 is 128 bits
-                               throw new \UnexpectedValueException( 'Hmac returned less than 128 bits' );
-                       }
-                       return substr( $ret, -$len );
                }
+
+               // $wgAuthenticationTokenVersion in use, so hmac it.
+               $ret = MWCryptHash::hmac( $wgAuthenticationTokenVersion, $this->mToken, false );
+
+               // The raw hash can be overly long. Shorten it up.
+               $len = max( 32, self::TOKEN_LENGTH );
+               if ( strlen( $ret ) < $len ) {
+                       // Should never happen, even md5 is 128 bits
+                       throw new \UnexpectedValueException( 'Hmac returned less than 128 bits' );
+               }
+
+               return substr( $ret, -$len );
        }
 
        /**
@@ -3119,19 +3114,17 @@ class User implements IDBAccessObject, UserIdentity {
                $type = $oldaddr != '' ? 'changed' : 'set';
                $notificationResult = null;
 
-               if ( $wgEmailAuthentication ) {
+               if ( $wgEmailAuthentication && $type === 'changed' ) {
                        // Send the user an email notifying the user of the change in registered
                        // email address on their previous email address
-                       if ( $type == 'changed' ) {
-                               $change = $str != '' ? 'changed' : 'removed';
-                               $notificationResult = $this->sendMail(
-                                       wfMessage( 'notificationemail_subject_' . $change )->text(),
-                                       wfMessage( 'notificationemail_body_' . $change,
-                                               $this->getRequest()->getIP(),
-                                               $this->getName(),
-                                               $str )->text()
-                               );
-                       }
+                       $change = $str != '' ? 'changed' : 'removed';
+                       $notificationResult = $this->sendMail(
+                               wfMessage( 'notificationemail_subject_' . $change )->text(),
+                               wfMessage( 'notificationemail_body_' . $change,
+                                       $this->getRequest()->getIP(),
+                                       $this->getName(),
+                                       $str )->text()
+                       );
                }
 
                $this->setEmail( $str );
@@ -3201,9 +3194,9 @@ class User implements IDBAccessObject, UserIdentity {
 
                if ( array_key_exists( $oname, $this->mOptions ) ) {
                        return $this->mOptions[$oname];
-               } else {
-                       return $defaultOverride;
                }
+
+               return $defaultOverride;
        }
 
        /**
@@ -3533,14 +3526,15 @@ class User implements IDBAccessObject, UserIdentity {
                global $wgSecureLogin;
                if ( !$wgSecureLogin ) {
                        return false;
-               } else {
-                       $https = $this->getBoolOption( 'prefershttps' );
-                       Hooks::run( 'UserRequiresHTTPS', [ $this, &$https ] );
-                       if ( $https ) {
-                               $https = wfCanIPUseHTTPS( $this->getRequest()->getIP() );
-                       }
-                       return $https;
                }
+
+               $https = $this->getBoolOption( 'prefershttps' );
+               Hooks::run( 'UserRequiresHTTPS', [ $this, &$https ] );
+               if ( $https ) {
+                       $https = wfCanIPUseHTTPS( $this->getRequest()->getIP() );
+               }
+
+               return $https;
        }
 
        /**
@@ -3922,10 +3916,10 @@ class User implements IDBAccessObject, UserIdentity {
        public function getRequest() {
                if ( $this->mRequest ) {
                        return $this->mRequest;
-               } else {
-                       global $wgRequest;
-                       return $wgRequest;
                }
+
+               global $wgRequest;
+               return $wgRequest;
        }
 
        /**
@@ -4097,19 +4091,18 @@ class User implements IDBAccessObject, UserIdentity {
                $learnerRegistration = wfTimestamp( TS_MW, $now - $wgLearnerMemberSince * 86400 );
                $experiencedRegistration = wfTimestamp( TS_MW, $now - $wgExperiencedUserMemberSince * 86400 );
 
-               if (
-                       $editCount < $wgLearnerEdits ||
-                       $registration > $learnerRegistration
-               ) {
+               if ( $editCount < $wgLearnerEdits ||
+               $registration > $learnerRegistration ) {
                        return 'newcomer';
-               } elseif (
-                       $editCount > $wgExperiencedUserEdits &&
+               }
+
+               if ( $editCount > $wgExperiencedUserEdits &&
                        $registration <= $experiencedRegistration
                ) {
                        return 'experienced';
-               } else {
-                       return 'learner';
                }
+
+               return 'learner';
        }
 
        /**
@@ -4517,7 +4510,7 @@ class User implements IDBAccessObject, UserIdentity {
         */
        public function isBlockedFromCreateAccount() {
                $this->getBlockedStatus();
-               if ( $this->mBlock && $this->mBlock->prevents( 'createaccount' ) ) {
+               if ( $this->mBlock && $this->mBlock->appliesToRight( 'createaccount' ) ) {
                        return $this->mBlock;
                }
 
@@ -4528,7 +4521,7 @@ class User implements IDBAccessObject, UserIdentity {
                        $this->mBlockedFromCreateAccount = Block::newFromTarget( null, $this->getRequest()->getIP() );
                }
                return $this->mBlockedFromCreateAccount instanceof Block
-                       && $this->mBlockedFromCreateAccount->prevents( 'createaccount' )
+                       && $this->mBlockedFromCreateAccount->appliesToRight( 'createaccount' )
                        ? $this->mBlockedFromCreateAccount
                        : false;
        }
@@ -4539,7 +4532,7 @@ class User implements IDBAccessObject, UserIdentity {
         */
        public function isBlockedFromEmailuser() {
                $this->getBlockedStatus();
-               return $this->mBlock && $this->mBlock->prevents( 'sendemail' );
+               return $this->mBlock && $this->mBlock->appliesToRight( 'sendemail' );
        }
 
        /**
@@ -4550,7 +4543,7 @@ class User implements IDBAccessObject, UserIdentity {
         */
        public function isBlockedFromUpload() {
                $this->getBlockedStatus();
-               return $this->mBlock && $this->mBlock->prevents( 'upload' );
+               return $this->mBlock && $this->mBlock->appliesToRight( 'upload' );
        }
 
        /**
@@ -4723,22 +4716,38 @@ class User implements IDBAccessObject, UserIdentity {
 
                if ( $type == 'created' || $type === false ) {
                        $message = 'confirmemail_body';
+                       $type = 'created';
                } elseif ( $type === true ) {
                        $message = 'confirmemail_body_changed';
+                       $type = 'changed';
                } else {
                        // Messages: confirmemail_body_changed, confirmemail_body_set
                        $message = 'confirmemail_body_' . $type;
                }
 
-               return $this->sendMail( wfMessage( 'confirmemail_subject' )->text(),
-                       wfMessage( $message,
+               $mail = [
+                       'subject' => wfMessage( 'confirmemail_subject' )->text(),
+                       'body' => wfMessage( $message,
                                $this->getRequest()->getIP(),
                                $this->getName(),
                                $url,
                                $wgLang->userTimeAndDate( $expiration, $this ),
                                $invalidateURL,
                                $wgLang->userDate( $expiration, $this ),
-                               $wgLang->userTime( $expiration, $this ) )->text() );
+                               $wgLang->userTime( $expiration, $this ) )->text(),
+                       'from' => null,
+                       'replyTo' => null,
+               ];
+               $info = [
+                       'type' => $type,
+                       'ip' => $this->getRequest()->getIP(),
+                       'confirmURL' => $url,
+                       'invalidateURL' => $invalidateURL,
+                       'expiration' => $expiration
+               ];
+
+               Hooks::run( 'UserSendConfirmationMail', [ $this, &$mail, $info ] );
+               return $this->sendMail( $mail['subject'], $mail['body'], $mail['from'], $mail['replyTo'] );
        }
 
        /**
@@ -4749,7 +4758,7 @@ class User implements IDBAccessObject, UserIdentity {
         * @param string $body Message body
         * @param User|null $from Optional sending user; if unspecified, default
         *   $wgPasswordSender will be used.
-        * @param string|null $replyto Reply-To address
+        * @param MailAddress|null $replyto Reply-To address
         * @return Status
         */
        public function sendMail( $subject, $body, $from = null, $replyto = null ) {
@@ -4926,9 +4935,9 @@ class User implements IDBAccessObject, UserIdentity {
                                return false;
                        }
                        return true;
-               } else {
-                       return $confirmed;
                }
+
+               return $confirmed;
        }
 
        /**
@@ -5105,31 +5114,6 @@ class User implements IDBAccessObject, UserIdentity {
                return true;
        }
 
-       /**
-        * Get the localized descriptive name for a group, if it exists
-        * @deprecated since 1.29 Use UserGroupMembership::getGroupName instead
-        *
-        * @param string $group Internal group name
-        * @return string Localized descriptive group name
-        */
-       public static function getGroupName( $group ) {
-               wfDeprecated( __METHOD__, '1.29' );
-               return UserGroupMembership::getGroupName( $group );
-       }
-
-       /**
-        * Get the localized descriptive name for a member of a group, if it exists
-        * @deprecated since 1.29 Use UserGroupMembership::getGroupMemberName instead
-        *
-        * @param string $group Internal group name
-        * @param string $username Username for gender (since 1.19)
-        * @return string Localized name for group member
-        */
-       public static function getGroupMember( $group, $username = '#' ) {
-               wfDeprecated( __METHOD__, '1.29' );
-               return UserGroupMembership::getGroupMemberName( $group, $username );
-       }
-
        /**
         * Return the set of defined explicit groups.
         * The implicit groups (by default *, 'user' and 'autoconfirmed')
@@ -5204,9 +5188,9 @@ class User implements IDBAccessObject, UserIdentity {
                if ( $title ) {
                        return MediaWikiServices::getInstance()
                                ->getLinkRenderer()->makeLink( $title, $text );
-               } else {
-                       return htmlspecialchars( $text );
                }
+
+               return htmlspecialchars( $text );
        }
 
        /**
@@ -5229,9 +5213,9 @@ class User implements IDBAccessObject, UserIdentity {
                if ( $title ) {
                        $page = $title->getFullText();
                        return "[[$page|$text]]";
-               } else {
-                       return $text;
                }
+
+               return $text;
        }
 
        /**
@@ -5700,9 +5684,9 @@ class User implements IDBAccessObject, UserIdentity {
 
                if ( $groups ) {
                        return Status::newFatal( 'badaccess-groups', $wgLang->commaList( $groups ), count( $groups ) );
-               } else {
-                       return Status::newFatal( 'badaccess-group0' );
                }
+
+               return Status::newFatal( 'badaccess-group0' );
        }
 
        /**