Go to the documentation of this file.
29 use Wikimedia\ScopedCallback;
38 define(
'EDIT_TOKEN_SUFFIX', Token::SUFFIX );
103 'mEmailAuthenticated',
105 'mEmailTokenExpires',
163 'move-categorypages',
164 'move-rootuserpages',
168 'override-export-depth',
190 'userrights-interwiki',
333 return (
string)$this->
getName();
359 $this->mLoadedItems ===
true || $this->mFrom !==
'session';
370 if ( $this->mLoadedItems ===
true ) {
376 $this->mLoadedItems =
true;
377 $this->queryFlagsUsed =
$flags;
382 ->warning(
'User::loadFromSession called before the end of Setup.php', [
383 'exception' =>
new Exception(
'User::loadFromSession called before the end of Setup.php' ),
386 $this->mLoadedItems = $oldLoadedItems;
390 switch ( $this->mFrom ) {
396 if (
wfGetLB()->hasOrMadeRecentMasterChanges() ) {
397 $flags |= self::READ_LATEST;
398 $this->queryFlagsUsed =
$flags;
417 Hooks::run(
'UserLoadAfterLoadFromSession', [ $this ] );
420 throw new UnexpectedValueException(
421 "Unrecognised value for User->mFrom: \"{$this->mFrom}\"" );
431 if ( $this->mId == 0 ) {
449 $this->mLoadedItems =
true;
450 $this->queryFlagsUsed =
$flags;
460 public static function purge( $wikiId, $userId ) {
462 $key =
$cache->makeGlobalKey(
'user',
'id', $wikiId, $userId );
472 return $cache->makeGlobalKey(
'user',
'id',
wfWikiID(), $this->mId );
481 $id = $this->
getId();
483 return $id ? [ $this->
getCacheKey( $cache ) ] : [];
494 $data =
$cache->getWithSetCallback(
499 wfDebug(
"User: cache miss for user {$this->mId}\n" );
506 foreach ( self::$mCacheVars
as $name ) {
507 $data[
$name] = $this->$name;
514 foreach ( $this->mGroupMemberships
as $ugm ) {
515 if ( $ugm->getExpiry() ) {
516 $secondsUntilExpiry =
wfTimestamp( TS_UNIX, $ugm->getExpiry() ) - time();
517 if ( $secondsUntilExpiry > 0 && $secondsUntilExpiry < $ttl ) {
518 $ttl = $secondsUntilExpiry;
526 [
'pcTTL' => $cache::TTL_PROC_LONG,
'version' =>
self::VERSION ]
530 foreach ( self::$mCacheVars
as $name ) {
531 $this->$name = $data[
$name];
557 if ( $validate ===
true ) {
561 if (
$name ===
false ) {
568 $u->setItemLoaded(
'name' );
583 $u->setItemLoaded(
'id' );
599 $db = (
$flags & self::READ_LATEST ) == self::READ_LATEST
603 $id = $db->selectField(
607 'user_email_token' => md5(
$code ),
608 'user_email_token_expires > ' . $db->addQuotes( $db->timestamp() ),
624 $user->mFrom =
'session';
645 $user->loadFromRow( $row, $data );
686 'validate' =>
'valid',
692 if (
$name ===
false ) {
699 $row = $dbw->selectRow(
702 [
'user_name' =>
$name ],
713 if (
$user->mEmail ||
$user->mToken !== self::INVALID_TOKEN ||
714 AuthManager::singleton()->userCanAuthenticate(
$name )
721 AuthManager::singleton()->revokeAccessForUser(
$name );
723 $user->invalidateEmail();
725 $user->saveSettings();
726 SessionManager::singleton()->preventSessionsForUser(
$user->getName() );
739 public static function whoIs( $id ) {
761 if ( is_null( $nt ) ) {
766 if ( !(
$flags & self::READ_LATEST ) && isset( self::$idCacheByName[
$name] ) ) {
767 return self::$idCacheByName[
$name];
776 [
'user_name' => $nt->getText() ],
781 if (
$s ===
false ) {
789 if (
count( self::$idCacheByName ) > 1000 ) {
790 self::$idCacheByName = [];
800 self::$idCacheByName = [];
820 return preg_match(
'/^\d{1,3}\.\d{1,3}\.\d{1,3}\.(?:xxx|\d{1,3})$/',
$name )
840 || strpos(
$name,
'/' ) !==
false
841 || strlen(
$name ) > $wgMaxNameChars
850 if ( is_null( $parsed )
851 || $parsed->getNamespace()
852 || strcmp(
$name, $parsed->getPrefixedText() ) ) {
858 $unicodeBlacklist =
'/[' .
859 '\x{0080}-\x{009f}' . # iso-8859-1 control chars
860 '\x{00a0}' . # non-breaking space
861 '\x{2000}-\x{200f}' . # various whitespace
862 '\x{2028}-\x{202f}' . # breaks
and control chars
863 '\x{3000}' . # ideographic space
864 '\x{e000}-\x{f8ff}' . #
private use
866 if ( preg_match( $unicodeBlacklist,
$name ) ) {
885 global $wgReservedUsernames;
887 if ( !self::isValidUserName(
$name ) ) {
891 static $reservedUsernames =
false;
892 if ( !$reservedUsernames ) {
893 $reservedUsernames = $wgReservedUsernames;
894 Hooks::run(
'UserGetReservedNames', [ &$reservedUsernames ] );
898 foreach ( $reservedUsernames
as $reserved ) {
899 if ( substr( $reserved, 0, 4 ) ==
'msg:' ) {
900 $reserved =
wfMessage( substr( $reserved, 4 ) )->inContentLanguage()->text();
902 if ( $reserved ==
$name ) {
920 if ( $groups === [] ) {
924 $groups = array_unique( (
array)$groups );
927 $conds = [
'ug_group' => $groups ];
928 if ( $after !==
null ) {
929 $conds[] =
'ug_user > ' . (int)$after;
933 $ids =
$dbr->selectFieldValues(
940 'ORDER BY' =>
'ug_user',
960 global $wgInvalidUsernameCharacters;
965 if ( strlen(
$name ) > 235 ) {
967 ": '$name' invalid due to length" );
972 if ( $wgInvalidUsernameCharacters !==
'' ) {
973 if ( preg_match(
'/[' . preg_quote( $wgInvalidUsernameCharacters,
'/' ) .
']/',
$name ) ) {
975 ": '$name' invalid due to wgInvalidUsernameCharacters" );
1006 foreach (
$result->getErrorsByType(
'error' )
as $error ) {
1009 foreach (
$result->getErrorsByType(
'warning' )
as $warning ) {
1037 global $wgPasswordPolicy;
1040 $wgPasswordPolicy[
'policies'],
1041 $wgPasswordPolicy[
'checks']
1053 $status->merge( $upp->checkUserPassword( $this, $password ) );
1055 } elseif (
$result ===
true ) {
1081 # Reject names containing '#'; these will be cleaned up
1082 # with title normalisation, but then it's too late to
1084 if ( strpos(
$name,
'#' ) !==
false ) {
1090 $t = ( $validate !==
false ) ?
1093 if ( is_null(
$t ) ||
$t->getNamespace() !==
NS_USER ||
$t->isExternal() ) {
1098 $name = AuthManager::callLegacyAuthPlugin(
1099 'getCanonicalName', [
$t->getText() ],
$t->getText()
1102 switch ( $validate ) {
1121 throw new InvalidArgumentException(
1122 'Invalid parameter value for $validate in ' . __METHOD__ );
1134 global $wgMinimalPasswordLength;
1148 $this->mName =
$name;
1149 $this->mRealName =
'';
1151 $this->mOptionOverrides =
null;
1152 $this->mOptionsLoaded =
false;
1154 $loggedOut = $this->mRequest && !defined(
'MW_NO_SESSION' )
1155 ? $this->mRequest->getSession()->getLoggedOutTimestamp() : 0;
1156 if ( $loggedOut !== 0 ) {
1157 $this->mTouched =
wfTimestamp( TS_MW, $loggedOut );
1159 $this->mTouched =
'1'; # Allow
any pages to be cached
1162 $this->mToken =
null;
1163 $this->mEmailAuthenticated =
null;
1164 $this->mEmailToken =
'';
1165 $this->mEmailTokenExpires =
null;
1167 $this->mGroupMemberships = [];
1185 return ( $this->mLoadedItems ===
true && $all ===
'all' ) ||
1186 ( isset( $this->mLoadedItems[$item] ) && $this->mLoadedItems[$item] ===
true );
1195 if ( is_array( $this->mLoadedItems ) ) {
1196 $this->mLoadedItems[$item] =
true;
1215 $session = $this->
getRequest()->getSession();
1216 $user = $session->getUser();
1217 if (
$user->isLoggedIn() ) {
1224 if ( $config->get(
'CookieSetOnAutoblock' ) ===
true ) {
1226 $shouldSetCookie = $this->
getRequest()->getCookie(
'BlockID' ) ===
null
1229 && $block->isAutoblocking();
1230 if ( $shouldSetCookie ) {
1231 wfDebug( __METHOD__ .
': User is autoblocked, setting cookie to track' );
1232 $block->setCookie( $this->
getRequest()->response() );
1237 $session->set(
'wsUserID', $this->
getId() );
1238 $session->set(
'wsUserName', $this->
getName() );
1239 $session->set(
'wsToken', $this->
getToken() );
1254 $this->mId = intval( $this->mId );
1256 if ( !$this->mId ) {
1265 $s = $db->selectRow(
1267 self::selectFields(),
1268 [
'user_id' => $this->mId ],
1273 $this->queryFlagsUsed =
$flags;
1276 if (
$s !==
false ) {
1279 $this->mGroupMemberships =
null;
1305 $this->mGroupMemberships =
null;
1307 if ( isset( $row->user_name ) ) {
1308 $this->mName = $row->user_name;
1309 $this->mFrom =
'name';
1315 if ( isset( $row->user_real_name ) ) {
1316 $this->mRealName = $row->user_real_name;
1322 if ( isset( $row->user_id ) ) {
1323 $this->mId = intval( $row->user_id );
1324 $this->mFrom =
'id';
1330 if ( isset( $row->user_id ) && isset( $row->user_name ) ) {
1331 self::$idCacheByName[$row->user_name] = $row->user_id;
1334 if ( isset( $row->user_editcount ) ) {
1335 $this->mEditCount = $row->user_editcount;
1340 if ( isset( $row->user_touched ) ) {
1341 $this->mTouched =
wfTimestamp( TS_MW, $row->user_touched );
1346 if ( isset( $row->user_token ) ) {
1350 $this->mToken = rtrim( $row->user_token,
" \0" );
1351 if ( $this->mToken ===
'' ) {
1352 $this->mToken =
null;
1358 if ( isset( $row->user_email ) ) {
1359 $this->mEmail = $row->user_email;
1360 $this->mEmailAuthenticated =
wfTimestampOrNull( TS_MW, $row->user_email_authenticated );
1361 $this->mEmailToken = $row->user_email_token;
1362 $this->mEmailTokenExpires =
wfTimestampOrNull( TS_MW, $row->user_email_token_expires );
1369 $this->mLoadedItems =
true;
1372 if ( is_array( $data ) ) {
1373 if ( isset( $data[
'user_groups'] ) && is_array( $data[
'user_groups'] ) ) {
1374 if ( !
count( $data[
'user_groups'] ) ) {
1375 $this->mGroupMemberships = [];
1377 $firstGroup = reset( $data[
'user_groups'] );
1378 if ( is_array( $firstGroup ) || is_object( $firstGroup ) ) {
1379 $this->mGroupMemberships = [];
1380 foreach ( $data[
'user_groups']
as $row ) {
1382 $this->mGroupMemberships[$ugm->getGroup()] = $ugm;
1387 if ( isset( $data[
'user_properties'] ) && is_array( $data[
'user_properties'] ) ) {
1400 foreach ( self::$mCacheVars
as $var ) {
1401 $this->$var =
$user->$var;
1409 if ( is_null( $this->mGroupMemberships ) ) {
1410 $db = ( $this->queryFlagsUsed & self::READ_LATEST )
1433 global $wgAutopromoteOnceLogInRC;
1440 if ( !
count( $toPromote ) ) {
1449 foreach ( $toPromote
as $group ) {
1453 Hooks::run(
'UserGroupsChanged', [ $this, $toPromote, [],
false,
false ] );
1454 AuthManager::callLegacyAuthPlugin(
'updateExternalDBGroups', [ $this, $toPromote ] );
1456 $newGroups = array_merge( $oldGroups, $toPromote );
1459 $logEntry->setPerformer( $this );
1461 $logEntry->setParameters( [
1462 '4::oldgroups' => $oldGroups,
1463 '5::newgroups' => $newGroups,
1465 $logid = $logEntry->insert();
1466 if ( $wgAutopromoteOnceLogInRC ) {
1467 $logEntry->publish( $logid );
1483 if ( $this->mTouched ) {
1485 $conditions[
'user_touched'] = $db->
timestamp( $this->mTouched );
1503 if ( !$this->mId ) {
1511 $dbw->update(
'user',
1512 [
'user_touched' => $dbw->timestamp( $newTouched ) ],
1514 'user_id' => $this->mId,
1518 $success = ( $dbw->affectedRows() > 0 );
1521 $this->mTouched = $newTouched;
1539 $this->mNewtalk = -1;
1540 $this->mDatePreference =
null;
1541 $this->mBlockedby = -1; # Unset
1542 $this->mHash =
false;
1543 $this->mRights =
null;
1544 $this->mEffectiveGroups =
null;
1545 $this->mImplicitGroups =
null;
1546 $this->mGroupMemberships =
null;
1547 $this->mOptions =
null;
1548 $this->mOptionsLoaded =
false;
1549 $this->mEditCount =
null;
1551 if ( $reloadFrom ) {
1552 $this->mLoadedItems = [];
1553 $this->mFrom = $reloadFrom;
1566 static $defOpt =
null;
1567 static $defOptLang =
null;
1569 if ( $defOpt !==
null && $defOptLang ===
$wgContLang->getCode() ) {
1579 $defOpt[
'language'] = $defOptLang;
1580 foreach ( LanguageConverter::$languagesWithVariants
as $langCode ) {
1581 $defOpt[$langCode ==
$wgContLang->getCode() ?
'variant' :
"variant-$langCode"] = $langCode;
1587 foreach ( $wgNamespacesToBeSearchedDefault
as $nsnum => $val ) {
1588 $defOpt[
'searchNs' . $nsnum] = (
boolean)$val;
1592 Hooks::run(
'UserGetDefaultOptions', [ &$defOpt ] );
1605 if ( isset( $defOpts[
$opt] ) ) {
1606 return $defOpts[
$opt];
1619 global $wgProxyWhitelist,
$wgUser, $wgApplyIpBlocksToXff, $wgSoftBlockRanges;
1621 if ( -1 != $this->mBlockedby ) {
1625 wfDebug( __METHOD__ .
": checking...\n" );
1634 # We only need to worry about passing the IP address to the Block generator if the
1635 # user is not immune to autoblocks/hardblocks, and they are the current user so we
1636 # know which IP address they're actually coming from
1638 if ( !$this->
isAllowed(
'ipblock-exempt' ) ) {
1641 $globalUserName =
$wgUser->isSafeToLoad()
1644 if ( $this->
getName() === $globalUserName ) {
1653 if ( !$block instanceof
Block ) {
1658 if ( !$block instanceof
Block && $ip !==
null && !in_array( $ip, $wgProxyWhitelist ) ) {
1660 if ( self::isLocallyBlockedProxy( $ip ) ) {
1661 $block =
new Block( [
1665 'systemBlock' =>
'proxy',
1667 $this->blockTrigger =
'proxy-block';
1669 $block =
new Block( [
1673 'systemBlock' =>
'dnsbl',
1675 $this->blockTrigger =
'openproxy-block';
1680 if ( !$block instanceof
Block
1681 && $wgApplyIpBlocksToXff
1683 && !in_array( $ip, $wgProxyWhitelist )
1685 $xff = $this->
getRequest()->getHeader(
'X-Forwarded-For' );
1686 $xff = array_map(
'trim', explode(
',', $xff ) );
1687 $xff = array_diff( $xff, [ $ip ] );
1690 if ( $block instanceof
Block ) {
1691 # Mangle the reason to alert the user that the block
1692 # originated from matching the X-Forwarded-For header.
1693 $block->mReason =
wfMessage(
'xffblockreason', $block->mReason )->text();
1694 $this->blockTrigger =
'xff-block';
1698 if ( !$block instanceof
Block
1703 $block =
new Block( [
1705 'byText' =>
'MediaWiki default',
1706 'reason' =>
wfMessage(
'softblockrangesreason', $ip )->
text(),
1708 'systemBlock' =>
'wgSoftBlockRanges',
1710 $this->blockTrigger =
'config-block';
1713 if ( $block instanceof
Block ) {
1714 wfDebug( __METHOD__ .
": Found block.\n" );
1715 $this->mBlock = $block;
1716 $this->mBlockedby = $block->getByName();
1717 $this->mBlockreason = $block->mReason;
1718 $this->mHideName = $block->mHideName;
1719 $this->mAllowUsertalk = !$block->prevents(
'editownusertalk' );
1721 $this->mBlockedby =
'';
1722 $this->mHideName = 0;
1723 $this->mAllowUsertalk =
false;
1724 $this->blockTrigger =
false;
1740 if ( strlen( $blockCookieVal ) < 1 || !is_numeric( substr( $blockCookieVal, 0, 1 ) ) ) {
1745 if ( $blockCookieId !==
null ) {
1748 if ( $tmpBlock instanceof
Block ) {
1751 && !$tmpBlock->isExpired()
1752 && $tmpBlock->isAutoblocking();
1754 $useBlockCookie = ( $config->get(
'CookieSetOnAutoblock' ) ===
true );
1755 if ( $blockIsValid && $useBlockCookie ) {
1757 $this->blockTrigger =
'cookie-block';
1779 global $wgEnableDnsBlacklist, $wgDnsBlacklistUrls, $wgProxyWhitelist;
1781 if ( !$wgEnableDnsBlacklist ) {
1785 if ( $checkWhitelist && in_array( $ip, $wgProxyWhitelist ) ) {
1804 $ipReversed = implode(
'.', array_reverse( explode(
'.', $ip ) ) );
1810 if ( is_array(
$base ) ) {
1813 $host =
"{$base[1]}.$ipReversed.{$base[0]}";
1815 $host =
"$ipReversed.{$base[0]}";
1817 $basename =
$base[0];
1819 $host =
"$ipReversed.$base";
1823 $ipList = gethostbynamel( $host );
1826 wfDebugLog(
'dnsblacklist',
"Hostname $host is {$ipList[0]}, it's a proxy says $basename!" );
1830 wfDebugLog(
'dnsblacklist',
"Requested $host, not found in $basename." );
1848 if ( !$wgProxyList ) {
1852 if ( !is_array( $wgProxyList ) ) {
1854 $wgProxyList = array_map(
'trim',
file( $wgProxyList ) );
1857 if ( is_array( $wgProxyList ) ) {
1860 array_search( $ip, $wgProxyList ) !==
false ||
1862 array_key_exists( $ip, $wgProxyList )
1877 global $wgRateLimitsExcludedIPs;
1884 return !$this->
isAllowed(
'noratelimit' );
1911 if ( !isset( $wgRateLimits[$action] ) ) {
1915 $limits = array_merge(
1916 [
'&can-bypass' =>
true ],
1917 $wgRateLimits[$action]
1926 $id = $this->
getId();
1932 if ( isset( $limits[
'anon'] ) ) {
1933 $keys[
wfMemcKey(
'limiter', $action,
'anon' )] = $limits[
'anon'];
1937 if ( isset( $limits[
'user'] ) ) {
1938 $userLimit = $limits[
'user'];
1941 if ( $isNewbie && isset( $limits[
'newbie'] ) ) {
1942 $keys[
wfMemcKey(
'limiter', $action,
'user', $id )] = $limits[
'newbie'];
1949 if ( isset( $limits[
'ip'] ) ) {
1951 $keys[
"mediawiki:limiter:$action:ip:$ip"] = $limits[
'ip'];
1954 if ( isset( $limits[
'subnet'] ) ) {
1957 if ( $subnet !==
false ) {
1958 $keys[
"mediawiki:limiter:$action:subnet:$subnet"] = $limits[
'subnet'];
1966 if ( isset( $limits[$group] ) ) {
1967 if ( $userLimit ===
false
1968 || $limits[$group][0] / $limits[$group][1] > $userLimit[0] / $userLimit[1]
1970 $userLimit = $limits[$group];
1976 if ( $userLimit !==
false ) {
1977 list( $max, $period ) = $userLimit;
1978 wfDebug( __METHOD__ .
": effective user limit: $max in {$period}s\n" );
1979 $keys[
wfMemcKey(
'limiter', $action,
'user', $id )] = $userLimit;
1983 if ( isset( $limits[
'ip-all'] ) ) {
1986 if ( $isNewbie || $userLimit ===
false
1987 || $limits[
'ip-all'][0] / $limits[
'ip-all'][1] > $userLimit[0] / $userLimit[1] ) {
1988 $keys[
"mediawiki:limiter:$action:ip-all:$ip"] = $limits[
'ip-all'];
1993 if ( isset( $limits[
'subnet-all'] ) ) {
1996 if ( $subnet !==
false ) {
1998 if ( $isNewbie || $userLimit ===
false
1999 || $limits[
'ip-all'][0] / $limits[
'ip-all'][1]
2000 > $userLimit[0] / $userLimit[1] ) {
2001 $keys[
"mediawiki:limiter:$action:subnet-all:$subnet"] = $limits[
'subnet-all'];
2011 $summary =
"(limit $max in {$period}s)";
2012 $count =
$cache->get( $key );
2015 if ( $count >= $max ) {
2016 wfDebugLog(
'ratelimit',
"User '{$this->getName()}' " .
2017 "(IP {$this->getRequest()->getIP()}) tripped $key at $count $summary" );
2020 wfDebug( __METHOD__ .
": ok. $key at $count $summary\n" );
2023 wfDebug( __METHOD__ .
": adding record for $key $summary\n" );
2025 $cache->add( $key, 0, intval( $period ) );
2055 return $this->mBlock instanceof
Block ? $this->mBlock :
null;
2066 global $wgBlockAllowsUTEdit;
2068 $blocked = $this->
isBlocked( $bFromSlave );
2069 $allowUsertalk = ( $wgBlockAllowsUTEdit ? $this->mAllowUsertalk :
false );
2071 if ( !$this->mHideName && $allowUsertalk &&
$title->getText() === $this->
getName()
2074 wfDebug( __METHOD__ .
": self-talk page, ignoring any blocks\n" );
2077 Hooks::run(
'UserIsBlockedFrom', [ $this,
$title, &$blocked, &$allowUsertalk ] );
2106 return ( $this->mBlock ? $this->mBlock->getId() :
false );
2132 if ( $this->mGlobalBlock !==
null ) {
2133 return $this->mGlobalBlock ?:
null;
2145 Hooks::run(
'UserIsBlockedGlobally', [ &
$user, $ip, &$blocked, &$block ] );
2147 if ( $blocked && $block ===
null ) {
2149 $block =
new Block( [
2151 'systemBlock' =>
'global-block'
2155 $this->mGlobalBlock = $blocked ? $block :
false;
2156 return $this->mGlobalBlock ?:
null;
2165 if ( $this->mLocked !==
null ) {
2170 $authUser = AuthManager::callLegacyAuthPlugin(
'getUserInstance', [ &
$user ],
null );
2171 $this->mLocked = $authUser && $authUser->isLocked();
2172 Hooks::run(
'UserIsLocked', [ $this, &$this->mLocked ] );
2182 if ( $this->mHideName !==
null ) {
2186 if ( !$this->mHideName ) {
2189 $authUser = AuthManager::callLegacyAuthPlugin(
'getUserInstance', [ &
$user ],
null );
2190 $this->mHideName = $authUser && $authUser->isHidden();
2191 Hooks::run(
'UserIsHidden', [ $this, &$this->mHideName ] );
2201 if ( $this->mId ===
null && $this->mName !==
null &&
User::isIP( $this->mName ) ) {
2231 if ( $this->mName ===
false ) {
2254 $this->mName = $str;
2262 return str_replace(
' ',
'_', $this->
getName() );
2273 if ( $this->mNewtalk === -1 ) {
2274 $this->mNewtalk =
false; # reset talk
page status
2278 if ( !$this->mId ) {
2279 global $wgDisableAnonTalk;
2280 if ( $wgDisableAnonTalk ) {
2282 $this->mNewtalk =
false;
2287 $this->mNewtalk = $this->
checkNewtalk(
'user_id', $this->mId );
2319 $timestamp =
$dbr->selectField(
'user_newtalk',
2320 'MIN(user_last_timestamp)',
2321 $this->
isAnon() ? [
'user_ip' => $this->
getName() ] : [
'user_id' => $this->
getId() ],
2324 return [ [
'wiki' =>
wfWikiID(),
'link' => $utp->getLocalURL(),
'rev' =>
$rev ] ];
2333 $newMessageRevisionId =
null;
2335 if ( $newMessageLinks ) {
2339 if (
count( $newMessageLinks ) === 1
2340 && $newMessageLinks[0][
'wiki'] ===
wfWikiID()
2341 && $newMessageLinks[0][
'rev']
2344 $newMessageRevision = $newMessageLinks[0][
'rev'];
2345 $newMessageRevisionId = $newMessageRevision->getId();
2348 return $newMessageRevisionId;
2362 $ok =
$dbr->selectField(
'user_newtalk', $field, [ $field => $id ], __METHOD__ );
2364 return $ok !==
false;
2376 $prevRev = $curRev ? $curRev->getPrevious() :
false;
2377 $ts = $prevRev ? $prevRev->getTimestamp() :
null;
2380 $dbw->insert(
'user_newtalk',
2381 [ $field => $id,
'user_last_timestamp' => $dbw->timestampOrNull( $ts ) ],
2384 if ( $dbw->affectedRows() ) {
2385 wfDebug( __METHOD__ .
": set on ($field, $id)\n" );
2388 wfDebug( __METHOD__ .
" already set ($field, $id)\n" );
2401 $dbw->delete(
'user_newtalk',
2404 if ( $dbw->affectedRows() ) {
2405 wfDebug( __METHOD__ .
": killed on ($field, $id)\n" );
2408 wfDebug( __METHOD__ .
": already gone ($field, $id)\n" );
2425 $this->mNewtalk = $val;
2432 $id = $this->
getId();
2455 if ( $this->mTouched && $time <= $this->mTouched ) {
2473 if ( !$this->
getId() ) {
2479 if ( $mode ===
'refresh' ) {
2480 $cache->delete( $key, 1 );
2514 $id = $this->
getId();
2516 $key =
wfMemcKey(
'user-quicktouched',
'id', $id );
2518 $this->mQuickTouched =
null;
2528 return ( $timestamp >= $this->
getTouched() );
2543 if ( $this->mQuickTouched ===
null ) {
2544 $key =
wfMemcKey(
'user-quicktouched',
'id', $this->mId );
2550 return max( $this->mTouched, $this->mQuickTouched );
2608 $manager = AuthManager::singleton();
2611 if ( !$manager->userExists( $this->getName() ) ) {
2612 throw new LogicException(
'Cannot set a password for a user that is not in the database.' );
2616 'username' => $this->
getName(),
2622 ->info( __METHOD__ .
': Password change rejected: '
2623 .
$status->getWikiText(
null,
null,
'en' ) );
2627 $this->
setOption(
'watchlisttoken',
false );
2628 SessionManager::singleton()->invalidateSessionsForUser( $this );
2646 $manager = AuthManager::singleton();
2647 $reqs = $manager->getAuthenticationRequests( AuthManager::ACTION_CHANGE, $this );
2648 $reqs = AuthenticationRequest::loadRequestsFromSubmission( $reqs, $data );
2651 foreach ( $reqs
as $req ) {
2652 $status->merge( $manager->allowsAuthenticationDataChange(
$req ),
true );
2654 if (
$status->getValue() ===
'ignored' ) {
2655 $status->warning(
'authenticationdatachange-ignored' );
2659 foreach ( $reqs
as $req ) {
2660 $manager->changeAuthenticationData(
$req );
2673 global $wgAuthenticationTokenVersion;
2676 if ( !$this->mToken && $forceCreation ) {
2680 if ( !$this->mToken ) {
2683 } elseif ( $this->mToken === self::INVALID_TOKEN ) {
2687 } elseif ( $wgAuthenticationTokenVersion ===
null ) {
2695 $len = max( 32, self::TOKEN_LENGTH );
2696 if ( strlen(
$ret ) < $len ) {
2698 throw new \UnexpectedValueException(
'Hmac returned less than 128 bits' );
2700 return substr(
$ret, -$len );
2712 if ( $this->mToken === self::INVALID_TOKEN ) {
2714 ->debug( __METHOD__ .
": Ignoring attempt to set token for system user \"$this\"" );
2715 } elseif ( !$token ) {
2718 $this->mToken = $token;
2731 throw new BadMethodCallException( __METHOD__ .
' has been removed in 1.27' );
2740 Hooks::run(
'UserGetEmail', [ $this, &$this->mEmail ] );
2750 Hooks::run(
'UserGetEmailAuthenticationTimestamp', [ $this, &$this->mEmailAuthenticated ] );
2760 if ( $str == $this->mEmail ) {
2764 $this->mEmail = $str;
2765 Hooks::run(
'UserSetEmail', [ $this, &$this->mEmail ] );
2783 if ( $str === $oldaddr ) {
2787 $type = $oldaddr !=
'' ?
'changed' :
'set';
2788 $notificationResult =
null;
2793 if (
$type ==
'changed' ) {
2794 $change = $str !=
'' ?
'changed' :
'removed';
2795 $notificationResult = $this->
sendMail(
2796 wfMessage(
'notificationemail_subject_' . $change )->
text(),
2797 wfMessage(
'notificationemail_body_' . $change,
2811 if ( $notificationResult !==
null ) {
2812 $result->merge( $notificationResult );
2844 $this->mRealName = $str;
2857 public function getOption( $oname, $defaultOverride =
null, $ignoreHidden =
false ) {
2861 # We want 'disabled' preferences to always behave as the default value for
2862 # users, even if they have set the option explicitly in their settings (ie they
2863 # set it, and then it was disabled removing their ability to change it). But
2864 # we don't want to erase the preferences in the database in case the preference
2865 # is re-enabled again. So don't touch $mOptions, just override the returned value
2866 if ( !$ignoreHidden && in_array( $oname, $wgHiddenPrefs ) ) {
2870 if ( array_key_exists( $oname, $this->mOptions ) ) {
2871 return $this->mOptions[$oname];
2873 return $defaultOverride;
2890 # We want 'disabled' preferences to always behave as the default value for
2891 # users, even if they have set the option explicitly in their settings (ie they
2892 # set it, and then it was disabled removing their ability to change it). But
2893 # we don't want to erase the preferences in the database in case the preference
2894 # is re-enabled again. So don't touch $mOptions, just override the returned value
2895 foreach ( $wgHiddenPrefs
as $pref ) {
2897 if ( $default !==
null ) {
2902 if (
$flags & self::GETOPTIONS_EXCLUDE_DEFAULTS ) {
2917 return (
bool)$this->
getOption( $oname );
2931 $val = $defaultOverride;
2933 return intval( $val );
2948 if ( is_null( $val ) ) {
2952 $this->mOptions[$oname] = $val;
2968 $id = $this->
getId();
2969 if ( !$id || in_array( $oname, $wgHiddenPrefs ) ) {
2978 $token = hash_hmac(
'sha1',
"$oname:$id", $this->
getToken() );
2995 if ( in_array( $oname, $wgHiddenPrefs ) ) {
3030 'registered-multiselect',
3031 'registered-checkmatrix',
3063 unset( $prefs[
$name] );
3068 $multiselectOptions = [];
3069 foreach ( $prefs
as $name => $info ) {
3070 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'multiselect' ) ||
3071 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLMultiSelectField' ) ) {
3073 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
3076 $multiselectOptions[
"$prefix$value"] =
true;
3079 unset( $prefs[
$name] );
3082 $checkmatrixOptions = [];
3083 foreach ( $prefs
as $name => $info ) {
3084 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'checkmatrix' ) ||
3085 ( isset( $info[
'class'] ) && $info[
'class'] ==
'HTMLCheckMatrix' ) ) {
3088 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
3090 foreach ( $columns
as $column ) {
3091 foreach ( $rows
as $row ) {
3092 $checkmatrixOptions[
"$prefix$column-$row"] =
true;
3096 unset( $prefs[
$name] );
3102 if ( isset( $prefs[$key] ) ) {
3103 $mapping[$key] =
'registered';
3104 } elseif ( isset( $multiselectOptions[$key] ) ) {
3105 $mapping[$key] =
'registered-multiselect';
3106 } elseif ( isset( $checkmatrixOptions[$key] ) ) {
3107 $mapping[$key] =
'registered-checkmatrix';
3108 } elseif ( isset( $specialOptions[$key] ) ) {
3109 $mapping[$key] =
'special';
3110 } elseif ( substr( $key, 0, 7 ) ===
'userjs-' ) {
3111 $mapping[$key] =
'userjs';
3113 $mapping[$key] =
'unused';
3135 $resetKinds = [
'registered',
'registered-multiselect',
'registered-checkmatrix',
'unused' ],
3141 if ( !is_array( $resetKinds ) ) {
3142 $resetKinds = [ $resetKinds ];
3145 if ( in_array(
'all', $resetKinds ) ) {
3146 $newOptions = $defaultOptions;
3153 $resetKinds = array_intersect( $resetKinds, self::listOptionKinds() );
3158 foreach ( $this->mOptions
as $key =>
$value ) {
3159 if ( in_array( $optionKinds[$key], $resetKinds ) ) {
3160 if ( array_key_exists( $key, $defaultOptions ) ) {
3161 $newOptions[$key] = $defaultOptions[$key];
3164 $newOptions[$key] =
$value;
3169 Hooks::run(
'UserResetAllOptions', [ $this, &$newOptions, $this->mOptions, $resetKinds ] );
3171 $this->mOptions = $newOptions;
3172 $this->mOptionsLoaded =
true;
3181 if ( is_null( $this->mDatePreference ) ) {
3184 $map =
$wgLang->getDatePreferenceMigrationMap();
3185 if ( isset( $map[
$value] ) ) {
3188 $this->mDatePreference =
$value;
3201 if ( !$wgSecureLogin ) {
3205 Hooks::run(
'UserRequiresHTTPS', [ $this, &$https ] );
3234 if ( is_null( $this->mRights ) ) {
3236 Hooks::run(
'UserGetRights', [ $this, &$this->mRights ] );
3240 if ( !defined(
'MW_NO_SESSION' ) ) {
3241 $allowedRights = $this->
getRequest()->getSession()->getAllowedUserRights();
3242 if ( $allowedRights !==
null ) {
3243 $this->mRights = array_intersect( $this->mRights, $allowedRights );
3248 $this->mRights = array_values( array_unique( $this->mRights ) );
3259 $config->get(
'BlockDisablesLogin' ) &&
3263 $this->mRights = array_intersect( $this->mRights, $anon->getRights() );
3277 return array_keys( $this->mGroupMemberships );
3301 if ( $recache || is_null( $this->mEffectiveGroups ) ) {
3302 $this->mEffectiveGroups = array_unique( array_merge(
3309 Hooks::run(
'UserEffectiveGroups', [ &
$user, &$this->mEffectiveGroups ] );
3311 $this->mEffectiveGroups = array_values( array_unique( $this->mEffectiveGroups ) );
3324 if ( $recache || is_null( $this->mImplicitGroups ) ) {
3325 $this->mImplicitGroups = [
'*' ];
3326 if ( $this->
getId() ) {
3327 $this->mImplicitGroups[] =
'user';
3329 $this->mImplicitGroups = array_unique( array_merge(
3330 $this->mImplicitGroups,
3337 $this->mEffectiveGroups =
null;
3355 if ( is_null( $this->mFormerGroups ) ) {
3356 $db = ( $this->queryFlagsUsed & self::READ_LATEST )
3359 $res = $db->select(
'user_former_groups',
3361 [
'ufg_user' => $this->mId ],
3363 $this->mFormerGroups = [];
3364 foreach (
$res as $row ) {
3365 $this->mFormerGroups[] = $row->ufg_group;
3377 if ( !$this->
getId() ) {
3381 if ( $this->mEditCount ===
null ) {
3385 $count =
$dbr->selectField(
3386 'user',
'user_editcount',
3387 [
'user_id' => $this->mId ],
3391 if ( $count ===
null ) {
3395 $this->mEditCount = $count;
3419 if ( !
Hooks::run(
'UserAddGroup', [ $this, &$group, &$expiry ] ) ) {
3425 if ( !$ugm->insert(
true ) ) {
3429 $this->mGroupMemberships[$group] = $ugm;
3434 $this->mRights =
null;
3450 if ( !
Hooks::run(
'UserRemoveGroup', [ $this, &$group ] ) ) {
3456 if ( !$ugm || !$ugm->delete() ) {
3461 unset( $this->mGroupMemberships[$group] );
3466 $this->mRights =
null;
3478 return $this->
getId() != 0;
3499 Hooks::run(
"UserIsBot", [ $this, &$isBot ] );
3511 $permissions = func_get_args();
3512 foreach ( $permissions
as $permission ) {
3513 if ( $this->
isAllowed( $permission ) ) {
3526 $permissions = func_get_args();
3527 foreach ( $permissions
as $permission ) {
3528 if ( !$this->
isAllowed( $permission ) ) {
3541 if ( $action ===
'' ) {
3546 return in_array( $action, $this->
getRights(),
true );
3555 return $wgUseRCPatrol && $this->
isAllowedAny(
'patrol',
'patrolmarks' );
3563 global $wgUseRCPatrol, $wgUseNPPatrol;
3565 ( $wgUseRCPatrol || $wgUseNPPatrol )
3575 global $wgUseRCPatrol, $wgUseFilePatrol;
3577 ( $wgUseRCPatrol || $wgUseFilePatrol )
3588 if ( $this->mRequest ) {
3605 if (
$title->isWatchable() && ( !$checkRights || $this->
isAllowed(
'viewmywatchlist' ) ) ) {
3606 return MediaWikiServices::getInstance()->getWatchedItemStore()->isWatched( $this,
$title );
3619 if ( !$checkRights || $this->
isAllowed(
'editmywatchlist' ) ) {
3620 MediaWikiServices::getInstance()->getWatchedItemStore()->addWatchBatchForUser(
3636 if ( !$checkRights || $this->
isAllowed(
'editmywatchlist' ) ) {
3637 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
3638 $store->removeWatch( $this,
$title->getSubjectPage() );
3639 $store->removeWatch( $this,
$title->getTalkPage() );
3661 if ( !$this->
isAllowed(
'editmywatchlist' ) ) {
3669 if ( !
Hooks::run(
'UserClearNewTalkNotification', [ &
$user, $oldid ] ) ) {
3710 MediaWikiServices::getInstance()->getWatchedItemStore()
3711 ->resetNotificationTimestamp( $this,
$title, $force, $oldid );
3727 if ( !$wgUseEnotif && !$wgShowUpdatedMarker ) {
3732 $id = $this->
getId();
3738 $asOfTimes = array_unique( $dbw->selectFieldValues(
3740 'wl_notificationtimestamp',
3741 [
'wl_user' => $id,
'wl_notificationtimestamp IS NOT NULL' ],
3743 [
'ORDER BY' =>
'wl_notificationtimestamp DESC',
'LIMIT' => 500 ]
3745 if ( !$asOfTimes ) {
3752 [
'wl_notificationtimestamp' =>
null ],
3753 [
'wl_user' => $id,
'wl_notificationtimestamp' => $asOfTimes ],
3760 function ()
use ( $dbw, $id ) {
3761 global $wgUpdateRowsPerQuery;
3763 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
3764 $ticket =
$lbFactory->getEmptyTransactionTicket( __METHOD__ );
3765 $asOfTimes = array_unique( $dbw->selectFieldValues(
3767 'wl_notificationtimestamp',
3768 [
'wl_user' => $id,
'wl_notificationtimestamp IS NOT NULL' ],
3771 foreach ( array_chunk( $asOfTimes, $wgUpdateRowsPerQuery )
as $asOfTimeBatch ) {
3774 [
'wl_notificationtimestamp' =>
null ],
3775 [
'wl_user' => $id,
'wl_notificationtimestamp' => $asOfTimeBatch ],
3778 $lbFactory->commitAndWaitForReplication( __METHOD__, $ticket );
3793 $wgExperiencedUserEdits,
3794 $wgLearnerMemberSince,
3795 $wgExperiencedUserMemberSince;
3804 $learnerRegistration =
wfTimestamp( TS_MW, $now - $wgLearnerMemberSince * 86400 );
3805 $experiencedRegistration =
wfTimestamp( TS_MW, $now - $wgExperiencedUserMemberSince * 86400 );
3808 $editCount < $wgLearnerEdits ||
3809 $registration > $learnerRegistration
3813 $editCount > $wgExperiencedUserEdits &&
3814 $registration <= $experiencedRegistration
3816 return 'experienced';
3880 global $wgExtendedLoginCookieExpiration, $wgCookieExpiration;
3885 $exp += $wgExtendedLoginCookieExpiration !==
null
3886 ? $wgExtendedLoginCookieExpiration
3887 : $wgCookieExpiration;
3902 if ( 0 == $this->mId ) {
3906 $session = $this->
getRequest()->getSession();
3908 $session = $session->sessionWithRequest(
$request );
3910 $delay = $session->delaySave();
3912 if ( !$session->getUser()->equals( $this ) ) {
3913 if ( !$session->canSetUser() ) {
3915 ->warning( __METHOD__ .
3916 ": Cannot save user \"$this\" to a user \"{$session->getUser()}\"'s immutable session"
3920 $session->setUser( $this );
3923 $session->setRememberUser( $rememberMe );
3924 if ( $secure !==
null ) {
3925 $session->setForceHTTPS( $secure );
3928 $session->persist();
3930 ScopedCallback::consume( $delay );
3949 $session = $this->
getRequest()->getSession();
3950 if ( !$session->canSetUser() ) {
3952 ->warning( __METHOD__ .
": Cannot log out of an immutable session" );
3953 $error =
'immutable';
3954 } elseif ( !$session->getUser()->equals( $this ) ) {
3956 ->warning( __METHOD__ .
3957 ": Cannot log user \"$this\" out of a user \"{$session->getUser()}\"'s session"
3961 $error =
'wronguser';
3964 $delay = $session->delaySave();
3965 $session->unpersist();
3966 $session->setLoggedOutTimestamp( time() );
3967 $session->setUser(
new User );
3968 $session->set(
'wsUserID', 0 );
3969 $session->resetAllTokens();
3970 ScopedCallback::consume( $delay );
3974 'event' =>
'logout',
3975 'successful' => $error ===
false,
3976 'status' => $error ?:
'success',
3990 "Could not update user with ID '{$this->mId}'; DB is read-only."
3996 if ( 0 == $this->mId ) {
4006 $dbw->update(
'user',
4008 'user_name' => $this->mName,
4009 'user_real_name' => $this->mRealName,
4010 'user_email' => $this->mEmail,
4011 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
4012 'user_touched' => $dbw->timestamp( $newTouched ),
4013 'user_token' => strval( $this->mToken ),
4015 'user_email_token_expires' => $dbw->timestampOrNull( $this->mEmailTokenExpires ),
4017 'user_id' => $this->mId,
4021 if ( !$dbw->affectedRows() ) {
4025 $from = ( $this->queryFlagsUsed & self::READ_LATEST ) ?
'master' :
'replica';
4027 "CAS update failed on user_touched for user ID '{$this->mId}' (read from $from);" .
4028 " the version of the user to be saved is older than the current version."
4032 $this->mTouched = $newTouched;
4052 $db = ( (
$flags & self::READ_LATEST ) == self::READ_LATEST )
4057 ? [
'LOCK IN SHARE MODE' ]
4060 $id = $db->selectField(
'user',
4061 'user_id', [
'user_name' =>
$s ], __METHOD__,
$options );
4082 foreach ( [
'password',
'newpassword',
'newpass_time',
'password_expires' ]
as $field ) {
4083 if ( isset(
$params[$field] ) ) {
4084 wfDeprecated( __METHOD__ .
" with param '$field'",
'1.27' );
4092 if ( isset(
$params[
'options'] ) ) {
4097 $seqVal = $dbw->nextSequenceValue(
'user_user_id_seq' );
4102 'user_id' => $seqVal,
4103 'user_name' =>
$name,
4104 'user_password' => $noPass,
4105 'user_newpassword' => $noPass,
4106 'user_email' =>
$user->mEmail,
4107 'user_email_authenticated' => $dbw->timestampOrNull(
$user->mEmailAuthenticated ),
4108 'user_real_name' =>
$user->mRealName,
4109 'user_token' => strval(
$user->mToken ),
4110 'user_registration' => $dbw->timestamp(
$user->mRegistration ),
4111 'user_editcount' => 0,
4112 'user_touched' => $dbw->timestamp(
$user->newTouchedTimestamp() ),
4115 $fields[
"user_$name"] =
$value;
4117 $dbw->insert(
'user', $fields, __METHOD__, [
'IGNORE' ] );
4118 if ( $dbw->affectedRows() ) {
4154 if ( !$this->mToken ) {
4163 $seqVal = $dbw->nextSequenceValue(
'user_user_id_seq' );
4164 $dbw->insert(
'user',
4166 'user_id' => $seqVal,
4167 'user_name' => $this->mName,
4168 'user_password' => $noPass,
4169 'user_newpassword' => $noPass,
4170 'user_email' => $this->mEmail,
4171 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
4173 'user_token' => strval( $this->mToken ),
4174 'user_registration' => $dbw->timestamp( $this->mRegistration ),
4175 'user_editcount' => 0,
4176 'user_touched' => $dbw->timestamp( $this->mTouched ),
4180 if ( !$dbw->affectedRows() ) {
4182 $this->mId = $dbw->selectField(
4185 [
'user_name' => $this->mName ],
4187 [
'LOCK IN SHARE MODE' ]
4196 throw new MWException( __METHOD__ .
": hit a key conflict attempting " .
4197 "to insert user '{$this->mName}' row, but it was not present in select!" );
4201 $this->mId = $dbw->insertId();
4230 wfDebug( __METHOD__ .
"()\n" );
4232 if ( $this->mId == 0 ) {
4237 if ( !$userblock ) {
4241 return (
bool)$userblock->doAutoblock( $this->
getRequest()->getIP() );
4250 if ( $this->mBlock && $this->mBlock->prevents(
'createaccount' ) ) {
4254 # T15611: if the IP address the user is trying to create an account from is
4255 # blocked with createaccount disabled, prevent new account creation there even
4256 # when the user is logged in
4257 if ( $this->mBlockedFromCreateAccount ===
false && !$this->
isAllowed(
'ipblock-exempt' ) ) {
4260 return $this->mBlockedFromCreateAccount instanceof
Block
4261 && $this->mBlockedFromCreateAccount->
prevents(
'createaccount' )
4262 ? $this->mBlockedFromCreateAccount
4272 return $this->mBlock && $this->mBlock->prevents(
'sendemail' );
4299 return $title->getTalkPage();
4308 return !$this->
isAllowed(
'autoconfirmed' );
4318 $manager = AuthManager::singleton();
4319 $reqs = AuthenticationRequest::loadRequestsFromSubmission(
4320 $manager->getAuthenticationRequests( AuthManager::ACTION_LOGIN ),
4322 'username' => $this->
getName(),
4323 'password' => $password,
4326 $res = AuthManager::singleton()->beginAuthentication( $reqs,
'null:' );
4327 switch (
$res->status ) {
4328 case AuthenticationResponse::PASS:
4330 case AuthenticationResponse::FAIL:
4333 ->info( __METHOD__ .
': Authentication failed: ' .
$res->message->plain() );
4336 throw new BadMethodCallException(
4337 'AuthManager returned a response unsupported by ' . __METHOD__
4374 return $request->getSession()->getToken( $salt );
4432 $val = substr( $val, 0, strspn( $val,
'0123456789abcdef' ) ) . Token::SUFFIX;
4451 if (
$type ==
'created' ||
$type ===
false ) {
4452 $message =
'confirmemail_body';
4453 } elseif (
$type ===
true ) {
4454 $message =
'confirmemail_body_changed';
4457 $message =
'confirmemail_body_' .
$type;
4465 $wgLang->userTimeAndDate( $expiration, $this ),
4467 $wgLang->userDate( $expiration, $this ),
4468 $wgLang->userTime( $expiration, $this ) )->
text() );
4482 public function sendMail( $subject, $body, $from =
null, $replyto =
null ) {
4485 if ( $from instanceof
User ) {
4494 'replyTo' => $replyto,
4515 $hash = md5( $token );
4516 $this->mEmailToken = $hash;
4517 $this->mEmailTokenExpires = $expiration;
4527 return $this->
getTokenUrl(
'ConfirmEmail', $token );
4536 return $this->
getTokenUrl(
'InvalidateEmail', $token );
4556 return $title->getCanonicalURL();
4571 Hooks::run(
'ConfirmEmailComplete', [ $this ] );
4585 $this->mEmailToken =
null;
4586 $this->mEmailTokenExpires =
null;
4589 Hooks::run(
'InvalidateEmailComplete', [ $this ] );
4599 $this->mEmailAuthenticated = $timestamp;
4600 Hooks::run(
'UserSetEmailAuthenticationTimestamp', [ $this, &$this->mEmailAuthenticated ] );
4649 if ( !Sanitizer::validateEmail( $this->mEmail ) ) {
4669 $this->mEmailToken &&
4695 if ( $this->
getId() == 0 ) {
4699 $time =
$dbr->selectField(
'revision',
'rev_timestamp',
4700 [
'rev_user' => $this->
getId() ],
4702 [
'ORDER BY' =>
'rev_timestamp ASC' ]
4717 global $wgGroupPermissions, $wgRevokePermissions;
4720 foreach ( $groups
as $group ) {
4721 if ( isset( $wgGroupPermissions[$group] ) ) {
4722 $rights = array_merge( $rights,
4724 array_keys( array_filter( $wgGroupPermissions[$group] ) ) );
4728 foreach ( $groups
as $group ) {
4729 if ( isset( $wgRevokePermissions[$group] ) ) {
4730 $rights = array_diff( $rights,
4731 array_keys( array_filter( $wgRevokePermissions[$group] ) ) );
4734 return array_unique( $rights );
4744 global $wgGroupPermissions;
4745 $allowedGroups = [];
4746 foreach ( array_keys( $wgGroupPermissions )
as $group ) {
4747 if ( self::groupHasPermission( $group, $role ) ) {
4748 $allowedGroups[] = $group;
4751 return $allowedGroups;
4767 global $wgGroupPermissions, $wgRevokePermissions;
4768 return isset( $wgGroupPermissions[$group][$role] ) && $wgGroupPermissions[$group][$role]
4769 && !( isset( $wgRevokePermissions[$group][$role] ) && $wgRevokePermissions[$group][$role] );
4787 global $wgGroupPermissions, $wgRevokePermissions;
4792 if ( isset(
$cache[$right] ) && !defined(
'MW_PHPUNIT_TEST' ) ) {
4796 if ( !isset( $wgGroupPermissions[
'*'][$right] ) || !$wgGroupPermissions[
'*'][$right] ) {
4802 foreach ( $wgRevokePermissions
as $rights ) {
4803 if ( isset( $rights[$right] ) && $rights[$right] ) {
4811 if ( !defined(
'MW_NO_SESSION' ) ) {
4812 $allowedRights = SessionManager::getGlobalSession()->getAllowedUserRights();
4813 if ( $allowedRights !==
null && !in_array( $right, $allowedRights,
true ) ) {
4820 if ( !
Hooks::run(
'UserIsEveryoneAllowed', [ $right ] ) ) {
4861 global $wgGroupPermissions, $wgRevokePermissions;
4863 array_merge( array_keys( $wgGroupPermissions ), array_keys( $wgRevokePermissions ) ),
4864 self::getImplicitGroups()
4873 if ( self::$mAllRights ===
false ) {
4874 global $wgAvailableRights;
4875 if (
count( $wgAvailableRights ) ) {
4876 self::$mAllRights = array_unique( array_merge( self::$mCoreRights, $wgAvailableRights ) );
4880 Hooks::run(
'UserGetAllRights', [ &self::$mAllRights ] );
4890 global $wgImplicitGroups;
4892 $groups = $wgImplicitGroups;
4893 # Deprecated, use $wgImplicitGroups instead
4894 Hooks::run(
'UserGetImplicitGroups', [ &$groups ],
'1.25' );
4924 if ( $text ==
'' ) {
4931 return htmlspecialchars( $text );
4948 if ( $text ==
'' ) {
4954 return "[[$page|$text]]";
4970 global $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
4979 if ( empty( $wgAddGroups[$group] ) ) {
4981 } elseif ( $wgAddGroups[$group] ===
true ) {
4984 } elseif ( is_array( $wgAddGroups[$group] ) ) {
4985 $groups[
'add'] = $wgAddGroups[$group];
4989 if ( empty( $wgRemoveGroups[$group] ) ) {
4991 } elseif ( $wgRemoveGroups[$group] ===
true ) {
4993 } elseif ( is_array( $wgRemoveGroups[$group] ) ) {
4994 $groups[
'remove'] = $wgRemoveGroups[$group];
4998 if ( empty( $wgGroupsAddToSelf[
'user'] ) || $wgGroupsAddToSelf[
'user'] !==
true ) {
4999 foreach ( $wgGroupsAddToSelf
as $key =>
$value ) {
5000 if ( is_int( $key ) ) {
5001 $wgGroupsAddToSelf[
'user'][] =
$value;
5006 if ( empty( $wgGroupsRemoveFromSelf[
'user'] ) || $wgGroupsRemoveFromSelf[
'user'] !==
true ) {
5007 foreach ( $wgGroupsRemoveFromSelf
as $key =>
$value ) {
5008 if ( is_int( $key ) ) {
5009 $wgGroupsRemoveFromSelf[
'user'][] =
$value;
5015 if ( empty( $wgGroupsAddToSelf[$group] ) ) {
5017 } elseif ( $wgGroupsAddToSelf[$group] ===
true ) {
5020 } elseif ( is_array( $wgGroupsAddToSelf[$group] ) ) {
5021 $groups[
'add-self'] = $wgGroupsAddToSelf[$group];
5024 if ( empty( $wgGroupsRemoveFromSelf[$group] ) ) {
5026 } elseif ( $wgGroupsRemoveFromSelf[$group] ===
true ) {
5028 } elseif ( is_array( $wgGroupsRemoveFromSelf[$group] ) ) {
5029 $groups[
'remove-self'] = $wgGroupsRemoveFromSelf[$group];
5043 if ( $this->
isAllowed(
'userrights' ) ) {
5066 foreach ( $addergroups
as $addergroup ) {
5067 $groups = array_merge_recursive(
5070 $groups[
'add'] = array_unique( $groups[
'add'] );
5071 $groups[
'remove'] = array_unique( $groups[
'remove'] );
5072 $groups[
'add-self'] = array_unique( $groups[
'add-self'] );
5073 $groups[
'remove-self'] = array_unique( $groups[
'remove-self'] );
5104 [
'user_editcount=user_editcount+1' ],
5105 [
'user_id' => $this->
getId(),
'user_editcount IS NOT NULL' ],
5109 if ( $dbw->affectedRows() == 0 ) {
5112 if (
$dbr !== $dbw ) {
5124 if ( $this->mEditCount ===
null ) {
5127 $this->mEditCount += (
$dbr !== $dbw ) ? 1 : 0;
5129 $this->mEditCount++;
5146 $count = (int)
$dbr->selectField(
5149 [
'rev_user' => $this->getId() ],
5152 $count = $count + $add;
5157 [
'user_editcount' => $count ],
5158 [
'user_id' => $this->
getId() ],
5173 $key =
"right-$right";
5175 return $msg->isDisabled() ? $right : $msg->text();
5186 $key =
"grant-$grant";
5188 return $msg->isDisabled() ? $grant : $msg->text();
5239 if ( $this->mOptionsLoaded ) {
5245 if ( !$this->
getId() ) {
5251 $this->mOptions[
'variant'] = $variant;
5252 $this->mOptions[
'language'] = $variant;
5253 $this->mOptionsLoaded =
true;
5258 if ( !is_null( $this->mOptionOverrides ) ) {
5259 wfDebug(
"User: loading options for user " . $this->
getId() .
" from override cache.\n" );
5260 foreach ( $this->mOptionOverrides
as $key =>
$value ) {
5261 $this->mOptions[$key] =
$value;
5264 if ( !is_array( $data ) ) {
5265 wfDebug(
"User: loading options for user " . $this->
getId() .
" from database.\n" );
5267 $dbr = ( $this->queryFlagsUsed & self::READ_LATEST )
5273 [
'up_property',
'up_value' ],
5274 [
'up_user' => $this->
getId() ],
5278 $this->mOptionOverrides = [];
5280 foreach (
$res as $row ) {
5285 if ( $row->up_value ===
'0' ) {
5288 $data[$row->up_property] = $row->up_value;
5297 $this->mOptionsLoaded =
true;
5299 Hooks::run(
'UserLoadOptions', [ $this, &$this->mOptions ] );
5315 if ( !
Hooks::run(
'UserSaveOptions', [ $this, &$saveOptions ] ) ) {
5319 $userId = $this->
getId();
5322 foreach ( $saveOptions
as $key =>
$value ) {
5325 if ( ( $defaultOption ===
null &&
$value !==
false &&
$value !==
null )
5326 ||
$value != $defaultOption
5329 'up_user' => $userId,
5330 'up_property' => $key,
5338 $res = $dbw->select(
'user_properties',
5339 [
'up_property',
'up_value' ], [
'up_user' => $userId ], __METHOD__ );
5344 foreach (
$res as $row ) {
5345 if ( !isset( $saveOptions[$row->up_property] )
5346 || strcmp( $saveOptions[$row->up_property], $row->up_value ) != 0
5348 $keysDelete[] = $row->up_property;
5352 if (
count( $keysDelete ) ) {
5360 $dbw->delete(
'user_properties',
5361 [
'up_user' => $userId,
'up_property' => $keysDelete ], __METHOD__ );
5364 $dbw->insert(
'user_properties', $insert_rows, __METHOD__, [
'IGNORE' ] );
5405 global $wgMinimalPasswordLength;
5407 if ( $wgMinimalPasswordLength == 0 ) {
5411 # Note that the pattern requirement will always be satisfied if the
5412 # input is empty, so we need required in all cases.
5414 # @todo FIXME: T25769: This needs to not claim the password is required
5415 # if e-mail confirmation is being used. Since HTML5 input validation
5416 # is b0rked anyway in some browsers, just return nothing. When it's
5417 # re-enabled, fix this code to not output required for e-mail
5419 # $ret = array( 'required' );
5422 # We can't actually do this right now, because Opera 9.6 will print out
5423 # the entered password visibly in its error message! When other
5424 # browsers add support for this attribute, or Opera fixes its support,
5425 # we can add support with a version check to avoid doing this on Opera
5426 # versions where it will be a problem. Reported to Opera as
5427 # DSK-262266, but they don't have a public bug tracker for us to follow.
5452 'user_email_authenticated',
5454 'user_email_token_expires',
5455 'user_registration',
5492 if ( !$this->
getId() ) {
5497 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.
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.
inDnsBlacklist( $ip, $bases)
Whether the given IP is in a given DNS blacklist.
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
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
error also a ContextSource you ll probably need to make sure the header is varied on $request
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.
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.
resetTokenFromOption( $oname)
Reset a token stored in the preferences (like the watchlist one).
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...
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...
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...
if( $wgRCFilterByAge) $wgDefaultUserOptions['rcdays']
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.
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.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $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
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
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.
getRequest()
Get the WebRequest 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.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
$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.
loadGroups()
Load the groups from the database if they aren't already loaded.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
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.
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.
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.
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.
wfMemcKey()
Make a cache key for the local wiki.
namespace and then decline to actually register it file or subcat img or subcat $title
isLocked()
Check if user account is locked.
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.
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN boolean columns are always mapped to as the code does not always treat the column as a boolean(which is limited to accepting true, false, 0, 1, t, or f) *The default data type for all VARCHAR
setNewtalk( $val, $curRev=null)
Update the 'You have new messages!' status.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
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.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers please use GetContentModels hook to make them known to core if desired 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 inclusive $limit
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?
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.
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.
const TOKEN_LENGTH
@const int Number of characters in user_token field.
see documentation in includes Linker php for Linker::makeImageLink & $time
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,...
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.
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.
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.
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.
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
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.
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.
static getMain()
Static methods.
blockedBy()
If user is blocked, return the name of the user who placed the block.
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.
string $blockTrigger
Indicates type of block (used for eventlogging) Permitted values: 'cookie-block', 'proxy-block',...
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.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk page
$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.
static getMainWANInstance()
Get the main WAN cache object.
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.
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.
loadFromCache()
Load user data from shared cache, given mId has already been set.
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.
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.
static isUsableName( $name)
Usernames which fail to pass this function will be blocked from user login and new account registrati...
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled $incrBy
isBlocked( $bFromSlave=true)
Check if user is blocked.
$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.
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.
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.
integer $queryFlagsUsed
User::READ_* constant bitfield used to load data.
getGroupMemberships()
Get the list of explicit group memberships this user has, stored as UserGroupMembership objects.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
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,...
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.
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