Swap out uses of User->isLoggedIn() with ->isRegistered()

Bug: T270450
Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
This commit is contained in:
James D. Forrester 2020-12-17 15:10:11 -08:00 committed by Reedy
parent d79d75d315
commit abdc94a3da
53 changed files with 133 additions and 133 deletions

View file

@ -2501,7 +2501,7 @@ class EditPage implements IEditObject {
*/
protected function updateWatchlist() {
$user = $this->context->getUser();
if ( !$user->isLoggedIn() ) {
if ( !$user->isRegistered() ) {
return;
}
@ -2771,7 +2771,7 @@ class EditPage implements IEditObject {
$ip = User::isIP( $username );
$block = DatabaseBlock::newFromTarget( $user, $user );
$userExists = ( $user && $user->isLoggedIn() );
$userExists = ( $user && $user->isRegistered() );
if ( $userExists && $user->isHidden() &&
!$this->permManager->userHasRight( $this->context->getUser(), 'hideuser' )
) {
@ -2812,7 +2812,7 @@ class EditPage implements IEditObject {
$helpLink = wfExpandUrl( Skin::makeInternalOrExternalUrl(
$this->context->msg( 'helppage' )->inContentLanguage()->text()
) );
if ( $this->context->getUser()->isLoggedIn() ) {
if ( $this->context->getUser()->isRegistered() ) {
$out->wrapWikiMsg(
// Suppress the external link icon, consider the help url an internal one
"<div class=\"mw-newarticletext plainlinks\">\n$1\n</div>",
@ -4351,7 +4351,7 @@ class EditPage implements IEditObject {
];
}
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$checkboxes = array_merge(
$checkboxes,
$this->getCheckboxesDefinitionForWatchlist( $checked['watch'] )

View file

@ -344,7 +344,7 @@ class FileDeleteForm {
);
}
if ( $this->user->isLoggedIn() ) {
if ( $this->user->isRegistered() ) {
$fields[] = new OOUI\FieldLayout(
new OOUI\CheckboxInputWidget( [
'name' => 'wpWatch',

View file

@ -1001,7 +1001,7 @@ class MediaWiki {
$request->getCookie( 'forceHTTPS', '' ) ||
// Avoid checking the user and groups unless it's enabled.
(
$this->context->getUser()->isLoggedIn()
$this->context->getUser()->isRegistered()
&& $this->context->getUser()->requiresHTTPS()
);
}
@ -1010,7 +1010,7 @@ class MediaWiki {
* If the stars are suitably aligned, do an HTTP->HTTPS redirect
*
* Note: Do this after $wgTitle is setup, otherwise the hooks run from
* isLoggedIn() will do all sorts of weird stuff.
* isRegistered() will do all sorts of weird stuff.
*
* @return bool True if the redirect was done. Handling of the request
* should be aborted. False if no redirect was done.

View file

@ -2930,7 +2930,7 @@ class OutputPage extends ContextSource {
[], // modules; not relevant
$this->getLanguage()->getCode(),
$this->getSkin()->getSkinName(),
$this->getUser()->isLoggedIn() ? $this->getUser()->getName() : null,
$this->getUser()->isRegistered() ? $this->getUser()->getName() : null,
null, // version; not relevant
ResourceLoader::inDebugMode(),
null, // only; not relevant
@ -3341,7 +3341,7 @@ class OutputPage extends ContextSource {
'wgRelevantPageName' => $relevantTitle->getPrefixedDBkey(),
'wgRelevantArticleId' => $relevantTitle->getArticleID(),
];
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$vars['wgUserId'] = $user->getId();
$vars['wgUserEditCount'] = $user->getEditCount();
$userReg = $user->getRegistration();
@ -3452,7 +3452,7 @@ class OutputPage extends ContextSource {
$user = $this->getUser();
if ( !$user->isLoggedIn() ) {
if ( !$user->isRegistered() ) {
// Anons have predictable edit tokens
return false;
}

View file

@ -1347,7 +1347,7 @@ class PermissionManager {
);
if (
$user->isLoggedIn() &&
$user->isRegistered() &&
$this->options->get( 'BlockDisablesLogin' ) &&
$user->getBlock()
) {

View file

@ -552,8 +552,8 @@ class ProtectionForm {
'id' => 'mwProtect-reason', 'maxlength' => $maxlength ] ) .
"</td>
</tr>";
# Disallow watching is user is not logged in
if ( $user->isLoggedIn() ) {
# Disallow watching is user is not registered
if ( $user->isRegistered() ) {
$out .= "
<tr>
<td></td>

View file

@ -1585,7 +1585,7 @@ class DerivedPageDataUpdater implements IDBAccessObject, LoggerAwareInterface {
if ( User::isIP( $shortTitle ) ) {
// An anonymous user
$talkPageNotificationManager->setUserHasNewMessages( $recipient, $revRecord );
} elseif ( $recipient->isLoggedIn() ) {
} elseif ( $recipient->isRegistered() ) {
$talkPageNotificationManager->setUserHasNewMessages( $recipient, $revRecord );
} else {
wfDebug( __METHOD__ . ": don't need to notify a nonexistent user" );

View file

@ -135,7 +135,7 @@ class CreditsAction extends FormlessAction {
/** @var User $user */
foreach ( $contributors as $user ) {
$cnt--;
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$link = $this->link( $user );
if ( $this->canShowRealUserName() && $user->getRealName() ) {
$real_names[] = $link;

View file

@ -93,8 +93,8 @@ class RawAction extends FormlessAction {
// vary generated content for open sessions on private wikis
$privateCache = !$permissionManager->isEveryoneAllowed( 'read' ) &&
( $smaxage == 0 || MediaWiki\Session\SessionManager::getGlobalSession()->isPersistent() );
// Don't accidentally cache cookies if user is logged in (T55032)
$privateCache = $privateCache || $this->getUser()->isLoggedIn();
// Don't accidentally cache cookies if user is registered (T55032)
$privateCache = $privateCache || $this->getUser()->isRegistered();
$mode = $privateCache ? 'private' : 'public';
$response->header(
'Cache-Control: ' . $mode . ', s-maxage=' . $smaxage . ', max-age=' . $maxage

View file

@ -244,8 +244,8 @@ class WatchAction extends FormAction {
User $user,
string $expiry = null
) {
// User must be logged in, and either changing the watch state or at least the expiry.
if ( !$user->isLoggedIn() ) {
// User must be registered, and either changing the watch state or at least the expiry.
if ( !$user->isRegistered() ) {
return Status::newGood();
}

View file

@ -1139,7 +1139,7 @@ abstract class ApiBase extends ContextSource {
$this->dieWithError( 'apierror-bad-watchlist-token', 'bad_wltoken' );
}
} else {
if ( !$this->getUser()->isLoggedIn() ) {
if ( !$this->getUser()->isRegistered() ) {
$this->dieWithError( 'watchlistanontext', 'notloggedin' );
}
$this->checkUserRightsAny( 'viewmywatchlist' );

View file

@ -35,7 +35,7 @@ class ApiChangeAuthenticationData extends ApiBase {
}
public function execute() {
if ( !$this->getUser()->isLoggedIn() ) {
if ( !$this->getUser()->isRegistered() ) {
$this->dieWithError( 'apierror-mustbeloggedin-changeauthenticationdata', 'notloggedin' );
}

View file

@ -49,7 +49,7 @@ class ApiLinkAccount extends ApiBase {
}
public function execute() {
if ( !$this->getUser()->isLoggedIn() ) {
if ( !$this->getUser()->isRegistered() ) {
$this->dieWithError( 'apierror-mustbeloggedin-linkaccounts', 'notloggedin' );
}

View file

@ -1565,7 +1565,7 @@ class ApiMain extends ApiBase {
(
$this->getConfig()->get( 'ForceHTTPS' ) ||
$request->getSession()->shouldForceHTTPS() ||
( $this->getUser()->isLoggedIn() &&
( $this->getUser()->isRegistered() &&
$this->getUser()->requiresHTTPS() )
)
) {

View file

@ -298,7 +298,7 @@ class ApiQueryInfo extends ApiQueryBase {
* @param User $user
*/
public static function getWatchToken( User $user ) {
if ( !$user->isLoggedIn() ) {
if ( !$user->isRegistered() ) {
return false;
}
@ -316,7 +316,7 @@ class ApiQueryInfo extends ApiQueryBase {
* @param User $user
*/
public static function getOptionsToken( User $user ) {
if ( !$user->isLoggedIn() ) {
if ( !$user->isRegistered() ) {
return false;
}

View file

@ -34,7 +34,7 @@ class ApiQueryStashImageInfo extends ApiQueryImageInfo {
}
public function execute() {
if ( !$this->getUser()->isLoggedIn() ) {
if ( !$this->getUser()->isRegistered() ) {
$this->dieWithError( 'apierror-mustbeloggedin-uploadstash', 'notloggedin' );
}

View file

@ -46,7 +46,7 @@ class ApiRemoveAuthenticationData extends ApiBase {
}
public function execute() {
if ( !$this->getUser()->isLoggedIn() ) {
if ( !$this->getUser()->isRegistered() ) {
$this->dieWithError( 'apierror-mustbeloggedin-removeauth', 'notloggedin' );
}

View file

@ -560,7 +560,7 @@ class ApiUpload extends ApiBase {
$permission = $this->mUpload->isAllowed( $user );
if ( $permission !== true ) {
if ( !$user->isLoggedIn() ) {
if ( !$user->isRegistered() ) {
$this->dieWithError( [ 'apierror-mustbeloggedin', $this->msg( 'action-upload' ) ] );
}

View file

@ -46,7 +46,7 @@ class ApiWatch extends ApiBase {
public function execute() {
$user = $this->getUser();
if ( !$user->isLoggedIn() ) {
if ( !$user->isRegistered() ) {
$this->dieWithError( 'watchlistanontext', 'notloggedin' );
}

View file

@ -242,7 +242,7 @@ class CategoryMembershipChange {
$username = wfMessage( 'autochange-username' )->inContentLanguage()->text();
$user = User::newFromName( $username );
# User::newFromName() can return false on a badly configured wiki.
if ( $user && !$user->isLoggedIn() ) {
if ( $user && !$user->isRegistered() ) {
$user->addToDatabase();
}

View file

@ -583,7 +583,7 @@ class HTMLForm extends ContextSource {
$tokenOkay = true; // no session check needed
} elseif ( $this->getRequest()->wasPosted() ) {
$editToken = $this->getRequest()->getVal( 'wpEditToken' );
if ( $this->getUser()->isLoggedIn() || $editToken !== null ) {
if ( $this->getUser()->isRegistered() || $editToken !== null ) {
// Session tokens for logged-out users have no security value.
// However, if the user gave one, check it in order to give a nice
// "session expired" error instead of "permission denied" or such.

View file

@ -42,7 +42,7 @@ class AssembleUploadChunksJob extends Job {
$context = RequestContext::getMain();
$user = $context->getUser();
try {
if ( !$user->isLoggedIn() ) {
if ( !$user->isRegistered() ) {
$this->setLastError( "Could not load the author user from session." );
return false;

View file

@ -248,7 +248,7 @@ class DoubleRedirectJob extends Job {
$username = wfMessage( 'double-redirect-fixer' )->inContentLanguage()->text();
self::$user = User::newFromName( $username );
# User::newFromName() can return false on a badly configured wiki.
if ( self::$user && !self::$user->isLoggedIn() ) {
if ( self::$user && !self::$user->isRegistered() ) {
self::$user->addToDatabase();
}
}

View file

@ -44,7 +44,7 @@ class PublishStashedFileJob extends Job {
$context = RequestContext::getMain();
$user = $context->getUser();
try {
if ( !$user->isLoggedIn() ) {
if ( !$user->isRegistered() ) {
$this->setLastError( "Could not load the author user from session." );
return false;

View file

@ -198,7 +198,7 @@ abstract class LanguageConverter implements ILanguageConverter {
// NOTE: For calls from Setup.php, wgUser or the session might not be set yet (T235360)
// Use case: During autocreation, User::isUsableName is called which uses interface
// messages for reserved usernames.
if ( $wgUser && $wgUser->isSafeToLoad() && $wgUser->isLoggedIn() && !$req ) {
if ( $wgUser && $wgUser->isSafeToLoad() && $wgUser->isRegistered() && !$req ) {
$req = $this->getUserVariant( $wgUser );
} elseif ( !$req ) {
$req = $this->getHeaderVariant();
@ -311,7 +311,7 @@ abstract class LanguageConverter implements ILanguageConverter {
return false;
}
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
// Get language variant preference from logged in users
if (
$this->mMainLanguageCode ==

View file

@ -292,7 +292,7 @@ class Article implements Page {
$content = ContentHandler::makeContent( $text, $this->getTitle() );
} else {
$message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
$message = $this->getContext()->getUser()->isRegistered() ? 'noarticletext' : 'noarticletextanon';
$content = new MessageContent( $message, null );
}
@ -1374,7 +1374,7 @@ class Article implements Page {
$ip = User::isIP( $rootPart );
$block = DatabaseBlock::newFromTarget( $user, $user );
if ( $user && $user->isLoggedIn() && $user->isHidden() &&
if ( $user && $user->isRegistered() && $user->isHidden() &&
!$services->getPermissionManager()
->userHasRight( $contextUser, 'hideuser' )
) {
@ -1382,7 +1382,7 @@ class Article implements Page {
// users, pretend like it does not exist at all.
$user = false;
}
if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
if ( !( $user && $user->isRegistered() ) && !$ip ) { # User does not exist
$outputPage->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
[ 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ] );
} elseif (
@ -1420,10 +1420,10 @@ class Article implements Page {
# so be careful showing this. 404 pages must be cheap as they are hard to cache.
$dbCache = ObjectCache::getInstance( 'db-replicated' );
$key = $dbCache->makeKey( 'page-recent-delete', md5( $title->getPrefixedText() ) );
$loggedIn = $contextUser->isLoggedIn();
$isRegistered = $contextUser->isRegistered();
$sessionExists = $this->getContext()->getRequest()->getSession()->isPersistent();
if ( $loggedIn || $dbCache->get( $key ) || $sessionExists ) {
if ( $isRegistered || $dbCache->get( $key ) || $sessionExists ) {
$logTypes = [ 'delete', 'move', 'protect' ];
$dbr = wfGetDB( DB_REPLICA );
@ -1440,7 +1440,7 @@ class Article implements Page {
'lim' => 10,
'conds' => $conds,
'showIfEmpty' => false,
'msgKey' => [ $loggedIn || $sessionExists
'msgKey' => [ $isRegistered || $sessionExists
? 'moveddeleted-notice'
: 'moveddeleted-notice-recent'
]
@ -1494,7 +1494,7 @@ class Article implements Page {
} elseif ( $pm->quickUserCan( 'create', $contextUser, $title ) &&
$pm->quickUserCan( 'edit', $contextUser, $title )
) {
$message = $loggedIn ? 'noarticletext' : 'noarticletextanon';
$message = $isRegistered ? 'noarticletext' : 'noarticletextanon';
$text = wfMessage( $message )->plain();
} else {
$text = wfMessage( 'noarticletext-nopermission' )->plain();
@ -2077,7 +2077,7 @@ class Article implements Page {
]
);
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$fields[] = new OOUI\FieldLayout(
new OOUI\CheckboxInputWidget( [
'name' => 'wpWatch',

View file

@ -69,7 +69,7 @@ class SearchFormWidget {
[
'id' => $isPowerSearch ? 'powersearch' : 'search',
// T151903: default to POST in case JS is disabled
'method' => ( $isPowerSearch && $user->isLoggedIn() ) ? 'post' : 'get',
'method' => ( $isPowerSearch && $user->isRegistered() ) ? 'post' : 'get',
'action' => wfScript(),
]
) .
@ -309,7 +309,7 @@ class SearchFormWidget {
// Stuff to feed SpecialSearch::saveNamespaces()
$user = $this->specialSearch->getUser();
$remember = '';
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$remember = $divider . Xml::checkLabel(
$this->specialSearch->msg( 'powersearch-remember' )->text(),
'nsRemember',

View file

@ -284,7 +284,7 @@ abstract class Skin extends ContextSource {
$services = MediaWikiServices::getInstance();
$permManager = $services->getPermissionManager();
if ( $user->isLoggedIn()
if ( $user->isRegistered()
&& $permManager->userHasAllRights( $user, 'writeapi', 'viewmywatchlist', 'editmywatchlist' )
&& $this->getRelevantTitle()->canExist()
) {
@ -313,7 +313,7 @@ abstract class Skin extends ContextSource {
// User/talk link
$user = $this->getUser();
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$titles[] = $user->getUserPage();
$titles[] = $user->getTalkPage();
}
@ -428,7 +428,7 @@ abstract class Skin extends ContextSource {
if ( $user ) {
$user->load( User::READ_NORMAL );
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$this->mRelevantUser = $user;
}
}
@ -2036,7 +2036,7 @@ abstract class Skin extends ContextSource {
$siteNotice = '';
if ( $this->getHookRunner()->onSiteNoticeBefore( $siteNotice, $this ) ) {
if ( $this->getUser()->isLoggedIn() ) {
if ( $this->getUser()->isRegistered() ) {
$siteNotice = $this->getCachedNotice( 'sitenotice' );
} else {
$anonNotice = $this->getCachedNotice( 'anonnotice' );

View file

@ -49,6 +49,7 @@ class SkinTemplate extends Skin {
public $titletxt;
public $userpage;
public $thisquery;
// TODO: Rename this to $isRegistered (but that's a breaking change)
public $loggedin;
public $username;
public $userpageUrlDetails;
@ -105,7 +106,7 @@ class SkinTemplate extends Skin {
unset( $query['returntoquery'] );
}
$this->thisquery = wfArrayToCgi( $query );
$this->loggedin = $user->isLoggedIn();
$this->loggedin = $user->isRegistered();
$this->username = $user->getName();
if ( $this->loggedin ) {

View file

@ -191,7 +191,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'cssClassSuffix' => 'user-newcomer',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
$performer = $rc->getPerformer();
return $performer && $performer->isLoggedIn() &&
return $performer && $performer->isRegistered() &&
$performer->getExperienceLevel() === 'newcomer';
}
],
@ -202,7 +202,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'cssClassSuffix' => 'user-learner',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
$performer = $rc->getPerformer();
return $performer && $performer->isLoggedIn() &&
return $performer && $performer->isRegistered() &&
$performer->getExperienceLevel() === 'learner';
},
],
@ -213,7 +213,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
'cssClassSuffix' => 'user-experienced',
'isRowApplicableCallable' => function ( $ctx, $rc ) {
$performer = $rc->getPerformer();
return $performer && $performer->isLoggedIn() &&
return $performer && $performer->isRegistered() &&
$performer->getExperienceLevel() === 'experienced';
},
]

View file

@ -265,7 +265,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
*/
if ( !$this->isSignup() && !$this->mPosted && !$this->securityLevel &&
( $this->mReturnTo !== '' || $this->mReturnToQuery !== '' ) &&
$this->getUser()->isLoggedIn()
$this->getUser()->isRegistered()
) {
$this->successfulAction();
return;
@ -569,7 +569,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
// warning header for non-standard workflows (e.g. security reauthentication)
if (
!$this->isSignup() &&
$this->getUser()->isLoggedIn() &&
$this->getUser()->isRegistered() &&
$this->authAction !== AuthManager::ACTION_LOGIN_CONTINUE
) {
$reauthMessage = $this->securityLevel ? 'userlogin-reauth' : 'userlogin-loggedin';
@ -729,9 +729,9 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
protected function getFieldDefinitions() {
global $wgEmailConfirmToEdit;
$isLoggedIn = $this->getUser()->isLoggedIn();
$isRegistered = $this->getUser()->isRegistered();
$continuePart = $this->isContinued() ? 'continue-' : '';
$anotherPart = $isLoggedIn ? 'another-' : '';
$anotherPart = $isRegistered ? 'another-' : '';
// @phan-suppress-next-line PhanUndeclaredMethod
$expiration = $this->getRequest()->getSession()->getProvider()->getRememberUserDuration();
$expirationDays = ceil( $expiration / ( 3600 * 24 ) );
@ -762,7 +762,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
'username' => [
'label-raw' => $this->msg( 'userlogin-yourname' )->escaped() . $usernameHelpLink,
'id' => 'wpName2',
'placeholder-message' => $isLoggedIn ? 'createacct-another-username-ph'
'placeholder-message' => $isRegistered ? 'createacct-another-username-ph'
: 'userlogin-yourname-ph',
],
'mailpassword' => [
@ -838,7 +838,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
],
'realname' => [
'type' => 'text',
'help-message' => $isLoggedIn ? 'createacct-another-realname-tip'
'help-message' => $isRegistered ? 'createacct-another-realname-tip'
: 'prefs-help-realname',
'label-message' => 'createacct-realname',
'cssclass' => 'loginText',
@ -1029,26 +1029,26 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
if ( $this->mLanguage ) {
$linkq .= '&uselang=' . urlencode( $this->mLanguage );
}
$loggedIn = $this->getUser()->isLoggedIn();
$isRegistered = $this->getUser()->isRegistered();
$fieldDefinitions['createOrLogin'] = [
'type' => 'info',
'raw' => true,
'linkQuery' => $linkq,
'default' => function ( $params ) use ( $loggedIn, $linkTitle ) {
'default' => function ( $params ) use ( $isRegistered, $linkTitle ) {
return Html::rawElement( 'div',
[ 'id' => 'mw-createaccount' . ( !$loggedIn ? '-cta' : '' ),
'class' => ( $loggedIn ? 'mw-form-related-link-container' : 'mw-ui-vform-field' ) ],
( $loggedIn ? '' : $this->msg( 'userlogin-noaccount' )->escaped() )
[ 'id' => 'mw-createaccount' . ( !$isRegistered ? '-cta' : '' ),
'class' => ( $isRegistered ? 'mw-form-related-link-container' : 'mw-ui-vform-field' ) ],
( $isRegistered ? '' : $this->msg( 'userlogin-noaccount' )->escaped() )
. Html::element( 'a',
[
'id' => 'mw-createaccount-join' . ( $loggedIn ? '-loggedin' : '' ),
'id' => 'mw-createaccount-join' . ( $isRegistered ? '-loggedin' : '' ),
'href' => $linkTitle->getLocalURL( $params['linkQuery'] ),
'class' => ( $loggedIn ? '' : 'mw-ui-button' ),
'class' => ( $isRegistered ? '' : 'mw-ui-button' ),
'tabindex' => 100,
],
$this->msg(
$loggedIn ? 'userlogin-createanother' : 'userlogin-joinproject'
$isRegistered ? 'userlogin-createanother' : 'userlogin-joinproject'
)->text()
)
);
@ -1190,7 +1190,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
!$this->isSignup()
) {
$user = $this->getUser();
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$formDescriptor['username']['default'] = $user->getName();
} else {
$formDescriptor['username']['default'] =

View file

@ -351,7 +351,7 @@ class SpecialBlock extends FormSpecialPage {
}
# Watchlist their user page? (Only if user is logged in)
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$a['Watch'] = [
'type' => 'check',
'label-message' => 'ipbwatchuser',

View file

@ -185,10 +185,10 @@ class SpecialConfirmEmail extends UnlistedSpecialPage {
$userLatest = $user->getInstanceForUpdate();
$userLatest->confirmEmail();
$userLatest->saveSettings();
$message = $this->getUser()->isLoggedIn() ? 'confirmemail_loggedin' : 'confirmemail_success';
$message = $this->getUser()->isRegistered() ? 'confirmemail_loggedin' : 'confirmemail_success';
$this->getOutput()->addWikiMsg( $message );
if ( !$this->getUser()->isLoggedIn() ) {
if ( !$this->getUser()->isRegistered() ) {
$title = SpecialPage::getTitleFor( 'Userlogin' );
$this->getOutput()->returnToMain( true, $title );
}

View file

@ -83,7 +83,7 @@ class SpecialEmailInvalidate extends UnlistedSpecialPage {
$user->saveSettings();
$this->getOutput()->addWikiMsg( 'confirmemail_invalidated' );
if ( !$this->getUser()->isLoggedIn() ) {
if ( !$this->getUser()->isRegistered() ) {
$this->getOutput()->returnToMain();
}
}

View file

@ -196,7 +196,7 @@ class MovePageForm extends UnlistedSpecialPage {
$this->moveSubpages = $request->getBool( 'wpMovesubpages' );
$this->deleteAndMove = $request->getBool( 'wpDeleteAndMove' );
$this->moveOverShared = $request->getBool( 'wpMoveOverSharedFile' );
$this->watch = $request->getCheck( 'wpWatch' ) && $user->isLoggedIn();
$this->watch = $request->getCheck( 'wpWatch' ) && $user->isRegistered();
if ( $request->getVal( 'action' ) == 'submit' && $request->wasPosted()
&& $user->matchEditToken( $request->getVal( 'wpEditToken' ) )
@ -521,7 +521,7 @@ class MovePageForm extends UnlistedSpecialPage {
}
# Don't allow watching if user is not logged in
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$watchChecked = ( $this->watch || $this->userOptionsLookup->getBoolOption( $user, 'watchmoves' )
|| $user->isWatched( $this->oldTitle ) );
$fields[] = new OOUI\FieldLayout(

View file

@ -89,7 +89,7 @@ class SpecialPasswordReset extends FormSpecialPage {
'label-message' => 'passwordreset-username',
];
if ( $this->getUser()->isLoggedIn() ) {
if ( $this->getUser()->isRegistered() ) {
$a['Username']['default'] = $this->getUser()->getName();
}
}

View file

@ -229,7 +229,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
*/
private function needsWatchlistFeatures(): bool {
return !$this->including()
&& $this->getUser()->isLoggedIn()
&& $this->getUser()->isRegistered()
&& $this->permissionManager->userHasRight( $this->getUser(), 'viewmywatchlist' );
}

View file

@ -752,7 +752,7 @@ class SpecialSearch extends SpecialPage {
$user = $this->getUser();
$request = $this->getRequest();
if ( $user->isLoggedIn() &&
if ( $user->isRegistered() &&
$user->matchEditToken(
$request->getVal( 'nsRemember' ),
'searchnamespace',

View file

@ -139,7 +139,7 @@ class SpecialUpload extends SpecialPage {
$this->mDestWarningAck = $request->getText( 'wpDestFileWarningAck' );
$this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' )
|| $request->getCheck( 'wpUploadIgnoreWarning' );
$this->mWatchthis = $request->getBool( 'wpWatchthis' ) && $this->getUser()->isLoggedIn();
$this->mWatchthis = $request->getBool( 'wpWatchthis' ) && $this->getUser()->isRegistered();
$this->mCopyrightStatus = $request->getText( 'wpUploadCopyStatus' );
$this->mCopyrightSource = $request->getText( 'wpUploadSource' );

View file

@ -68,7 +68,7 @@ class SpecialUserLogin extends LoginSignupSpecialPage {
public function setHeaders() {
// override the page title if we are doing a forced reauthentication
parent::setHeaders();
if ( $this->securityLevel && $this->getUser()->isLoggedIn() ) {
if ( $this->securityLevel && $this->getUser()->isRegistered() ) {
$this->getOutput()->setPageTitle( $this->msg( 'login-security' ) );
}
}

View file

@ -398,7 +398,7 @@ class UploadForm extends HTMLForm {
*/
protected function getOptionsSection() {
$user = $this->getUser();
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$descriptor = [
'Watchthis' => [
'type' => 'check',

View file

@ -73,7 +73,7 @@ class UploadStash {
protected $fileProps = [];
// current user
protected $user, $userId, $isLoggedIn;
protected $user, $userId, $isRegistered;
/**
* Represents a temporary filestore, with metadata in the database.
@ -96,7 +96,7 @@ class UploadStash {
if ( is_object( $this->user ) ) {
$this->userId = $this->user->getId();
$this->isLoggedIn = $this->user->isLoggedIn();
$this->isRegistered = $this->user->isRegistered();
}
}
@ -120,7 +120,7 @@ class UploadStash {
);
}
if ( !$noAuth && !$this->isLoggedIn ) {
if ( !$noAuth && !$this->isRegistered ) {
throw new UploadStashNotLoggedInException(
wfMessage( 'uploadstash-not-logged-in' )
);
@ -277,7 +277,7 @@ class UploadStash {
$stashPath = $storeStatus->value;
// fetch the current user ID
if ( !$this->isLoggedIn ) {
if ( !$this->isRegistered ) {
throw new UploadStashNotLoggedInException(
wfMessage( 'uploadstash-not-logged-in' )
);
@ -338,7 +338,7 @@ class UploadStash {
* @return bool Success
*/
public function clear() {
if ( !$this->isLoggedIn ) {
if ( !$this->isRegistered ) {
throw new UploadStashNotLoggedInException(
wfMessage( 'uploadstash-not-logged-in' )
);
@ -368,7 +368,7 @@ class UploadStash {
* @return bool Success
*/
public function removeFile( $key ) {
if ( !$this->isLoggedIn ) {
if ( !$this->isRegistered ) {
throw new UploadStashNotLoggedInException(
wfMessage( 'uploadstash-not-logged-in' )
);
@ -438,7 +438,7 @@ class UploadStash {
* @return array|false
*/
public function listFiles() {
if ( !$this->isLoggedIn ) {
if ( !$this->isRegistered ) {
throw new UploadStashNotLoggedInException(
wfMessage( 'uploadstash-not-logged-in' )
);

View file

@ -1228,7 +1228,7 @@ class User implements IDBAccessObject, UserIdentity {
// returned here, so just use it if applicable.
$session = $this->getRequest()->getSession();
$user = $session->getUser();
if ( $user->isLoggedIn() ) {
if ( $user->isRegistered() ) {
$this->loadFromUserObject( $user );
// Other code expects these to be set in the session, so set them.
@ -2961,8 +2961,7 @@ class User implements IDBAccessObject, UserIdentity {
}
/**
* Alias of isLoggedIn() with a name that describes its actual functionality. UserIdentity has
* only this new name and not the old isLoggedIn() variant.
* Get whether the user is registered.
*
* @return bool True if user is registered on this wiki, i.e., has a user ID. False if user is
* anonymous or has no local account (which can happen when importing). This is equivalent to
@ -3527,7 +3526,7 @@ class User implements IDBAccessObject, UserIdentity {
* in code along the lines of:
*
* $user = User::newFromName( $name );
* if ( !$user->isLoggedIn() ) {
* if ( !$user->isRegistered() ) {
* $user->addToDatabase();
* }
* // do something with $user...
@ -3537,7 +3536,7 @@ class User implements IDBAccessObject, UserIdentity {
* calling sequence as far as possible.
*
* Note that if the user exists, this function will acquire a write lock,
* so it is still advisable to make the call conditional on isLoggedIn(),
* so it is still advisable to make the call conditional on isRegistered(),
* and to commit the transaction after calling.
*
* @throws MWException
@ -3628,7 +3627,7 @@ class User implements IDBAccessObject, UserIdentity {
* @return bool A block was spread
*/
public function spreadAnyEditBlock() {
if ( $this->isLoggedIn() && $this->getBlock() ) {
if ( $this->isRegistered() && $this->getBlock() ) {
return $this->spreadBlock();
}

View file

@ -116,7 +116,7 @@ class UppercaseTitlesForUnicodeTransition extends Maintenance {
$this->user = User::newSystemUser( $username, [ 'steal' => $steal ] );
if ( !$this->user ) {
$user = User::newFromName( $username );
if ( !$steal && $user && $user->isLoggedIn() ) {
if ( !$steal && $user && $user->isRegistered() ) {
$this->fatalError( "User $username already exists.\n"
. "Use --steal if you really want to steal it from the human who currently owns it."
);

View file

@ -914,7 +914,7 @@ hello
$this->setMwGlobals( 'wgWatchlistExpiry', true );
MWTimestamp::setFakeTime( '20200505120000' );
$user = $this->getTestUser()->getUser();
$this->assertTrue( $user->isLoggedIn() );
$this->assertTrue( $user->isRegistered() );
// Create the EditPage.
$title = Title::newFromText( __METHOD__ );

View file

@ -44,7 +44,7 @@ class TestUser {
// But for now, we just need to create or update the user with the desired properties.
// we particularly need the new password, since we just generated it randomly.
// In core MediaWiki, there is no functionality to delete users, so this is the best we can do.
if ( !$this->user->isLoggedIn() ) {
if ( !$this->user->isRegistered() ) {
// create the user
$this->user = User::createNew(
$this->username, [

View file

@ -64,7 +64,7 @@ class TestUserRegistry {
$testUser = self::$testUsers[$key] ?? false;
if ( !$testUser || !$testUser->getUser()->isLoggedIn() ) {
if ( !$testUser || !$testUser->getUser()->isRegistered() ) {
$id = self::getNextId();
// Hack! If this is the primary sysop account, make the username
// be 'UTSysop', for back-compat, and for the sake of PHPUnit data

View file

@ -97,7 +97,7 @@ class WatchActionTest extends MediaWikiIntegrationTestCase {
->setConstructorArgs( [ $this->watchAction->getContext() ] )
->getMock();
// Change the context to have a logged in user with correct permission.
// Change the context to have a registered user with correct permission.
$testContext->setUser( $this->getUser( true, true, [ 'editmywatchlist' ] ) );
/** @var MockObject|WebRequest $testRequest */
@ -143,10 +143,10 @@ class WatchActionTest extends MediaWikiIntegrationTestCase {
* @covers WatchAction::checkCanExecute()
*/
public function testShowUserLoggedInNoException() {
$loggedInUser = $this->createMock( User::class );
$loggedInUser->method( 'isLoggedIn' )->willReturn( true );
$registeredUser = $this->createMock( User::class );
$registeredUser->method( 'isRegistered' )->willReturn( true );
$testContext = new DerivativeContext( $this->watchAction->getContext() );
$testContext->setUser( $loggedInUser );
$testContext->setUser( $registeredUser );
$watchAction = new WatchAction(
Article::newFromWikiPage( $this->testWikiPage, $testContext ),
$testContext
@ -159,7 +159,7 @@ class WatchActionTest extends MediaWikiIntegrationTestCase {
$exception = $e;
}
$this->assertNull( $exception,
'UserNotLoggedIn exception should not be thrown if user is logged in.' );
'UserNotLoggedIn exception should not be thrown if user is a registered one.' );
}
/**
@ -653,7 +653,7 @@ class WatchActionTest extends MediaWikiIntegrationTestCase {
}
/**
* @param bool $isLoggedIn Whether the user should be "marked" as logged in
* @param bool $isRegistered Whether the user should be "marked" as registered
* @param bool|string $isWatched The value any call to isWatched should return.
* A string value is the expiry that should be used.
* @param array $permissions The permissions of the user
@ -661,13 +661,13 @@ class WatchActionTest extends MediaWikiIntegrationTestCase {
* @throws Exception
*/
private function getUser(
$isLoggedIn = true,
$isRegistered = true,
$isWatched = true,
$permissions = []
) {
$user = $this->createMock( User::class );
$user->method( 'getId' )->willReturn( 42 );
$user->method( 'isLoggedIn' )->willReturn( $isLoggedIn );
$user->method( 'isRegistered' )->willReturn( $isRegistered );
$user->method( 'isWatched' )->willReturn( $isWatched );
// Override WatchedItemStore to think the page is watched, if applicable.

View file

@ -27,30 +27,30 @@ class ApiLogoutTest extends ApiTestCase {
$token = 'invalid token';
$this->doUserLogout( $token, $user );
} finally {
$this->assertTrue( $user->isLoggedIn(), 'not logged out' );
$this->assertTrue( $user->isRegistered(), 'not logged out' );
}
}
public function testUserLogout() {
$user = $this->getTestSysop()->getUser();
$this->assertTrue( $user->isLoggedIn(), 'sanity check' );
$this->assertTrue( $user->isRegistered(), 'sanity check' );
$token = $this->getUserCsrfTokenFromApi( $user );
$this->doUserLogout( $token, $user );
$this->assertFalse( $user->isLoggedIn() );
$this->assertFalse( $user->isRegistered() );
}
public function testUserLogoutWithWebToken() {
global $wgRequest;
$user = $this->getTestSysop()->getUser();
$this->assertTrue( $user->isLoggedIn(), 'sanity check' );
$this->assertTrue( $user->isRegistered(), 'sanity check' );
// Logic copied from SkinTemplate.
$token = $user->getEditToken( 'logoutToken', $wgRequest );
$this->doUserLogout( $token, $user );
$this->assertFalse( $user->isLoggedIn() );
$this->assertFalse( $user->isRegistered() );
}
private function getUserCsrfTokenFromApi( User $user ) {

View file

@ -217,31 +217,31 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiInteg
public static function provideGetAuthenticationRequests() {
$anon = [ 'username' => null ];
$loggedIn = [ 'username' => 'UTSysop' ];
$registered = [ 'username' => 'UTSysop' ];
return [
[ AuthManager::ACTION_LOGIN, $anon, [
new PasswordAuthenticationRequest
] ],
[ AuthManager::ACTION_LOGIN, $loggedIn, [
[ AuthManager::ACTION_LOGIN, $registered, [
new PasswordAuthenticationRequest
] ],
[ AuthManager::ACTION_CREATE, $anon, [] ],
[ AuthManager::ACTION_CREATE, $loggedIn, [
[ AuthManager::ACTION_CREATE, $registered, [
new TemporaryPasswordAuthenticationRequest( 'random' )
] ],
[ AuthManager::ACTION_LINK, $anon, [] ],
[ AuthManager::ACTION_LINK, $loggedIn, [] ],
[ AuthManager::ACTION_LINK, $registered, [] ],
[ AuthManager::ACTION_CHANGE, $anon, [
new TemporaryPasswordAuthenticationRequest( 'random' )
] ],
[ AuthManager::ACTION_CHANGE, $loggedIn, [
[ AuthManager::ACTION_CHANGE, $registered, [
new TemporaryPasswordAuthenticationRequest( 'random' )
] ],
[ AuthManager::ACTION_REMOVE, $anon, [
new TemporaryPasswordAuthenticationRequest
] ],
[ AuthManager::ACTION_REMOVE, $loggedIn, [
[ AuthManager::ACTION_REMOVE, $registered, [
new TemporaryPasswordAuthenticationRequest
] ],
];

View file

@ -84,7 +84,7 @@ class BlockManagerTest extends MediaWikiIntegrationTestCase {
], $options['blockOptions'] ) );
$blockStore->insertBlock( $block );
$user = $options['loggedIn'] ? $this->user : new User();
$user = $options['registered'] ? $this->user : new User();
$user->getRequest()->setCookie( 'BlockID', $blockManager->getCookieValue( $block ) );
$this->assertSame( $expected, (bool)$blockManager->getBlockFromCookieValue(
@ -115,7 +115,7 @@ class BlockManagerTest extends MediaWikiIntegrationTestCase {
], $options['blockOptions'] ) );
$blockStore->insertBlock( $block );
$user = $options['loggedIn'] ? $this->user : new User();
$user = $options['registered'] ? $this->user : new User();
$user->getRequest()->setCookie( 'BlockID', $blockManager->getCookieValue( $block ) );
$response = new FauxResponse;
@ -138,7 +138,7 @@ class BlockManagerTest extends MediaWikiIntegrationTestCase {
'Autoblocking user block' => [
[
'target' => '',
'loggedIn' => true,
'registered' => true,
'blockOptions' => [
'enableAutoblock' => true
],
@ -148,7 +148,7 @@ class BlockManagerTest extends MediaWikiIntegrationTestCase {
'Autoblocking user block for anonymous user' => [
[
'target' => '',
'loggedIn' => false,
'registered' => false,
'blockOptions' => [
'enableAutoblock' => true
],
@ -158,7 +158,7 @@ class BlockManagerTest extends MediaWikiIntegrationTestCase {
'Non-autoblocking user block' => [
[
'target' => '',
'loggedIn' => true,
'registered' => true,
'blockOptions' => [],
],
false,
@ -166,7 +166,7 @@ class BlockManagerTest extends MediaWikiIntegrationTestCase {
'IP block for anonymous user' => [
[
'target' => '127.0.0.1',
'loggedIn' => false,
'registered' => false,
'blockOptions' => [],
],
true,
@ -174,7 +174,7 @@ class BlockManagerTest extends MediaWikiIntegrationTestCase {
'IP block for logged in user' => [
[
'target' => '127.0.0.1',
'loggedIn' => true,
'registered' => true,
'blockOptions' => [],
],
false,
@ -182,7 +182,7 @@ class BlockManagerTest extends MediaWikiIntegrationTestCase {
'IP range block for anonymous user' => [
[
'target' => '127.0.0.0/8',
'loggedIn' => false,
'registered' => false,
'blockOptions' => [],
],
true,

View file

@ -95,7 +95,7 @@ class RequestContextTest extends MediaWikiIntegrationTestCase {
} else {
$this->assertEquals( $oldSessionId, session_id(), "Unchanged PHP session ID." );
}
$this->assertTrue( $context->getUser()->isLoggedIn(), "Correct context user." );
$this->assertTrue( $context->getUser()->isRegistered(), "Correct context user." );
$this->assertEquals( $sinfo['userId'], $context->getUser()->getId(), "Correct context user ID." );
$this->assertEquals(
'UnitTestContextUser',

View file

@ -728,31 +728,31 @@ class UserTest extends MediaWikiIntegrationTestCase {
* @covers User::isAnon
* @covers User::logOut
*/
public function testLoggedIn() {
public function testIsRegistered() {
$user = $this->getMutableTestUser()->getUser();
$this->assertTrue( $user->isRegistered() );
$this->assertTrue( $user->isLoggedIn() );
$this->assertTrue( $user->isLoggedIn() ); // Deprecated wrapper method
$this->assertFalse( $user->isAnon() );
$this->setTemporaryHook( 'UserLogout', function ( &$user ) {
return false;
} );
$user->logout();
$this->assertTrue( $user->isLoggedIn() );
$this->assertTrue( $user->isRegistered() );
$this->removeTemporaryHook( 'UserLogout' );
$user->logout();
$this->assertFalse( $user->isLoggedIn() );
$this->assertFalse( $user->isRegistered() );
// Non-existent users are perceived as anonymous
$user = User::newFromName( 'UTNonexistent' );
$this->assertFalse( $user->isRegistered() );
$this->assertFalse( $user->isLoggedIn() );
$this->assertFalse( $user->isLoggedIn() ); // Deprecated wrapper method
$this->assertTrue( $user->isAnon() );
$user = new User;
$this->assertFalse( $user->isRegistered() );
$this->assertFalse( $user->isLoggedIn() );
$this->assertFalse( $user->isLoggedIn() ); // Deprecated wrapper method
$this->assertTrue( $user->isAnon() );
}
@ -789,7 +789,7 @@ class UserTest extends MediaWikiIntegrationTestCase {
public function testCheckAndSetTouched() {
$user = $this->getMutableTestUser()->getUser();
$user = TestingAccessWrapper::newFromObject( $user );
$this->assertTrue( $user->isLoggedIn() );
$this->assertTrue( $user->isRegistered() );
$touched = $user->getDBTouched();
$this->assertTrue(