Go to the documentation of this file.
30 use Wikimedia\ScopedCallback;
39 define(
'EDIT_TOKEN_SUFFIX', Token::SUFFIX );
104 'mEmailAuthenticated',
106 'mEmailTokenExpires',
164 'move-categorypages',
165 'move-rootuserpages',
169 'override-export-depth',
191 'userrights-interwiki',
328 return (
string)$this->
getName();
354 $this->mLoadedItems ===
true || $this->mFrom !==
'session';
365 if ( $this->mLoadedItems ===
true ) {
371 $this->mLoadedItems =
true;
372 $this->queryFlagsUsed =
$flags;
377 ->warning(
'User::loadFromSession called before the end of Setup.php', [
378 'exception' =>
new Exception(
'User::loadFromSession called before the end of Setup.php' ),
381 $this->mLoadedItems = $oldLoadedItems;
385 switch ( $this->mFrom ) {
391 if (
wfGetLB()->hasOrMadeRecentMasterChanges() ) {
392 $flags |= self::READ_LATEST;
393 $this->queryFlagsUsed =
$flags;
412 Hooks::run(
'UserLoadAfterLoadFromSession', [ $this ] );
415 throw new UnexpectedValueException(
416 "Unrecognised value for User->mFrom: \"{$this->mFrom}\"" );
426 if ( $this->mId == 0 ) {
444 $this->mLoadedItems =
true;
445 $this->queryFlagsUsed =
$flags;
455 public static function purge( $wikiId, $userId ) {
457 $key =
$cache->makeGlobalKey(
'user',
'id', $wikiId, $userId );
467 return $cache->makeGlobalKey(
'user',
'id',
wfWikiID(), $this->mId );
476 $id = $this->
getId();
478 return $id ? [ $this->
getCacheKey( $cache ) ] : [];
489 $data =
$cache->getWithSetCallback(
494 wfDebug(
"User: cache miss for user {$this->mId}\n" );
501 foreach ( self::$mCacheVars
as $name ) {
502 $data[
$name] = $this->$name;
509 foreach ( $this->mGroupMemberships
as $ugm ) {
510 if ( $ugm->getExpiry() ) {
511 $secondsUntilExpiry =
wfTimestamp( TS_UNIX, $ugm->getExpiry() ) - time();
512 if ( $secondsUntilExpiry > 0 && $secondsUntilExpiry < $ttl ) {
513 $ttl = $secondsUntilExpiry;
520 [
'pcTTL' => $cache::TTL_PROC_LONG,
'version' =>
self::VERSION ]
524 foreach ( self::$mCacheVars
as $name ) {
525 $this->$name = $data[
$name];
551 if ( $validate ===
true ) {
555 if (
$name ===
false ) {
562 $u->setItemLoaded(
'name' );
577 $u->setItemLoaded(
'id' );
593 $db = (
$flags & self::READ_LATEST ) == self::READ_LATEST
597 $id = $db->selectField(
601 'user_email_token' => md5(
$code ),
602 'user_email_token_expires > ' . $db->addQuotes( $db->timestamp() ),
618 $user->mFrom =
'session';
639 $user->loadFromRow( $row, $data );
680 'validate' =>
'valid',
686 if (
$name ===
false ) {
691 $row =
$dbr->selectRow(
693 self::selectFields(),
694 [
'user_name' =>
$name ],
700 $row = $dbw->selectRow(
702 self::selectFields(),
703 [
'user_name' =>
$name ],
719 if (
$user->mEmail ||
$user->mToken !== self::INVALID_TOKEN ||
720 AuthManager::singleton()->userCanAuthenticate(
$name )
727 AuthManager::singleton()->revokeAccessForUser(
$name );
729 $user->invalidateEmail();
731 $user->saveSettings();
732 SessionManager::singleton()->preventSessionsForUser(
$user->getName() );
745 public static function whoIs( $id ) {
767 if ( is_null( $nt ) ) {
772 if ( !(
$flags & self::READ_LATEST ) && isset( self::$idCacheByName[
$name] ) ) {
773 return self::$idCacheByName[
$name];
782 [
'user_name' => $nt->getText() ],
787 if (
$s ===
false ) {
795 if (
count( self::$idCacheByName ) > 1000 ) {
796 self::$idCacheByName = [];
806 self::$idCacheByName = [];
826 return preg_match(
'/^\d{1,3}\.\d{1,3}\.\d{1,3}\.(?:xxx|\d{1,3})$/',
$name )
855 || self::isIP(
$name )
856 || strpos(
$name,
'/' ) !==
false
866 if ( is_null( $parsed )
867 || $parsed->getNamespace()
868 || strcmp(
$name, $parsed->getPrefixedText() ) ) {
874 $unicodeBlacklist =
'/[' .
875 '\x{0080}-\x{009f}' . # iso-8859-1 control chars
876 '\x{00a0}' . # non-breaking space
877 '\x{2000}-\x{200f}' . # various whitespace
878 '\x{2028}-\x{202f}' . # breaks
and control chars
879 '\x{3000}' . # ideographic space
880 '\x{e000}-\x{f8ff}' . #
private use
882 if ( preg_match( $unicodeBlacklist,
$name ) ) {
903 if ( !self::isValidUserName(
$name ) ) {
907 static $reservedUsernames =
false;
908 if ( !$reservedUsernames ) {
910 Hooks::run(
'UserGetReservedNames', [ &$reservedUsernames ] );
914 foreach ( $reservedUsernames
as $reserved ) {
915 if ( substr( $reserved, 0, 4 ) ==
'msg:' ) {
916 $reserved =
wfMessage( substr( $reserved, 4 ) )->inContentLanguage()->text();
918 if ( $reserved ==
$name ) {
936 if ( $groups === [] ) {
940 $groups = array_unique( (
array)$groups );
941 $limit = min( 5000, $limit );
943 $conds = [
'ug_group' => $groups ];
944 if ( $after !==
null ) {
945 $conds[] =
'ug_user > ' . (int)$after;
949 $ids =
$dbr->selectFieldValues(
956 'ORDER BY' =>
'ug_user',
981 if ( strlen(
$name ) > 235 ) {
983 ": '$name' invalid due to length" );
991 ": '$name' invalid due to wgInvalidUsernameCharacters" );
1022 foreach (
$result->getErrorsByType(
'error' )
as $error ) {
1025 foreach (
$result->getErrorsByType(
'warning' )
as $warning ) {
1069 $status->merge( $upp->checkUserPassword( $this, $password ) );
1071 } elseif (
$result ===
true ) {
1097 # Reject names containing '#'; these will be cleaned up
1098 # with title normalisation, but then it's too late to
1100 if ( strpos(
$name,
'#' ) !==
false ) {
1106 $t = ( $validate !==
false ) ?
1109 if ( is_null(
$t ) ||
$t->getNamespace() !==
NS_USER ||
$t->isExternal() ) {
1114 $name = AuthManager::callLegacyAuthPlugin(
1115 'getCanonicalName', [
$t->getText() ],
$t->getText()
1118 switch ( $validate ) {
1122 if ( !self::isValidUserName(
$name ) ) {
1127 if ( !self::isUsableName(
$name ) ) {
1132 if ( !self::isCreatableName(
$name ) ) {
1137 throw new InvalidArgumentException(
1138 'Invalid parameter value for $validate in ' . __METHOD__ );
1164 $this->mName =
$name;
1165 $this->mRealName =
'';
1167 $this->mOptionOverrides =
null;
1168 $this->mOptionsLoaded =
false;
1170 $loggedOut = $this->mRequest && !defined(
'MW_NO_SESSION' )
1171 ? $this->mRequest->getSession()->getLoggedOutTimestamp() : 0;
1172 if ( $loggedOut !== 0 ) {
1173 $this->mTouched =
wfTimestamp( TS_MW, $loggedOut );
1175 $this->mTouched =
'1'; # Allow
any pages to be cached
1178 $this->mToken =
null;
1179 $this->mEmailAuthenticated =
null;
1180 $this->mEmailToken =
'';
1181 $this->mEmailTokenExpires =
null;
1183 $this->mGroupMemberships = [];
1201 return ( $this->mLoadedItems ===
true && $all ===
'all' ) ||
1202 ( isset( $this->mLoadedItems[$item] ) && $this->mLoadedItems[$item] ===
true );
1211 if ( is_array( $this->mLoadedItems ) ) {
1212 $this->mLoadedItems[$item] =
true;
1231 $session = $this->
getRequest()->getSession();
1232 $user = $session->getUser();
1233 if (
$user->isLoggedIn() ) {
1240 if ( $config->get(
'CookieSetOnAutoblock' ) ===
true ) {
1242 $shouldSetCookie = $this->
getRequest()->getCookie(
'BlockID' ) ===
null
1245 && $block->isAutoblocking();
1246 if ( $shouldSetCookie ) {
1247 wfDebug( __METHOD__ .
': User is autoblocked, setting cookie to track' );
1248 $block->setCookie( $this->
getRequest()->response() );
1253 $session->set(
'wsUserID', $this->
getId() );
1254 $session->set(
'wsUserName', $this->
getName() );
1255 $session->set(
'wsToken', $this->
getToken() );
1270 $this->mId = intval( $this->mId );
1272 if ( !$this->mId ) {
1281 $s = $db->selectRow(
1283 self::selectFields(),
1284 [
'user_id' => $this->mId ],
1289 $this->queryFlagsUsed =
$flags;
1292 if (
$s !==
false ) {
1295 $this->mGroupMemberships =
null;
1321 $this->mGroupMemberships =
null;
1323 if ( isset( $row->user_name ) ) {
1324 $this->mName = $row->user_name;
1325 $this->mFrom =
'name';
1331 if ( isset( $row->user_real_name ) ) {
1332 $this->mRealName = $row->user_real_name;
1338 if ( isset( $row->user_id ) ) {
1339 $this->mId = intval( $row->user_id );
1340 $this->mFrom =
'id';
1346 if ( isset( $row->user_id ) && isset( $row->user_name ) ) {
1347 self::$idCacheByName[$row->user_name] = $row->user_id;
1350 if ( isset( $row->user_editcount ) ) {
1351 $this->mEditCount = $row->user_editcount;
1356 if ( isset( $row->user_touched ) ) {
1357 $this->mTouched =
wfTimestamp( TS_MW, $row->user_touched );
1362 if ( isset( $row->user_token ) ) {
1366 $this->mToken = rtrim( $row->user_token,
" \0" );
1367 if ( $this->mToken ===
'' ) {
1368 $this->mToken =
null;
1374 if ( isset( $row->user_email ) ) {
1375 $this->mEmail = $row->user_email;
1376 $this->mEmailAuthenticated =
wfTimestampOrNull( TS_MW, $row->user_email_authenticated );
1377 $this->mEmailToken = $row->user_email_token;
1378 $this->mEmailTokenExpires =
wfTimestampOrNull( TS_MW, $row->user_email_token_expires );
1385 $this->mLoadedItems =
true;
1388 if ( is_array( $data ) ) {
1389 if ( isset( $data[
'user_groups'] ) && is_array( $data[
'user_groups'] ) ) {
1390 if ( !
count( $data[
'user_groups'] ) ) {
1391 $this->mGroupMemberships = [];
1393 $firstGroup = reset( $data[
'user_groups'] );
1394 if ( is_array( $firstGroup ) || is_object( $firstGroup ) ) {
1395 $this->mGroupMemberships = [];
1396 foreach ( $data[
'user_groups']
as $row ) {
1398 $this->mGroupMemberships[$ugm->getGroup()] = $ugm;
1403 if ( isset( $data[
'user_properties'] ) && is_array( $data[
'user_properties'] ) ) {
1416 foreach ( self::$mCacheVars
as $var ) {
1417 $this->$var =
$user->$var;
1425 if ( is_null( $this->mGroupMemberships ) ) {
1426 $db = ( $this->queryFlagsUsed & self::READ_LATEST )
1456 if ( !
count( $toPromote ) ) {
1465 foreach ( $toPromote
as $group ) {
1469 Hooks::run(
'UserGroupsChanged', [ $this, $toPromote, [],
false,
false ] );
1470 AuthManager::callLegacyAuthPlugin(
'updateExternalDBGroups', [ $this, $toPromote ] );
1472 $newGroups = array_merge( $oldGroups, $toPromote );
1475 $logEntry->setPerformer( $this );
1477 $logEntry->setParameters( [
1478 '4::oldgroups' => $oldGroups,
1479 '5::newgroups' => $newGroups,
1481 $logid = $logEntry->insert();
1483 $logEntry->publish( $logid );
1499 if ( $this->mTouched ) {
1501 $conditions[
'user_touched'] = $db->
timestamp( $this->mTouched );
1519 if ( !$this->mId ) {
1527 $dbw->update(
'user',
1528 [
'user_touched' => $dbw->timestamp( $newTouched ) ],
1530 'user_id' => $this->mId,
1534 $success = ( $dbw->affectedRows() > 0 );
1537 $this->mTouched = $newTouched;
1555 $this->mNewtalk = -1;
1556 $this->mDatePreference =
null;
1557 $this->mBlockedby = -1; # Unset
1558 $this->mHash =
false;
1559 $this->mRights =
null;
1560 $this->mEffectiveGroups =
null;
1561 $this->mImplicitGroups =
null;
1562 $this->mGroupMemberships =
null;
1563 $this->mOptions =
null;
1564 $this->mOptionsLoaded =
false;
1565 $this->mEditCount =
null;
1567 if ( $reloadFrom ) {
1568 $this->mLoadedItems = [];
1569 $this->mFrom = $reloadFrom;
1582 static $defOpt =
null;
1583 static $defOptLang =
null;
1585 if ( $defOpt !==
null && $defOptLang ===
$wgContLang->getCode() ) {
1595 $defOpt[
'language'] = $defOptLang;
1596 foreach ( LanguageConverter::$languagesWithVariants
as $langCode ) {
1597 $defOpt[$langCode ==
$wgContLang->getCode() ?
'variant' :
"variant-$langCode"] = $langCode;
1604 $defOpt[
'searchNs' . $nsnum] = (bool)$val;
1608 Hooks::run(
'UserGetDefaultOptions', [ &$defOpt ] );
1621 if ( isset( $defOpts[
$opt] ) ) {
1622 return $defOpts[
$opt];
1637 if ( -1 != $this->mBlockedby ) {
1641 wfDebug( __METHOD__ .
": checking...\n" );
1650 # We only need to worry about passing the IP address to the Block generator if the
1651 # user is not immune to autoblocks/hardblocks, and they are the current user so we
1652 # know which IP address they're actually coming from
1654 if ( !$this->
isAllowed(
'ipblock-exempt' ) ) {
1657 $globalUserName =
$wgUser->isSafeToLoad()
1660 if ( $this->
getName() === $globalUserName ) {
1669 if ( !$block instanceof
Block ) {
1676 if ( self::isLocallyBlockedProxy( $ip ) ) {
1677 $block =
new Block( [
1681 'systemBlock' =>
'proxy',
1684 $block =
new Block( [
1688 'systemBlock' =>
'dnsbl',
1694 if ( !$block instanceof
Block
1699 $xff = $this->
getRequest()->getHeader(
'X-Forwarded-For' );
1700 $xff = array_map(
'trim', explode(
',', $xff ) );
1701 $xff = array_diff( $xff, [ $ip ] );
1704 if ( $block instanceof
Block ) {
1705 # Mangle the reason to alert the user that the block
1706 # originated from matching the X-Forwarded-For header.
1707 $block->mReason =
wfMessage(
'xffblockreason', $block->mReason )->text();
1711 if ( !$block instanceof
Block
1716 $block =
new Block( [
1718 'byText' =>
'MediaWiki default',
1719 'reason' =>
wfMessage(
'softblockrangesreason', $ip )->
text(),
1721 'systemBlock' =>
'wgSoftBlockRanges',
1725 if ( $block instanceof
Block ) {
1726 wfDebug( __METHOD__ .
": Found block.\n" );
1727 $this->mBlock = $block;
1728 $this->mBlockedby = $block->getByName();
1729 $this->mBlockreason = $block->mReason;
1730 $this->mHideName = $block->mHideName;
1731 $this->mAllowUsertalk = !$block->prevents(
'editownusertalk' );
1733 $this->mBlockedby =
'';
1734 $this->mHideName = 0;
1735 $this->mAllowUsertalk =
false;
1751 if ( strlen( $blockCookieVal ) < 1 || !is_numeric( substr( $blockCookieVal, 0, 1 ) ) ) {
1756 if ( $blockCookieId !==
null ) {
1759 if ( $tmpBlock instanceof
Block ) {
1762 && !$tmpBlock->isExpired()
1763 && $tmpBlock->isAutoblocking();
1765 $useBlockCookie = ( $config->get(
'CookieSetOnAutoblock' ) ===
true );
1766 if ( $blockIsValid && $useBlockCookie ) {
1814 $ipReversed = implode(
'.', array_reverse( explode(
'.', $ip ) ) );
1820 if ( is_array(
$base ) ) {
1823 $host =
"{$base[1]}.$ipReversed.{$base[0]}";
1825 $host =
"$ipReversed.{$base[0]}";
1827 $basename =
$base[0];
1829 $host =
"$ipReversed.$base";
1833 $ipList = gethostbynamel( $host );
1836 wfDebugLog(
'dnsblacklist',
"Hostname $host is {$ipList[0]}, it's a proxy says $basename!" );
1840 wfDebugLog(
'dnsblacklist',
"Requested $host, not found in $basename." );
1867 $resultProxyList = [];
1868 $deprecatedIPEntries = [];
1874 if ( $keyIsIP && !$valueIsIP ) {
1875 $deprecatedIPEntries[] = $key;
1876 $resultProxyList[] = $key;
1877 } elseif ( $keyIsIP && $valueIsIP ) {
1878 $deprecatedIPEntries[] = $key;
1879 $resultProxyList[] = $key;
1880 $resultProxyList[] =
$value;
1882 $resultProxyList[] =
$value;
1886 if ( $deprecatedIPEntries ) {
1888 'IP addresses in the keys of $wgProxyList (found the following IP addresses in keys: ' .
1889 implode(
', ', $deprecatedIPEntries ) .
', please move them to values)',
'1.30' );
1892 $proxyListIPSet =
new IPSet( $resultProxyList );
1893 return $proxyListIPSet->match( $ip );
1909 return !$this->
isAllowed(
'noratelimit' );
1940 $limits = array_merge(
1941 [
'&can-bypass' =>
true ],
1951 $id = $this->
getId();
1958 if ( isset( $limits[
'anon'] ) ) {
1959 $keys[
$cache->makeKey(
'limiter', $action,
'anon' )] = $limits[
'anon'];
1963 if ( isset( $limits[
'user'] ) ) {
1964 $userLimit = $limits[
'user'];
1971 if ( isset( $limits[
'ip'] ) ) {
1973 $keys[
"mediawiki:limiter:$action:ip:$ip"] = $limits[
'ip'];
1976 if ( isset( $limits[
'subnet'] ) ) {
1979 if ( $subnet !==
false ) {
1980 $keys[
"mediawiki:limiter:$action:subnet:$subnet"] = $limits[
'subnet'];
1988 if ( isset( $limits[$group] ) ) {
1989 if ( $userLimit ===
false
1990 || $limits[$group][0] / $limits[$group][1] > $userLimit[0] / $userLimit[1]
1992 $userLimit = $limits[$group];
1998 if ( $id !== 0 && $isNewbie && isset( $limits[
'newbie'] ) ) {
1999 $userLimit = $limits[
'newbie'];
2003 if ( $userLimit !==
false ) {
2004 list( $max, $period ) = $userLimit;
2005 wfDebug( __METHOD__ .
": effective user limit: $max in {$period}s\n" );
2006 $keys[
$cache->makeKey(
'limiter', $action,
'user', $id )] = $userLimit;
2010 if ( isset( $limits[
'ip-all'] ) ) {
2013 if ( $isNewbie || $userLimit ===
false
2014 || $limits[
'ip-all'][0] / $limits[
'ip-all'][1] > $userLimit[0] / $userLimit[1] ) {
2015 $keys[
"mediawiki:limiter:$action:ip-all:$ip"] = $limits[
'ip-all'];
2020 if ( isset( $limits[
'subnet-all'] ) ) {
2023 if ( $subnet !==
false ) {
2025 if ( $isNewbie || $userLimit ===
false
2026 || $limits[
'ip-all'][0] / $limits[
'ip-all'][1]
2027 > $userLimit[0] / $userLimit[1] ) {
2028 $keys[
"mediawiki:limiter:$action:subnet-all:$subnet"] = $limits[
'subnet-all'];
2034 foreach (
$keys as $key => $limit ) {
2035 list( $max, $period ) = $limit;
2036 $summary =
"(limit $max in {$period}s)";
2037 $count =
$cache->get( $key );
2040 if ( $count >= $max ) {
2041 wfDebugLog(
'ratelimit',
"User '{$this->getName()}' " .
2042 "(IP {$this->getRequest()->getIP()}) tripped $key at $count $summary" );
2045 wfDebug( __METHOD__ .
": ok. $key at $count $summary\n" );
2048 wfDebug( __METHOD__ .
": adding record for $key $summary\n" );
2049 if ( $incrBy > 0 ) {
2050 $cache->add( $key, 0, intval( $period ) );
2053 if ( $incrBy > 0 ) {
2054 $cache->incr( $key, $incrBy );
2080 return $this->mBlock instanceof
Block ? $this->mBlock :
null;
2093 $blocked = $this->
isBlocked( $bFromSlave );
2096 if ( !$this->mHideName && $allowUsertalk &&
$title->getText() === $this->
getName()
2099 wfDebug( __METHOD__ .
": self-talk page, ignoring any blocks\n" );
2102 Hooks::run(
'UserIsBlockedFrom', [ $this,
$title, &$blocked, &$allowUsertalk ] );
2131 return ( $this->mBlock ? $this->mBlock->getId() :
false );
2157 if ( $this->mGlobalBlock !==
null ) {
2158 return $this->mGlobalBlock ?:
null;
2170 Hooks::run(
'UserIsBlockedGlobally', [ &
$user, $ip, &$blocked, &$block ] );
2172 if ( $blocked && $block ===
null ) {
2174 $block =
new Block( [
2176 'systemBlock' =>
'global-block'
2180 $this->mGlobalBlock = $blocked ? $block :
false;
2181 return $this->mGlobalBlock ?:
null;
2190 if ( $this->mLocked !==
null ) {
2195 $authUser = AuthManager::callLegacyAuthPlugin(
'getUserInstance', [ &
$user ],
null );
2196 $this->mLocked = $authUser && $authUser->isLocked();
2197 Hooks::run(
'UserIsLocked', [ $this, &$this->mLocked ] );
2207 if ( $this->mHideName !==
null ) {
2211 if ( !$this->mHideName ) {
2214 $authUser = AuthManager::callLegacyAuthPlugin(
'getUserInstance', [ &
$user ],
null );
2215 $this->mHideName = $authUser && $authUser->isHidden();
2216 Hooks::run(
'UserIsHidden', [ $this, &$this->mHideName ] );
2226 if ( $this->mId ===
null && $this->mName !==
null && self::isIP( $this->mName ) ) {
2256 if ( $this->mName ===
false ) {
2279 $this->mName = $str;
2287 return str_replace(
' ',
'_', $this->
getName() );
2298 if ( $this->mNewtalk === -1 ) {
2299 $this->mNewtalk =
false; # reset talk
page status
2303 if ( !$this->mId ) {
2307 $this->mNewtalk =
false;
2312 $this->mNewtalk = $this->
checkNewtalk(
'user_id', $this->mId );
2344 $timestamp =
$dbr->selectField(
'user_newtalk',
2345 'MIN(user_last_timestamp)',
2346 $this->
isAnon() ? [
'user_ip' => $this->
getName() ] : [
'user_id' => $this->
getId() ],
2349 return [ [
'wiki' =>
wfWikiID(),
'link' => $utp->getLocalURL(),
'rev' =>
$rev ] ];
2358 $newMessageRevisionId =
null;
2360 if ( $newMessageLinks ) {
2364 if (
count( $newMessageLinks ) === 1
2365 && $newMessageLinks[0][
'wiki'] ===
wfWikiID()
2366 && $newMessageLinks[0][
'rev']
2369 $newMessageRevision = $newMessageLinks[0][
'rev'];
2370 $newMessageRevisionId = $newMessageRevision->getId();
2373 return $newMessageRevisionId;
2387 $ok =
$dbr->selectField(
'user_newtalk', $field, [ $field => $id ], __METHOD__ );
2389 return $ok !==
false;
2401 $prevRev = $curRev ? $curRev->getPrevious() :
false;
2402 $ts = $prevRev ? $prevRev->getTimestamp() :
null;
2405 $dbw->insert(
'user_newtalk',
2406 [ $field => $id,
'user_last_timestamp' => $dbw->timestampOrNull( $ts ) ],
2409 if ( $dbw->affectedRows() ) {
2410 wfDebug( __METHOD__ .
": set on ($field, $id)\n" );
2413 wfDebug( __METHOD__ .
" already set ($field, $id)\n" );
2426 $dbw->delete(
'user_newtalk',
2429 if ( $dbw->affectedRows() ) {
2430 wfDebug( __METHOD__ .
": killed on ($field, $id)\n" );
2433 wfDebug( __METHOD__ .
": already gone ($field, $id)\n" );
2450 $this->mNewtalk = $val;
2457 $id = $this->
getId();
2480 if ( $this->mTouched && $time <= $this->mTouched ) {
2498 if ( !$this->
getId() ) {
2504 if ( $mode ===
'refresh' ) {
2505 $cache->delete( $key, 1 );
2539 $id = $this->
getId();
2541 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
2542 $key =
$cache->makeKey(
'user-quicktouched',
'id', $id );
2543 $cache->touchCheckKey( $key );
2544 $this->mQuickTouched =
null;
2554 return ( $timestamp >= $this->
getTouched() );
2569 if ( $this->mQuickTouched ===
null ) {
2570 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
2571 $key =
$cache->makeKey(
'user-quicktouched',
'id', $this->mId );
2576 return max( $this->mTouched, $this->mQuickTouched );
2634 $manager = AuthManager::singleton();
2637 if ( !$manager->userExists( $this->getName() ) ) {
2638 throw new LogicException(
'Cannot set a password for a user that is not in the database.' );
2642 'username' => $this->
getName(),
2648 ->info( __METHOD__ .
': Password change rejected: '
2649 .
$status->getWikiText(
null,
null,
'en' ) );
2653 $this->
setOption(
'watchlisttoken',
false );
2654 SessionManager::singleton()->invalidateSessionsForUser( $this );
2672 $manager = AuthManager::singleton();
2673 $reqs = $manager->getAuthenticationRequests( AuthManager::ACTION_CHANGE, $this );
2674 $reqs = AuthenticationRequest::loadRequestsFromSubmission( $reqs, $data );
2677 foreach ( $reqs
as $req ) {
2678 $status->merge( $manager->allowsAuthenticationDataChange(
$req ),
true );
2680 if (
$status->getValue() ===
'ignored' ) {
2681 $status->warning(
'authenticationdatachange-ignored' );
2685 foreach ( $reqs
as $req ) {
2686 $manager->changeAuthenticationData(
$req );
2702 if ( !$this->mToken && $forceCreation ) {
2706 if ( !$this->mToken ) {
2709 } elseif ( $this->mToken === self::INVALID_TOKEN ) {
2721 $len = max( 32, self::TOKEN_LENGTH );
2722 if ( strlen(
$ret ) < $len ) {
2724 throw new \UnexpectedValueException(
'Hmac returned less than 128 bits' );
2726 return substr(
$ret, -$len );
2738 if ( $this->mToken === self::INVALID_TOKEN ) {
2740 ->debug( __METHOD__ .
": Ignoring attempt to set token for system user \"$this\"" );
2741 } elseif ( !$token ) {
2744 $this->mToken = $token;
2757 throw new BadMethodCallException( __METHOD__ .
' has been removed in 1.27' );
2766 Hooks::run(
'UserGetEmail', [ $this, &$this->mEmail ] );
2776 Hooks::run(
'UserGetEmailAuthenticationTimestamp', [ $this, &$this->mEmailAuthenticated ] );
2786 if ( $str == $this->mEmail ) {
2790 $this->mEmail = $str;
2791 Hooks::run(
'UserSetEmail', [ $this, &$this->mEmail ] );
2809 if ( $str === $oldaddr ) {
2813 $type = $oldaddr !=
'' ?
'changed' :
'set';
2814 $notificationResult =
null;
2819 if (
$type ==
'changed' ) {
2820 $change = $str !=
'' ?
'changed' :
'removed';
2821 $notificationResult = $this->
sendMail(
2822 wfMessage(
'notificationemail_subject_' . $change )->
text(),
2823 wfMessage(
'notificationemail_body_' . $change,
2837 if ( $notificationResult !==
null ) {
2838 $result->merge( $notificationResult );
2870 $this->mRealName = $str;
2883 public function getOption( $oname, $defaultOverride =
null, $ignoreHidden =
false ) {
2887 # We want 'disabled' preferences to always behave as the default value for
2888 # users, even if they have set the option explicitly in their settings (ie they
2889 # set it, and then it was disabled removing their ability to change it). But
2890 # we don't want to erase the preferences in the database in case the preference
2891 # is re-enabled again. So don't touch $mOptions, just override the returned value
2896 if ( array_key_exists( $oname, $this->mOptions ) ) {
2897 return $this->mOptions[$oname];
2899 return $defaultOverride;
2916 # We want 'disabled' preferences to always behave as the default value for
2917 # users, even if they have set the option explicitly in their settings (ie they
2918 # set it, and then it was disabled removing their ability to change it). But
2919 # we don't want to erase the preferences in the database in case the preference
2920 # is re-enabled again. So don't touch $mOptions, just override the returned value
2921 foreach ( $wgHiddenPrefs
as $pref ) {
2923 if ( $default !==
null ) {
2928 if (
$flags & self::GETOPTIONS_EXCLUDE_DEFAULTS ) {
2943 return (
bool)$this->
getOption( $oname );
2957 $val = $defaultOverride;
2959 return intval( $val );
2974 if ( is_null( $val ) ) {
2978 $this->mOptions[$oname] = $val;
2994 $id = $this->
getId();
3004 $token = hash_hmac(
'sha1',
"$oname:$id", $this->
getToken() );
3056 'registered-multiselect',
3057 'registered-checkmatrix',
3089 unset( $prefs[
$name] );
3094 $multiselectOptions = [];
3095 foreach ( $prefs
as $name => $info ) {
3096 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'multiselect' ) ||
3097 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLMultiSelectField' ) ) {
3099 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
3102 $multiselectOptions[
"$prefix$value"] =
true;
3105 unset( $prefs[
$name] );
3108 $checkmatrixOptions = [];
3109 foreach ( $prefs
as $name => $info ) {
3110 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'checkmatrix' ) ||
3111 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLCheckMatrix' ) ) {
3114 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
3116 foreach ( $columns
as $column ) {
3118 $checkmatrixOptions[
"$prefix$column-$row"] =
true;
3122 unset( $prefs[
$name] );
3128 if ( isset( $prefs[$key] ) ) {
3129 $mapping[$key] =
'registered';
3130 } elseif ( isset( $multiselectOptions[$key] ) ) {
3131 $mapping[$key] =
'registered-multiselect';
3132 } elseif ( isset( $checkmatrixOptions[$key] ) ) {
3133 $mapping[$key] =
'registered-checkmatrix';
3134 } elseif ( isset( $specialOptions[$key] ) ) {
3135 $mapping[$key] =
'special';
3136 } elseif ( substr( $key, 0, 7 ) ===
'userjs-' ) {
3137 $mapping[$key] =
'userjs';
3139 $mapping[$key] =
'unused';
3161 $resetKinds = [
'registered',
'registered-multiselect',
'registered-checkmatrix',
'unused' ],
3167 if ( !is_array( $resetKinds ) ) {
3168 $resetKinds = [ $resetKinds ];
3171 if ( in_array(
'all', $resetKinds ) ) {
3172 $newOptions = $defaultOptions;
3179 $resetKinds = array_intersect( $resetKinds, self::listOptionKinds() );
3184 foreach ( $this->mOptions
as $key =>
$value ) {
3185 if ( in_array( $optionKinds[$key], $resetKinds ) ) {
3186 if ( array_key_exists( $key, $defaultOptions ) ) {
3187 $newOptions[$key] = $defaultOptions[$key];
3190 $newOptions[$key] =
$value;
3195 Hooks::run(
'UserResetAllOptions', [ $this, &$newOptions, $this->mOptions, $resetKinds ] );
3197 $this->mOptions = $newOptions;
3198 $this->mOptionsLoaded =
true;
3207 if ( is_null( $this->mDatePreference ) ) {
3210 $map =
$wgLang->getDatePreferenceMigrationMap();
3211 if ( isset( $map[
$value] ) ) {
3214 $this->mDatePreference =
$value;
3231 Hooks::run(
'UserRequiresHTTPS', [ $this, &$https ] );
3260 if ( is_null( $this->mRights ) ) {
3262 Hooks::run(
'UserGetRights', [ $this, &$this->mRights ] );
3266 if ( !defined(
'MW_NO_SESSION' ) ) {
3267 $allowedRights = $this->
getRequest()->getSession()->getAllowedUserRights();
3268 if ( $allowedRights !==
null ) {
3269 $this->mRights = array_intersect( $this->mRights, $allowedRights );
3274 $this->mRights = array_values( array_unique( $this->mRights ) );
3285 $config->get(
'BlockDisablesLogin' ) &&
3289 $this->mRights = array_intersect( $this->mRights, $anon->getRights() );
3303 return array_keys( $this->mGroupMemberships );
3327 if ( $recache || is_null( $this->mEffectiveGroups ) ) {
3328 $this->mEffectiveGroups = array_unique( array_merge(
3335 Hooks::run(
'UserEffectiveGroups', [ &
$user, &$this->mEffectiveGroups ] );
3337 $this->mEffectiveGroups = array_values( array_unique( $this->mEffectiveGroups ) );
3350 if ( $recache || is_null( $this->mImplicitGroups ) ) {
3351 $this->mImplicitGroups = [
'*' ];
3352 if ( $this->
getId() ) {
3353 $this->mImplicitGroups[] =
'user';
3355 $this->mImplicitGroups = array_unique( array_merge(
3356 $this->mImplicitGroups,
3363 $this->mEffectiveGroups =
null;
3381 if ( is_null( $this->mFormerGroups ) ) {
3382 $db = ( $this->queryFlagsUsed & self::READ_LATEST )
3385 $res = $db->select(
'user_former_groups',
3387 [
'ufg_user' => $this->mId ],
3389 $this->mFormerGroups = [];
3390 foreach (
$res as $row ) {
3391 $this->mFormerGroups[] = $row->ufg_group;
3403 if ( !$this->
getId() ) {
3407 if ( $this->mEditCount ===
null ) {
3411 $count =
$dbr->selectField(
3412 'user',
'user_editcount',
3413 [
'user_id' => $this->mId ],
3417 if ( $count ===
null ) {
3421 $this->mEditCount = $count;
3445 if ( !
Hooks::run(
'UserAddGroup', [ $this, &$group, &$expiry ] ) ) {
3451 if ( !$ugm->insert(
true ) ) {
3455 $this->mGroupMemberships[$group] = $ugm;
3460 $this->mRights =
null;
3476 if ( !
Hooks::run(
'UserRemoveGroup', [ $this, &$group ] ) ) {
3482 if ( !$ugm || !$ugm->delete() ) {
3487 unset( $this->mGroupMemberships[$group] );
3492 $this->mRights =
null;
3504 return $this->
getId() != 0;
3525 Hooks::run(
"UserIsBot", [ $this, &$isBot ] );
3537 $permissions = func_get_args();
3538 foreach ( $permissions
as $permission ) {
3539 if ( $this->
isAllowed( $permission ) ) {
3552 $permissions = func_get_args();
3553 foreach ( $permissions
as $permission ) {
3554 if ( !$this->
isAllowed( $permission ) ) {
3567 if ( $action ===
'' ) {
3572 return in_array( $action, $this->
getRights(),
true );
3581 return $wgUseRCPatrol && $this->
isAllowedAny(
'patrol',
'patrolmarks' );
3614 if ( $this->mRequest ) {
3631 if (
$title->isWatchable() && ( !$checkRights || $this->
isAllowed(
'viewmywatchlist' ) ) ) {
3632 return MediaWikiServices::getInstance()->getWatchedItemStore()->isWatched( $this,
$title );
3645 if ( !$checkRights || $this->
isAllowed(
'editmywatchlist' ) ) {
3646 MediaWikiServices::getInstance()->getWatchedItemStore()->addWatchBatchForUser(
3662 if ( !$checkRights || $this->
isAllowed(
'editmywatchlist' ) ) {
3663 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
3664 $store->removeWatch( $this,
$title->getSubjectPage() );
3665 $store->removeWatch( $this,
$title->getTalkPage() );
3687 if ( !$this->
isAllowed(
'editmywatchlist' ) ) {
3695 if ( !
Hooks::run(
'UserClearNewTalkNotification', [ &
$user, $oldid ] ) ) {
3736 MediaWikiServices::getInstance()->getWatchedItemStore()
3737 ->resetNotificationTimestamp( $this,
$title, $force, $oldid );
3758 $id = $this->
getId();
3764 $asOfTimes = array_unique( $dbw->selectFieldValues(
3766 'wl_notificationtimestamp',
3767 [
'wl_user' => $id,
'wl_notificationtimestamp IS NOT NULL' ],
3769 [
'ORDER BY' =>
'wl_notificationtimestamp DESC',
'LIMIT' => 500 ]
3771 if ( !$asOfTimes ) {
3778 [
'wl_notificationtimestamp' =>
null ],
3779 [
'wl_user' => $id,
'wl_notificationtimestamp' => $asOfTimes ],
3786 function ()
use ( $dbw, $id ) {
3789 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
3790 $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
3791 $asOfTimes = array_unique( $dbw->selectFieldValues(
3793 'wl_notificationtimestamp',
3794 [
'wl_user' => $id,
'wl_notificationtimestamp IS NOT NULL' ],
3800 [
'wl_notificationtimestamp' =>
null ],
3801 [
'wl_user' => $id,
'wl_notificationtimestamp' => $asOfTimeBatch ],
3804 $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
3835 $registration > $learnerRegistration
3840 $registration <= $experiencedRegistration
3842 return 'experienced';
3928 if ( 0 == $this->mId ) {
3932 $session = $this->
getRequest()->getSession();
3934 $session = $session->sessionWithRequest(
$request );
3936 $delay = $session->delaySave();
3938 if ( !$session->getUser()->equals( $this ) ) {
3939 if ( !$session->canSetUser() ) {
3941 ->warning( __METHOD__ .
3942 ": Cannot save user \"$this\" to a user \"{$session->getUser()}\"'s immutable session"
3946 $session->setUser( $this );
3949 $session->setRememberUser( $rememberMe );
3950 if ( $secure !==
null ) {
3951 $session->setForceHTTPS( $secure );
3954 $session->persist();
3956 ScopedCallback::consume( $delay );
3975 $session = $this->
getRequest()->getSession();
3976 if ( !$session->canSetUser() ) {
3978 ->warning( __METHOD__ .
": Cannot log out of an immutable session" );
3979 $error =
'immutable';
3980 } elseif ( !$session->getUser()->equals( $this ) ) {
3982 ->warning( __METHOD__ .
3983 ": Cannot log user \"$this\" out of a user \"{$session->getUser()}\"'s session"
3987 $error =
'wronguser';
3990 $delay = $session->delaySave();
3991 $session->unpersist();
3992 $session->setLoggedOutTimestamp( time() );
3993 $session->setUser(
new User );
3994 $session->set(
'wsUserID', 0 );
3995 $session->resetAllTokens();
3996 ScopedCallback::consume( $delay );
4000 'event' =>
'logout',
4001 'successful' => $error ===
false,
4002 'status' => $error ?:
'success',
4016 "Could not update user with ID '{$this->mId}'; DB is read-only."
4022 if ( 0 == $this->mId ) {
4032 $dbw->update(
'user',
4034 'user_name' => $this->mName,
4035 'user_real_name' => $this->mRealName,
4036 'user_email' => $this->mEmail,
4037 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
4038 'user_touched' => $dbw->timestamp( $newTouched ),
4039 'user_token' => strval( $this->mToken ),
4041 'user_email_token_expires' => $dbw->timestampOrNull( $this->mEmailTokenExpires ),
4043 'user_id' => $this->mId,
4047 if ( !$dbw->affectedRows() ) {
4051 $from = ( $this->queryFlagsUsed & self::READ_LATEST ) ?
'master' :
'replica';
4053 "CAS update failed on user_touched for user ID '{$this->mId}' (read from $from);" .
4054 " the version of the user to be saved is older than the current version."
4058 $this->mTouched = $newTouched;
4078 $db = ( (
$flags & self::READ_LATEST ) == self::READ_LATEST )
4083 ? [
'LOCK IN SHARE MODE' ]
4086 $id = $db->selectField(
'user',
4087 'user_id', [
'user_name' =>
$s ], __METHOD__,
$options );
4108 foreach ( [
'password',
'newpassword',
'newpass_time',
'password_expires' ]
as $field ) {
4109 if ( isset(
$params[$field] ) ) {
4110 wfDeprecated( __METHOD__ .
" with param '$field'",
'1.27' );
4118 if ( isset(
$params[
'options'] ) ) {
4127 'user_name' =>
$name,
4128 'user_password' => $noPass,
4129 'user_newpassword' => $noPass,
4130 'user_email' =>
$user->mEmail,
4131 'user_email_authenticated' => $dbw->timestampOrNull(
$user->mEmailAuthenticated ),
4132 'user_real_name' =>
$user->mRealName,
4133 'user_token' => strval(
$user->mToken ),
4134 'user_registration' => $dbw->timestamp(
$user->mRegistration ),
4135 'user_editcount' => 0,
4136 'user_touched' => $dbw->timestamp(
$user->newTouchedTimestamp() ),
4139 $fields[
"user_$name"] =
$value;
4141 $dbw->insert(
'user', $fields, __METHOD__, [
'IGNORE' ] );
4142 if ( $dbw->affectedRows() ) {
4178 if ( !$this->mToken ) {
4182 if ( !is_string( $this->mName ) ) {
4183 throw new RuntimeException(
"User name field is not set." );
4191 $dbw->insert(
'user',
4193 'user_name' => $this->mName,
4194 'user_password' => $noPass,
4195 'user_newpassword' => $noPass,
4196 'user_email' => $this->mEmail,
4197 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
4199 'user_token' => strval( $this->mToken ),
4200 'user_registration' => $dbw->timestamp( $this->mRegistration ),
4201 'user_editcount' => 0,
4202 'user_touched' => $dbw->timestamp( $this->mTouched ),
4206 if ( !$dbw->affectedRows() ) {
4208 $this->mId = $dbw->selectField(
4211 [
'user_name' => $this->mName ],
4213 [
'LOCK IN SHARE MODE' ]
4222 throw new MWException( __METHOD__ .
": hit a key conflict attempting " .
4223 "to insert user '{$this->mName}' row, but it was not present in select!" );
4227 $this->mId = $dbw->insertId();
4256 wfDebug( __METHOD__ .
"()\n" );
4258 if ( $this->mId == 0 ) {
4263 if ( !$userblock ) {
4267 return (
bool)$userblock->doAutoblock( $this->
getRequest()->getIP() );
4276 if ( $this->mBlock && $this->mBlock->prevents(
'createaccount' ) ) {
4280 # T15611: if the IP address the user is trying to create an account from is
4281 # blocked with createaccount disabled, prevent new account creation there even
4282 # when the user is logged in
4283 if ( $this->mBlockedFromCreateAccount ===
false && !$this->
isAllowed(
'ipblock-exempt' ) ) {
4286 return $this->mBlockedFromCreateAccount instanceof
Block
4287 && $this->mBlockedFromCreateAccount->
prevents(
'createaccount' )
4288 ? $this->mBlockedFromCreateAccount
4298 return $this->mBlock && $this->mBlock->prevents(
'sendemail' );
4325 return $title->getTalkPage();
4334 return !$this->
isAllowed(
'autoconfirmed' );
4344 $manager = AuthManager::singleton();
4345 $reqs = AuthenticationRequest::loadRequestsFromSubmission(
4346 $manager->getAuthenticationRequests( AuthManager::ACTION_LOGIN ),
4348 'username' => $this->
getName(),
4349 'password' => $password,
4352 $res = AuthManager::singleton()->beginAuthentication( $reqs,
'null:' );
4353 switch (
$res->status ) {
4354 case AuthenticationResponse::PASS:
4356 case AuthenticationResponse::FAIL:
4359 ->info( __METHOD__ .
': Authentication failed: ' .
$res->message->plain() );
4362 throw new BadMethodCallException(
4363 'AuthManager returned a response unsupported by ' . __METHOD__
4400 return $request->getSession()->getToken( $salt );
4458 $val = substr( $val, 0, strspn( $val,
'0123456789abcdef' ) ) . Token::SUFFIX;
4477 if (
$type ==
'created' ||
$type ===
false ) {
4478 $message =
'confirmemail_body';
4479 } elseif (
$type ===
true ) {
4480 $message =
'confirmemail_body_changed';
4483 $message =
'confirmemail_body_' .
$type;
4491 $wgLang->userTimeAndDate( $expiration, $this ),
4493 $wgLang->userDate( $expiration, $this ),
4494 $wgLang->userTime( $expiration, $this ) )->
text() );
4508 public function sendMail( $subject, $body, $from =
null, $replyto =
null ) {
4511 if ( $from instanceof
User ) {
4520 'replyTo' => $replyto,
4541 $hash = md5( $token );
4542 $this->mEmailToken = $hash;
4543 $this->mEmailTokenExpires = $expiration;
4553 return $this->
getTokenUrl(
'ConfirmEmail', $token );
4562 return $this->
getTokenUrl(
'InvalidateEmail', $token );
4582 return $title->getCanonicalURL();
4597 Hooks::run(
'ConfirmEmailComplete', [ $this ] );
4611 $this->mEmailToken =
null;
4612 $this->mEmailTokenExpires =
null;
4615 Hooks::run(
'InvalidateEmailComplete', [ $this ] );
4625 $this->mEmailAuthenticated = $timestamp;
4626 Hooks::run(
'UserSetEmailAuthenticationTimestamp', [ $this, &$this->mEmailAuthenticated ] );
4675 if ( !Sanitizer::validateEmail( $this->mEmail ) ) {
4695 $this->mEmailToken &&
4721 if ( $this->
getId() == 0 ) {
4725 $time =
$dbr->selectField(
'revision',
'rev_timestamp',
4726 [
'rev_user' => $this->
getId() ],
4728 [
'ORDER BY' =>
'rev_timestamp ASC' ]
4746 foreach ( $groups
as $group ) {
4748 $rights = array_merge( $rights,
4754 foreach ( $groups
as $group ) {
4756 $rights = array_diff( $rights,
4760 return array_unique( $rights );
4771 $allowedGroups = [];
4773 if ( self::groupHasPermission( $group, $role ) ) {
4774 $allowedGroups[] = $group;
4777 return $allowedGroups;
4818 if ( isset(
$cache[$right] ) && !defined(
'MW_PHPUNIT_TEST' ) ) {
4829 if ( isset( $rights[$right] ) && $rights[$right] ) {
4837 if ( !defined(
'MW_NO_SESSION' ) ) {
4838 $allowedRights = SessionManager::getGlobalSession()->getAllowedUserRights();
4839 if ( $allowedRights !==
null && !in_array( $right, $allowedRights,
true ) ) {
4846 if ( !
Hooks::run(
'UserIsEveryoneAllowed', [ $right ] ) ) {
4890 self::getImplicitGroups()
4899 if ( self::$mAllRights ===
false ) {
4902 self::$mAllRights = array_unique( array_merge( self::$mCoreRights,
$wgAvailableRights ) );
4906 Hooks::run(
'UserGetAllRights', [ &self::$mAllRights ] );
4919 # Deprecated, use $wgImplicitGroups instead
4920 Hooks::run(
'UserGetImplicitGroups', [ &$groups ],
'1.25' );
4950 if ( $text ==
'' ) {
4955 return MediaWikiServices::getInstance()
4956 ->getLinkRenderer()->makeLink(
$title, $text );
4958 return htmlspecialchars( $text );
4975 if ( $text ==
'' ) {
4980 $page =
$title->getFullText();
4981 return "[[$page|$text]]";
5027 if ( is_int( $key ) ) {
5035 if ( is_int( $key ) ) {
5070 if ( $this->
isAllowed(
'userrights' ) ) {
5075 $all = array_merge( self::getAllGroups() );
5093 foreach ( $addergroups
as $addergroup ) {
5094 $groups = array_merge_recursive(
5097 $groups[
'add'] = array_unique( $groups[
'add'] );
5098 $groups[
'remove'] = array_unique( $groups[
'remove'] );
5099 $groups[
'add-self'] = array_unique( $groups[
'add-self'] );
5100 $groups[
'remove-self'] = array_unique( $groups[
'remove-self'] );
5134 [
'user_editcount=user_editcount+1' ],
5135 [
'user_id' => $this->
getId(),
'user_editcount IS NOT NULL' ],
5139 if ( $dbw->affectedRows() == 0 ) {
5142 if (
$dbr !== $dbw ) {
5154 if ( $this->mEditCount ===
null ) {
5157 $this->mEditCount += (
$dbr !== $dbw ) ? 1 : 0;
5159 $this->mEditCount++;
5176 $count = (int)
$dbr->selectField(
5179 [
'rev_user' => $this->getId() ],
5182 $count = $count + $add;
5187 [
'user_editcount' => $count ],
5188 [
'user_id' => $this->
getId() ],
5203 $key =
"right-$right";
5205 return $msg->isDisabled() ? $right : $msg->text();
5216 $key =
"grant-$grant";
5218 return $msg->isDisabled() ? $grant : $msg->text();
5269 if ( $this->mOptionsLoaded ) {
5275 if ( !$this->
getId() ) {
5281 $this->mOptions[
'variant'] = $variant;
5282 $this->mOptions[
'language'] = $variant;
5283 $this->mOptionsLoaded =
true;
5288 if ( !is_null( $this->mOptionOverrides ) ) {
5289 wfDebug(
"User: loading options for user " . $this->
getId() .
" from override cache.\n" );
5290 foreach ( $this->mOptionOverrides
as $key =>
$value ) {
5291 $this->mOptions[$key] =
$value;
5294 if ( !is_array( $data ) ) {
5295 wfDebug(
"User: loading options for user " . $this->
getId() .
" from database.\n" );
5297 $dbr = ( $this->queryFlagsUsed & self::READ_LATEST )
5303 [
'up_property',
'up_value' ],
5304 [
'up_user' => $this->
getId() ],
5308 $this->mOptionOverrides = [];
5310 foreach (
$res as $row ) {
5315 if ( $row->up_value ===
'0' ) {
5318 $data[$row->up_property] = $row->up_value;
5324 if ( isset( $data[
'email-blacklist'] ) && $data[
'email-blacklist'] ) {
5325 $data[
'email-blacklist'] = array_map(
'intval', explode(
"\n", $data[
'email-blacklist'] ) );
5334 $this->mOptionsLoaded =
true;
5336 Hooks::run(
'UserLoadOptions', [ $this, &$this->mOptions ] );
5351 if ( isset( $this->mOptions[
'email-blacklist'] ) ) {
5352 if ( $this->mOptions[
'email-blacklist'] ) {
5353 $value = $this->mOptions[
'email-blacklist'];
5356 if ( is_array(
$value ) ) {
5357 $ids = array_filter(
$value,
'is_numeric' );
5360 $ids = $lookup->centralIdsFromNames( explode(
"\n",
$value ), $this );
5362 $this->mOptions[
'email-blacklist'] = $ids;
5363 $saveOptions[
'email-blacklist'] = implode(
"\n", $this->mOptions[
'email-blacklist'] );
5366 $this->mOptions[
'email-blacklist'] =
null;
5372 if ( !
Hooks::run(
'UserSaveOptions', [ $this, &$saveOptions ] ) ) {
5376 $userId = $this->
getId();
5379 foreach ( $saveOptions
as $key =>
$value ) {
5382 if ( ( $defaultOption ===
null &&
$value !==
false &&
$value !==
null )
5383 ||
$value != $defaultOption
5386 'up_user' => $userId,
5387 'up_property' => $key,
5395 $res = $dbw->select(
'user_properties',
5396 [
'up_property',
'up_value' ], [
'up_user' => $userId ], __METHOD__ );
5401 foreach (
$res as $row ) {
5402 if ( !isset( $saveOptions[$row->up_property] )
5403 || strcmp( $saveOptions[$row->up_property], $row->up_value ) != 0
5405 $keysDelete[] = $row->up_property;
5409 if (
count( $keysDelete ) ) {
5417 $dbw->delete(
'user_properties',
5418 [
'up_user' => $userId,
'up_property' => $keysDelete ], __METHOD__ );
5421 $dbw->insert(
'user_properties', $insert_rows, __METHOD__, [
'IGNORE' ] );
5468 # Note that the pattern requirement will always be satisfied if the
5469 # input is empty, so we need required in all cases.
5471 # @todo FIXME: T25769: This needs to not claim the password is required
5472 # if e-mail confirmation is being used. Since HTML5 input validation
5473 # is b0rked anyway in some browsers, just return nothing. When it's
5474 # re-enabled, fix this code to not output required for e-mail
5476 # $ret = array( 'required' );
5479 # We can't actually do this right now, because Opera 9.6 will print out
5480 # the entered password visibly in its error message! When other
5481 # browsers add support for this attribute, or Opera fixes its support,
5482 # we can add support with a version check to avoid doing this on Opera
5483 # versions where it will be a problem. Reported to Opera as
5484 # DSK-262266, but they don't have a public bug tracker for us to follow.
5509 'user_email_authenticated',
5511 'user_email_token_expires',
5512 'user_registration',
5528 foreach ( self::getGroupsWithPermission( $permission )
as $group ) {
5549 if ( !$this->
getId() ) {
5554 if ( !
$user->loadFromId( self::READ_EXCLUSIVE ) ) {
static getDefaultOption( $opt)
Get a given default option value.
saveOptions()
Saves the non-default options for this user, as previously set e.g.
$wgHiddenPrefs
An array of preferences to not show for the user.
prevents( $action, $x=null)
Get/set whether the Block prevents a given action.
static passwordChangeInputAttribs()
Provide an array of HTML5 attributes to put on an input element intended for the user to enter a new ...
static getPreferences( $user, IContextSource $context)
updateNewtalk( $field, $id, $curRev=null)
Add or update the new messages flag.
setCookie( $name, $value, $exp=0, $secure=null, $params=[], $request=null)
Set a cookie on the user's client.
loadFromId( $flags=self::READ_NORMAL)
Load user table data, given mId has already been set.
load( $flags=self::READ_NORMAL)
Load the user table data for this object from the source given by mFrom.
getNewtalk()
Check if the user has new messages.
$mOptionsLoaded
Bool Whether the cache variables have been loaded.
$wgProxyWhitelist
Proxy whitelist, list of addresses that are assumed to be non-proxy despite what the other methods mi...
inDnsBlacklist( $ip, $bases)
Whether the given IP is in a given DNS blacklist.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
static newFromId( $id)
Static factory method for creation from a given user ID.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
confirmationTokenUrl( $token)
Return a URL the user can use to confirm their email address.
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
$wgProxyList
Big list of banned IP addresses.
clearSharedCache( $mode='changed')
Clear user data from memcached.
wfCanIPUseHTTPS( $ip)
Determine whether the client at a given source IP is likely to be able to access the wiki via HTTPS.
processing should stop and the error should be shown to the user * false
static getLocalClusterInstance()
Get the main cluster-local cache object.
isValidPassword( $password)
Is the input a valid password for this user?
getId()
Get the user's ID.
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
static makeGroupLinkWiki( $group, $text='')
Create a link to the group in Wikitext, if available; else return the group name.
useFilePatrol()
Check whether to enable new files patrol features for this user.
$wgMaxArticleSize
Maximum article size in kilobytes.
static hmac( $data, $key, $raw=true)
Generate an acceptably unstable one-way-hmac of some text making use of the best hash algorithm that ...
isAnon()
Get whether the user is anonymous.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
static clearCookie(WebResponse $response)
Unset the 'BlockID' cookie.
getTokenUrl( $page, $token)
Internal function to format the e-mail validation/invalidation URLs.
static isLocallyBlockedProxy( $ip)
Check if an IP address is in the local proxy list.
$wgRevokePermissions
Permission keys revoked from users in each group.
resetTokenFromOption( $oname)
Reset a token stored in the preferences (like the watchlist one).
$wgBlockAllowsUTEdit
Set this to true to allow blocked users to edit their own user talk page.
loadFromUserObject( $user)
Load the data for this user object from another user object.
static newFatalPermissionDeniedStatus( $permission)
Factory function for fatal permission-denied errors.
getEditTokenObject( $salt='', $request=null)
Initialize (if necessary) and return a session token value which can be used in edit forms to show th...
$wgShowUpdatedMarker
Show "Updated (since my last visit)" marker in RC view, watchlist and history view for watched pages ...
static isInRanges( $ip, $ranges)
Determines if an IP address is a list of CIDR a.b.c.d/n ranges.
static newFromID( $id)
Load a blocked user from their block id.
newTouchedTimestamp()
Generate a current or new-future timestamp to be stored in the user_touched field when we update thin...
$wgExperiencedUserMemberSince
Name of the external diff engine to use.
getEditCount()
Get the user's edit count.
spreadBlock()
If this (non-anonymous) user is blocked, block the IP address they've successfully logged in from.
Deferrable Update for closure/callback updates that should use auto-commit mode.
incEditCount()
Deferred version of incEditCountImmediate()
static newFromSession(WebRequest $request=null)
Create a new user object using data from session.
wfGetLB( $wiki=false)
Get a load balancer object.
static send( $to, $from, $subject, $body, $options=[])
This function will perform a direct (authenticated) login to a SMTP Server to use for mail relaying i...
getOptionKinds(IContextSource $context, $options=null)
Return an associative array mapping preferences keys to the kind of a preference they're used for.
static chooseBlock(array $blocks, array $ipChain)
From a list of multiple blocks, find the most exact and strongest Block.
getBlock( $bFromSlave=true)
Get the block affecting the user, or null if the user is not blocked.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
isEmailConfirmationPending()
Check whether there is an outstanding request for e-mail confirmation.
getBlockId()
If user is blocked, return the ID for the block.
getIntOption( $oname, $defaultOverride=0)
Get the user's current setting for a given option, as an integer value.
getOptions( $flags=0)
Get all user's options.
static getGroupName( $group)
Gets the localized friendly name for a group, if it exists.
string $mTouched
TS_MW timestamp from the DB.
__construct()
Lightweight constructor for an anonymous user.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getToken( $forceCreation=true)
Get the user's current token.
spreadAnyEditBlock()
If this user is logged-in and blocked, block any IP address they've successfully logged in from.
string[] $wgSoftBlockRanges
IP ranges that should be considered soft-blocked (anon-only, account creation allowed).
getNewMessageRevisionId()
Get the revision ID for the last talk page revision viewed by the talk page owner.
loadDefaults( $name=false)
Set cached properties to default.
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
$wgEmailAuthentication
Require email authentication before sending mail to an email address.
$mNewtalk
Lazy-initialized variables, invalidated with clearInstanceCache.
loadOptions( $data=null)
Load the user options either from cache, the database or an array.
static makeGroupLinkHTML( $group, $text='')
Create a link to the group in HTML, if available; else return the group name.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
$wgDefaultUserOptions
Settings added to this array will override the default globals for the user preferences used by anony...
this hook is for auditing only $req
setNewpassword( $str, $throttle=true)
Set the password for a password reminder or new account email.
static addUpdate(DeferrableUpdate $update, $stage=self::POSTSEND)
Add an update to the deferred list to be run later by execute()
static newFatal( $message)
Factory function for fatal errors.
setEmailWithConfirmation( $str)
Set the user's e-mail address and a confirmation mail if needed.
$wgEnableUserEmail
Set to true to enable user-to-user e-mail.
getStubThreshold()
Get the user preferred stub threshold.
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
wfReadOnly()
Check whether the wiki is in read-only mode.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
loadFromRow( $row, $data=null)
Initialize this object from a row from the user table.
setEmailAuthenticationTimestamp( $timestamp)
Set the e-mail authentication timestamp.
static isIPv6( $ip)
Given a string, determine if it as valid IP in IPv6 only.
getUserPage()
Get this user's personal page title.
getGroups()
Get the list of explicit group memberships this user has.
getBlockFromCookieValue( $blockCookieVal)
Try to load a Block from an ID given in a cookie value.
static generateRandomPasswordString( $minLength=10)
Generate a random string suitable for a password.
static generateHex( $chars, $forceStrong=false)
Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format.
useNPPatrol()
Check whether to enable new pages patrol features for this user.
static getDBOptions( $bitfield)
Get an appropriate DB index, options, and fallback DB index for a query.
Allows to change the fields on the form that will be generated $name
getDatePreference()
Get the user's preferred date format.
isSafeToLoad()
Test if it's safe to load this User object.
static getEditTokenTimestamp( $val)
Get the embedded timestamp from a token.
setEmail( $str)
Set the user's e-mail address.
idForName( $flags=0)
If only this user's username is known, and it exists, return the user ID.
static isValidUserName( $name)
Is the input a valid username?
sendConfirmationMail( $type='created')
Generate a new e-mail confirmation token and send a confirmation/invalidation mail to the user's give...
static groupHasPermission( $group, $role)
Check, if the given group has the given permission.
getEmailAuthenticationTimestamp()
Get the timestamp of the user's e-mail authentication.
pingLimiter( $action='edit', $incrBy=1)
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.
$mFrom
String Initialization data source if mLoadedItems!==true.
initEditCount( $add=0)
Initialize user_editcount from data out of the revision table.
Interface for database access objects.
useRCPatrol()
Check whether to enable recent changes patrol features for this user.
invalidateEmail()
Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already co...
static getGroupPage( $group)
Gets the title of a page describing a particular user group.
static newFromRow( $row, $data=null)
Create a new user object from a user row.
$wgUseRCPatrol
Use RC Patrolling to check for vandalism (from recent changes and watchlists) New pages and new files...
loadGroups()
Load the groups from the database if they aren't already loaded.
$wgUseNPPatrol
Use new page patrolling to check new pages on Special:Newpages.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
isIPRange()
Is the user an IP range?
deleteNewtalk( $field, $id)
Clear the new messages flag for the given user.
static newFromUser(User $user)
Create a new MailAddress object for the given user.
equals(User $user)
Checks if two user objects point to the same user.
static $mCacheVars
Array of Strings List of member variables which are saved to the shared cache (memcached).
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
The ContentHandler facility adds support for arbitrary content types on wiki pages
getRights()
Get the permissions this user has.
$wgClockSkewFudge
Clock skew or the one-second resolution of time() can occasionally cause cache problems when the user...
static createNew( $name, $params=[])
Add a user to the database, return the user object.
getRequest()
Get the WebRequest object to use with this object.
static getSaveBlacklist()
getAutomaticGroups( $recache=false)
Get the list of implicit group memberships this user has.
const INVALID_TOKEN
@const string An invalid value for user_token
setPassword( $str)
Set the password and reset the random token.
array $mGroupMemberships
Associative array of (group name => UserGroupMembership object)
static getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...
getInstanceForUpdate()
Get a new instance of this user that was loaded from the master via a locking read.
$wgMaxNameChars
Maximum number of bytes in username.
array $mGroups
No longer used since 1.29; use User::getGroups() instead.
const READ_LOCKING
Constants for object loading bitfield flags (higher => higher QoS)
isBlockedFrom( $title, $bFromSlave=false)
Check if user is blocked from editing a particular article.
$wgExperiencedUserEdits
Name of the external diff engine to use.
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.
static getMembershipsForUser( $userId, IDatabase $db=null)
Returns UserGroupMembership objects for all the groups a user currently belongs to.
addGroup( $group, $expiry=null)
Add the user to the given group.
Stores a single person's name and email address.
Value object representing a logged-out user's edit token.
matchEditToken( $val, $salt='', $request=null, $maxage=null)
Check given value against the token value stored in the session.
getEmail()
Get the user's e-mail address.
static addCallableUpdate( $callable, $stage=self::POSTSEND, IDatabase $dbw=null)
Add a callable update.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an article
getTalkPage()
Get this user's talk page title.
addToDatabase()
Add this existing user object to the database.
makeUpdateConditions(Database $db, array $conditions)
Builds update conditions.
static isValidRange( $ipRange)
Validate an IP range (valid address with a valid CIDR prefix).
invalidateCache()
Immediately touch the user data cache for this account.
setInternalPassword( $str)
Set the password and reset the random token unconditionally.
invalidationTokenUrl( $token)
Return a URL the user can use to invalidate their email address.
namespace and then decline to actually register it file or subcat img or subcat $title
isLocked()
Check if user account is locked.
string null $wgAuthenticationTokenVersion
Versioning for authentication tokens.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
checkPasswordValidity( $password)
Check if this is a valid password for this user.
static normalizeKey( $key)
Normalize a skin preference value to a form that can be loaded.
confirmEmail()
Mark the e-mail address confirmed.
setItemLoaded( $item)
Set that an item has been loaded.
static getPasswordFactory()
Lazily instantiate and return a factory object for making passwords.
static getLink( $ugm, IContextSource $context, $format, $userName=null)
Gets a link for a user group, possibly including the expiry date if relevant.
blockedFor()
If user is blocked, return the specified reason for the block.
setNewtalk( $val, $curRev=null)
Update the 'You have new messages!' status.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Block $mBlockedFromCreateAccount
null for the wiki Added in
isAllowedToCreateAccount()
Get whether the user is allowed to create an account.
logout()
Log this user out.
confirmationToken(&$expiration)
Generate, store, and return a new e-mail confirmation code.
getCacheKey(WANObjectCache $cache)
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
static getImplicitGroups()
Get a list of implicit groups.
isHidden()
Check if user account is hidden.
static randomPassword()
Return a random password.
static newFromRow( $row)
Creates a new UserGroupMembership object from a database row.
static getSubnet( $ip)
Returns the subnet of a given IP.
isBlockedFromEmailuser()
Get whether the user is blocked from using Special:Emailuser.
static isIP( $name)
Does the string match an anonymous IP address?
validateCache( $timestamp)
Validate the cache for this account.
getEffectiveGroups( $recache=false)
Get the list of implicit group memberships this user has.
isPingLimitable()
Is this user subject to rate limiting?
removeGroup( $group)
Remove the user from the given group.
canReceiveEmail()
Is this user allowed to receive e-mails within limits of current site configuration?
$wgImplicitGroups
Implicit groups, aren't shown on Special:Listusers or somewhere else.
isNewbie()
Determine whether the user is a newbie.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
touch()
Update the "touched" timestamp for the user.
$wgExtendedLoginCookieExpiration
Default login cookie lifetime, in seconds.
clearInstanceCache( $reloadFrom=false)
Clear various cached data stored in this object.
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
$wgEnableDnsBlacklist
Whether to use DNS blacklists in $wgDnsBlacklistUrls to check for open proxies.
const TOKEN_LENGTH
@const int Number of characters in user_token field.
$wgDefaultSkin
Default skin, for new users and anonymous visitors.
$wgUpdateRowsPerQuery
Number of rows to update per query.
see documentation in includes Linker php for Linker::makeImageLink & $time
$wgReservedUsernames
Array of usernames which may not be registered or logged in from Maintenance scripts can still use th...
clearCookie( $name, $secure=null, $params=[])
Clear a cookie on the user's client.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
when a variable name is used in a it is silently declared as a new masking the global
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
addWatch( $title, $checkRights=self::CHECK_USER_RIGHTS)
Watch an article.
string $mQuickTouched
TS_MW timestamp from cache.
setName( $str)
Set the user name.
resetOptions( $resetKinds=[ 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused'], IContextSource $context=null)
Reset certain (or all) options to the site defaults.
Check if a user's password complies with any password policies that apply to that user,...
$wgUseFilePatrol
Use file patrolling to check new files on Special:Newfiles.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
$mLoadedItems
Array with already loaded items or true if all items have been loaded.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
clearNotification(&$title, $oldid=0)
Clear the user's notification timestamp for the given title.
saveSettings()
Save this user's settings into the database.
addNewUserLogEntry( $action=false, $reason='')
Add a newuser log entry for this user.
static getBlocksForIPList(array $ipChain, $isAnon, $fromMaster=false)
Get all blocks that match any IP from an array of IP addresses.
static $mCoreRights
Array of Strings Core rights.
foreach( $wgExtensionFunctions as $func) if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised
getFirstEditTimestamp()
Get the timestamp of the first edit.
$wgAutopromoteOnceLogInRC
Put user rights log entries for autopromotion in recent changes?
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
const GETOPTIONS_EXCLUDE_DEFAULTS
Exclude user options that are set to their default value.
setRealName( $str)
Set the user's real name.
const EDIT_TOKEN_SUFFIX
Global constant made accessible as class constants so that autoloader magic can be used.
getNewMessageLinks()
Return the data needed to construct links for new talk page message alerts.
setExtendedLoginCookie( $name, $value, $secure)
Set an extended login cookie on the user's client.
$wgCookieExpiration
Default cookie lifetime, in seconds.
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
getBlockedStatus( $bFromSlave=true)
Get blocking information.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
getFormerGroups()
Returns the groups the user has belonged to.
static whoIs( $id)
Get the username corresponding to a given user ID.
static getIdFromCookieValue( $cookieValue)
Get the stored ID from the 'BlockID' cookie.
static hasFlags( $bitfield, $flags)
incEditCountImmediate()
Increment the user's edit-count field.
loadFromSession()
Load user data from the session.
$wgRateLimits
Simple rate limiter options to brake edit floods.
isBlockedGlobally( $ip='')
Check if user is blocked on all wikis.
getOption( $oname, $defaultOverride=null, $ignoreHidden=false)
Get the user's current setting for a given option.
static newGood( $value=null)
Factory function for good results.
isDnsBlacklisted( $ip, $checkWhitelist=false)
Whether the given IP is in a DNS blacklist.
getTouched()
Get the user touched timestamp.
getGlobalBlock( $ip='')
Check if user is blocked on all wikis.
const GAID_FOR_UPDATE
Used to be GAID_FOR_UPDATE define.
checkAndSetTouched()
Bump user_touched if it didn't change since this object was loaded.
Multi-datacenter aware caching interface.
getRealName()
Get the user's real name.
setCookies( $request=null, $secure=null, $rememberMe=false)
Persist this user's session (e.g.
static getGroupPermissions( $groups)
Get the permissions associated with a given list of groups.
static getGroupPage( $group)
Get the title of a page describing a particular group.
changeableGroups()
Returns an array of groups that this user can add and remove.
clearAllNotifications()
Resets all of the given user's page-change notification timestamps.
const VERSION
@const int Serialized record version.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
matchEditTokenNoSuffix( $val, $salt='', $request=null, $maxage=null)
Check given value against the token value stored in the session, ignoring the suffix.
$wgAddGroups
$wgAddGroups and $wgRemoveGroups can be used to give finer control over who can assign which groups a...
checkPassword( $password)
Check to see if the given clear-text password is one of the accepted passwords.
static getAllGroups()
Return the set of defined explicit groups.
removeWatch( $title, $checkRights=self::CHECK_USER_RIGHTS)
Stop watching an article.
static getAllRights()
Get a list of all available permissions.
$wgInvalidUsernameCharacters
Characters to prevent during new account creations.
static getMain()
Static methods.
blockedBy()
If user is blocked, return the name of the user who placed the block.
$wgLearnerEdits
The following variables define 3 user experience levels:
getDBTouched()
Get the user_touched timestamp field (time of last DB updates)
static getGroupMember( $group, $username='#')
Get the localized descriptive name for a member of a group, if it exists.
static isIPv4( $ip)
Given a string, determine if it as valid IP in IPv4 only.
Interface for objects which can provide a MediaWiki context on request.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
static changeableByGroup( $group)
Returns an array of the groups that a particular group can add/remove.
static getGroupName( $group)
Get the localized descriptive name for a group, if it exists.
setId( $v)
Set the user and reload all fields according to a given ID.
getExperienceLevel()
Compute experienced level based on edit count and registration date.
$wgUserEmailConfirmationTokenExpiry
The time, in seconds, when an email confirmation email expires.
getRegistration()
Get the timestamp of account creation.
static newInvalidPassword()
Create an InvalidPassword.
static sanitizeIP( $ip)
Convert an IP into a verbose, uppercase, normalized form.
static isEveryoneAllowed( $right)
Check if all users may be assumed to have the given permission.
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
isAllowedAny()
Check if user is allowed to access a feature / make an action.
static getRightDescription( $right)
Get the description of a given right.
changeAuthenticationData(array $data)
Changes credentials of the user.
$wgAvailableRights
A list of available rights, in addition to the ones defined by the core.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
$wgRateLimitsExcludedIPs
Array of IPs / CIDR ranges which should be excluded from rate limits.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
static getMainWANInstance()
Get the main WAN cache object.
$wgApplyIpBlocksToXff
Whether to look at the X-Forwarded-For header's list of (potentially spoofed) IPs and apply IP blocks...
isLoggedIn()
Get whether the user is logged in.
checkTemporaryPassword( $plaintext)
Check if the given clear-text password matches the temporary password sent by e-mail for password res...
getTitleKey()
Get the user's name escaped by underscores.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
setToken( $token=false)
Set the random token (used for persistent authentication) Called from loadDefaults() among other plac...
static idFromName( $name, $flags=self::READ_NORMAL)
Get database id given a user name.
$wgGroupPermissions
Permission keys given to users in each group.
static resetIdByNameCache()
Reset the cache used in idFromName().
string $mEmailTokenExpires
static findUsersByGroup( $groups, $limit=5000, $after=null)
Return the users who are members of the given group(s).
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
isEmailConfirmed()
Is this user's e-mail address valid-looking and confirmed within limits of the current site configura...
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static getGrantName( $grant)
Get the name of a given grant.
static loadFromTimestamp( $db, $title, $timestamp)
Load the revision for the given title with the given timestamp.
$wgDnsBlacklistUrls
List of DNS blacklists to use, if $wgEnableDnsBlacklist is true.
loadFromCache()
Load user data from shared cache, given mId has already been set.
$wgLearnerMemberSince
Name of the external diff engine to use.
addAutopromoteOnceGroups( $event)
Add the user to the group if he/she meets given criteria.
sendMail( $subject, $body, $from=null, $replyto=null)
Send an e-mail to this user's account.
getTokenFromOption( $oname)
Get a token stored in the preferences (like the watchlist one), resetting it if it's empty (and savin...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Class for creating log entries manually, to inject them into the database.
checkNewtalk( $field, $id)
Internal uncached check for new messages.
loadFromDatabase( $flags=self::READ_LATEST)
Load user and user_group data from the database.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
static selectFields()
Return the list of user fields that should be selected to create a new user object.
Factory class for creating and checking Password objects.
$wgPasswordPolicy
Password policy for local wiki users.
addNewUserLogEntryAutoCreate()
Add an autocreate newuser log entry for this user Used by things like CentralAuth and perhaps other a...
static newFromConfirmationCode( $code, $flags=0)
Factory method to fetch whichever user has a given email confirmation code.
if(! $wgDBerrorLogTZ) $wgRequest
isWatched( $title, $checkRights=self::CHECK_USER_RIGHTS)
Check the watched status of an article.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
static getMembership( $userId, $group, IDatabase $db=null)
Returns a UserGroupMembership object that pertains to the given user and group, or false if the user ...
getBoolOption( $oname)
Get the user's current setting for a given option, as a boolean value.
$wgMinimalPasswordLength
Specifies the minimal length of a user password.
$wgGroupsAddToSelf
A map of group names that the user is in, to group names that those users are allowed to add or revok...
static isUsableName( $name)
Usernames which fail to pass this function will be blocked from user login and new account registrati...
isBlocked( $bFromSlave=true)
Check if user is blocked.
static factory( $providerId=null)
Fetch a CentralIdLookup.
$wgPasswordSender
Sender email address for e-mail notifications.
isBlockedFromCreateAccount()
Get whether the user is explicitly blocked from account creation.
getEditToken( $salt='', $request=null)
Initialize (if necessary) and return a session token value which can be used in edit forms to show th...
requiresHTTPS()
Determine based on the wiki configuration and the user's options, whether this user must be over HTTP...
static $mAllRights
String Cached results of getAllRights()
isItemLoaded( $item, $all='all')
Return whether an item has been loaded.
static purge( $wikiId, $userId)
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
setOption( $oname, $val)
Set the given option for a user.
int $queryFlagsUsed
User::READ_* constant bitfield used to load data.
this hook is for auditing only or null if authentication failed before getting that far $username
getPasswordValidity( $password)
Given unvalidated password input, return error message on failure.
static whoIsReal( $id)
Get the real name of a user given their user ID.
getName()
Get the user name, or the IP of an anonymous user.
$wgSecureLogin
This is to let user authenticate using https when they come from http.
static getGroupMemberName( $group, $username)
Gets the localized name for a member of a group, if it exists.
doLogout()
Clear the user's session, and reset the instance cache.
getGroupMemberships()
Get the list of explicit group memberships this user has, stored as UserGroupMembership objects.
canSendEmail()
Is this user allowed to send e-mails within limits of current site configuration?
static isCreatableName( $name)
Usernames which fail to pass this function will be blocked from new account registrations,...
$wgNamespacesToBeSearchedDefault
List of namespaces which are searched by default.
getMutableCacheKeys(WANObjectCache $cache)
it s the revision text itself In either if gzip is the revision text is gzipped $flags
setPasswordInternal( $str)
Actually set the password and such.
$wgDisableAnonTalk
Disable links to talk pages of anonymous users (IPs) in listings on special pages like page history,...
Represents a "user group membership" – a specific instance of a user belonging to a group.
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
string $mEmailAuthenticated
the array() calling protocol came about after MediaWiki 1.4rc1.
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
isAllowed( $action='')
Internal mechanics of testing a permission.
static logException( $e, $catcher=self::CAUGHT_BY_OTHER)
Log an exception to the exception log (if enabled).
static listOptionKinds()
Return a list of the types of user options currently returned by User::getOptionKinds().
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang