31use Wikimedia\ScopedCallback;
41define(
'EDIT_TOKEN_SUFFIX', Token::SUFFIX );
106 'mEmailAuthenticated',
108 'mEmailTokenExpires',
170 'move-categorypages',
171 'move-rootuserpages',
175 'override-export-depth',
197 'userrights-interwiki',
333 return (
string)$this->
getName();
359 $this->mLoadedItems ===
true || $this->mFrom !==
'session';
367 public function load( $flags = self::READ_NORMAL ) {
370 if ( $this->mLoadedItems ===
true ) {
376 $this->mLoadedItems =
true;
377 $this->queryFlagsUsed = $flags;
381 \MediaWiki\Logger\LoggerFactory::getInstance(
'session' )
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 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
397 if ( $lb->hasOrMadeRecentMasterChanges() ) {
398 $flags |= self::READ_LATEST;
399 $this->queryFlagsUsed = $flags;
412 if ( $this->mId != 0 ) {
413 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
414 if ( $lb->hasOrMadeRecentMasterChanges() ) {
415 $flags |= self::READ_LATEST;
416 $this->queryFlagsUsed = $flags;
424 if (
wfGetLB()->hasOrMadeRecentMasterChanges() ) {
425 $flags |= self::READ_LATEST;
426 $this->queryFlagsUsed = $flags;
429 list( $index,
$options ) = DBAccessObjectUtils::getDBOptions( $flags );
430 $row =
wfGetDB( $index )->selectRow(
432 [
'actor_user',
'actor_name' ],
433 [
'actor_id' => $this->mActorId ],
441 } elseif ( $row->actor_user ) {
442 $this->mId = $row->actor_user;
453 Hooks::run(
'UserLoadAfterLoadFromSession', [ $this ] );
456 throw new UnexpectedValueException(
457 "Unrecognised value for User->mFrom: \"{$this->mFrom}\"" );
467 if ( $this->mId == 0 ) {
475 $latest = DBAccessObjectUtils::hasFlags( $flags, self::READ_LATEST );
485 $this->mLoadedItems =
true;
486 $this->queryFlagsUsed = $flags;
496 public static function purge( $wikiId, $userId ) {
497 $cache = ObjectCache::getMainWANInstance();
498 $key =
$cache->makeGlobalKey(
'user',
'id', $wikiId, $userId );
508 return $cache->makeGlobalKey(
'user',
'id',
wfWikiID(), $this->mId );
517 $id = $this->
getId();
519 return $id ? [ $this->
getCacheKey( $cache ) ] : [];
529 $cache = ObjectCache::getMainWANInstance();
530 $data =
$cache->getWithSetCallback(
533 function ( $oldValue, &$ttl, array &$setOpts ) use (
$cache ) {
535 wfDebug(
"User: cache miss for user {$this->mId}\n" );
542 foreach ( self::$mCacheVars as $name ) {
543 $data[
$name] = $this->$name;
550 foreach ( $this->mGroupMemberships as $ugm ) {
551 if ( $ugm->getExpiry() ) {
552 $secondsUntilExpiry =
wfTimestamp( TS_UNIX, $ugm->getExpiry() ) - time();
553 if ( $secondsUntilExpiry > 0 && $secondsUntilExpiry < $ttl ) {
554 $ttl = $secondsUntilExpiry;
561 [
'pcTTL' => $cache::TTL_PROC_LONG,
'version' =>
self::VERSION ]
565 foreach ( self::$mCacheVars as $name ) {
566 $this->$name = $data[
$name];
591 public static function newFromName( $name, $validate =
'valid' ) {
592 if ( $validate ===
true ) {
596 if ( $name ===
false ) {
603 $u->setItemLoaded(
'name' );
633 throw new BadMethodCallException(
634 'Cannot use ' . __METHOD__ .
' when $wgActorTableSchemaMigrationStage is MIGRATION_OLD'
661 $user->mFrom =
'defaults';
664 $user->mActorId = (int)$actorId;
665 if ( $user->mActorId !== 0 ) {
666 $user->mFrom =
'actor';
671 if ( $userName !==
null && $userName !==
'' ) {
672 $user->mName = $userName;
673 $user->mFrom =
'name';
674 $user->setItemLoaded(
'name' );
677 if ( $userId !==
null ) {
678 $user->mId = (int)$userId;
679 if ( $user->mId !== 0 ) {
682 $user->setItemLoaded(
'id' );
685 if ( $user->mFrom ===
'defaults' ) {
686 throw new InvalidArgumentException(
687 'Cannot create a user with no name, no ID, and no actor ID'
706 $db = ( $flags & self::READ_LATEST ) == self::READ_LATEST
710 $id = $db->selectField(
714 'user_email_token' => md5(
$code ),
715 'user_email_token_expires > ' . $db->addQuotes( $db->timestamp() ),
731 $user->mFrom =
'session';
793 'validate' =>
'valid',
799 if ( $name ===
false ) {
805 $row =
$dbr->selectRow(
806 $userQuery[
'tables'],
807 $userQuery[
'fields'],
808 [
'user_name' => $name ],
816 $row = $dbw->selectRow(
817 $userQuery[
'tables'],
818 $userQuery[
'fields'],
819 [
'user_name' => $name ],
837 if ( $user->mEmail || $user->mToken !== self::INVALID_TOKEN ||
838 AuthManager::singleton()->userCanAuthenticate( $name )
845 AuthManager::singleton()->revokeAccessForUser( $name );
847 $user->invalidateEmail();
849 $user->saveSettings();
850 SessionManager::singleton()->preventSessionsForUser( $user->getName() );
863 public static function whoIs( $id ) {
883 public static function idFromName( $name, $flags = self::READ_NORMAL ) {
884 $nt = Title::makeTitleSafe( NS_USER, $name );
885 if ( is_null( $nt ) ) {
890 if ( !( $flags & self::READ_LATEST ) && array_key_exists( $name, self::$idCacheByName ) ) {
891 return self::$idCacheByName[
$name];
894 list( $index,
$options ) = DBAccessObjectUtils::getDBOptions( $flags );
900 [
'user_name' => $nt->getText() ],
905 if (
$s ===
false ) {
908 $result =
$s->user_id;
913 if ( count( self::$idCacheByName ) > 1000 ) {
914 self::$idCacheByName = [];
924 self::$idCacheByName = [];
943 public static function isIP( $name ) {
944 return preg_match(
'/^\d{1,3}\.\d{1,3}\.\d{1,3}\.(?:xxx|\d{1,3})$/', $name )
945 || IP::isIPv6( $name );
955 return IP::isValidRange( $this->mName );
973 || self::isIP( $name )
974 || strpos( $name,
'/' ) !==
false
983 $parsed = Title::newFromText( $name );
984 if ( is_null( $parsed )
985 || $parsed->getNamespace()
986 || strcmp( $name, $parsed->getPrefixedText() ) ) {
992 $unicodeBlacklist =
'/[' .
993 '\x{0080}-\x{009f}' . # iso-8859-1 control chars
994 '\x{00a0}' . # non-breaking space
995 '\x{2000}-\x{200f}' . # various whitespace
996 '\x{2028}-\x{202f}' . # breaks and control chars
997 '\x{3000}' . # ideographic space
998 '\x{e000}-\x{f8ff}' . #
private use
1000 if ( preg_match( $unicodeBlacklist, $name ) ) {
1021 if ( !self::isValidUserName( $name ) ) {
1025 static $reservedUsernames =
false;
1026 if ( !$reservedUsernames ) {
1028 Hooks::run(
'UserGetReservedNames', [ &$reservedUsernames ] );
1032 foreach ( $reservedUsernames as $reserved ) {
1033 if ( substr( $reserved, 0, 4 ) ==
'msg:' ) {
1034 $reserved =
wfMessage( substr( $reserved, 4 ) )->inContentLanguage()->text();
1036 if ( $reserved == $name ) {
1054 if ( $groups === [] ) {
1058 $groups = array_unique( (array)$groups );
1059 $limit = min( 5000, $limit );
1061 $conds = [
'ug_group' => $groups ];
1062 if ( $after !==
null ) {
1063 $conds[] =
'ug_user > ' . (int)$after;
1067 $ids =
$dbr->selectFieldValues(
1074 'ORDER BY' =>
'ug_user',
1099 if ( strlen( $name ) > 235 ) {
1101 ": '$name' invalid due to length" );
1109 ": '$name' invalid due to wgInvalidUsernameCharacters" );
1136 if ( $result->isGood() ) {
1140 foreach ( $result->getErrorsByType(
'error' ) as $error ) {
1143 foreach ( $result->getErrorsByType(
'warning' ) as $warning ) {
1181 if ( !Hooks::run(
'isValidPassword', [ $password, &$result, $this ] ) ) {
1186 if ( $result ===
false ) {
1187 $status->merge( $upp->checkUserPassword( $this, $password ) );
1189 } elseif ( $result ===
true ) {
1215 # Reject names containing '#'; these will be cleaned up
1216 # with title normalisation, but then it's too late to
1218 if ( strpos( $name,
'#' ) !==
false ) {
1224 $t = ( $validate !==
false ) ?
1225 Title::newFromText( $name, NS_USER ) : Title::makeTitle( NS_USER, $name );
1227 if ( is_null(
$t ) ||
$t->getNamespace() !== NS_USER ||
$t->isExternal() ) {
1232 $name = AuthManager::callLegacyAuthPlugin(
1233 'getCanonicalName', [
$t->getText() ],
$t->getText()
1236 switch ( $validate ) {
1240 if ( !self::isValidUserName( $name ) ) {
1245 if ( !self::isUsableName( $name ) ) {
1250 if ( !self::isCreatableName( $name ) ) {
1255 throw new InvalidArgumentException(
1256 'Invalid parameter value for $validate in ' . __METHOD__ );
1282 $this->mName =
$name;
1283 $this->mActorId =
null;
1284 $this->mRealName =
'';
1286 $this->mOptionOverrides =
null;
1287 $this->mOptionsLoaded =
false;
1289 $loggedOut = $this->mRequest && !defined(
'MW_NO_SESSION' )
1290 ? $this->mRequest->getSession()->getLoggedOutTimestamp() : 0;
1291 if ( $loggedOut !== 0 ) {
1292 $this->mTouched =
wfTimestamp( TS_MW, $loggedOut );
1294 $this->mTouched =
'1'; # Allow any
pages to be cached
1297 $this->mToken =
null;
1298 $this->mEmailAuthenticated =
null;
1299 $this->mEmailToken =
'';
1300 $this->mEmailTokenExpires =
null;
1302 $this->mGroupMemberships = [];
1304 Hooks::run(
'UserLoadDefaults', [ $this, $name ] );
1320 return ( $this->mLoadedItems ===
true && $all ===
'all' ) ||
1321 ( isset( $this->mLoadedItems[$item] ) && $this->mLoadedItems[$item] ===
true );
1330 if ( is_array( $this->mLoadedItems ) ) {
1331 $this->mLoadedItems[$item] =
true;
1343 Hooks::run(
'UserLoadFromSession', [ $this, &$result ],
'1.27' );
1344 if ( $result !==
null ) {
1350 $session = $this->
getRequest()->getSession();
1351 $user = $session->getUser();
1352 if ( $user->isLoggedIn() ) {
1359 if ( $config->get(
'CookieSetOnAutoblock' ) ===
true ) {
1361 $shouldSetCookie = $this->
getRequest()->getCookie(
'BlockID' ) ===
null
1364 && $block->isAutoblocking();
1365 if ( $shouldSetCookie ) {
1366 wfDebug( __METHOD__ .
': User is autoblocked, setting cookie to track' );
1367 $block->setCookie( $this->
getRequest()->response() );
1372 $session->set(
'wsUserID', $this->
getId() );
1373 $session->set(
'wsUserName', $this->
getName() );
1374 $session->set(
'wsToken', $this->
getToken() );
1389 $this->mId = intval( $this->mId );
1391 if ( !$this->mId ) {
1397 list( $index,
$options ) = DBAccessObjectUtils::getDBOptions( $flags );
1401 $s = $db->selectRow(
1402 $userQuery[
'tables'],
1403 $userQuery[
'fields'],
1404 [
'user_id' => $this->mId ],
1410 $this->queryFlagsUsed = $flags;
1411 Hooks::run(
'UserLoadFromDatabase', [ $this, &
$s ] );
1413 if (
$s !==
false ) {
1416 $this->mGroupMemberships =
null;
1442 if ( !is_object( $row ) ) {
1443 throw new InvalidArgumentException(
'$row must be an object' );
1448 $this->mGroupMemberships =
null;
1451 if ( isset( $row->actor_id ) ) {
1452 $this->mActorId = (int)$row->actor_id;
1453 if ( $this->mActorId !== 0 ) {
1454 $this->mFrom =
'actor';
1462 if ( isset( $row->user_name ) && $row->user_name !==
'' ) {
1463 $this->mName = $row->user_name;
1464 $this->mFrom =
'name';
1470 if ( isset( $row->user_real_name ) ) {
1471 $this->mRealName = $row->user_real_name;
1477 if ( isset( $row->user_id ) ) {
1478 $this->mId = intval( $row->user_id );
1479 if ( $this->mId !== 0 ) {
1480 $this->mFrom =
'id';
1487 if ( isset( $row->user_id ) && isset( $row->user_name ) && $row->user_name !==
'' ) {
1488 self::$idCacheByName[$row->user_name] = $row->user_id;
1491 if ( isset( $row->user_editcount ) ) {
1492 $this->mEditCount = $row->user_editcount;
1497 if ( isset( $row->user_touched ) ) {
1498 $this->mTouched =
wfTimestamp( TS_MW, $row->user_touched );
1503 if ( isset( $row->user_token ) ) {
1507 $this->mToken = rtrim( $row->user_token,
" \0" );
1508 if ( $this->mToken ===
'' ) {
1509 $this->mToken =
null;
1515 if ( isset( $row->user_email ) ) {
1516 $this->mEmail = $row->user_email;
1517 $this->mEmailAuthenticated =
wfTimestampOrNull( TS_MW, $row->user_email_authenticated );
1518 $this->mEmailToken = $row->user_email_token;
1519 $this->mEmailTokenExpires =
wfTimestampOrNull( TS_MW, $row->user_email_token_expires );
1526 $this->mLoadedItems =
true;
1529 if ( is_array( $data ) ) {
1530 if ( isset( $data[
'user_groups'] ) && is_array( $data[
'user_groups'] ) ) {
1531 if ( !count( $data[
'user_groups'] ) ) {
1532 $this->mGroupMemberships = [];
1534 $firstGroup = reset( $data[
'user_groups'] );
1535 if ( is_array( $firstGroup ) || is_object( $firstGroup ) ) {
1536 $this->mGroupMemberships = [];
1537 foreach ( $data[
'user_groups'] as $row ) {
1538 $ugm = UserGroupMembership::newFromRow( (
object)$row );
1539 $this->mGroupMemberships[$ugm->getGroup()] = $ugm;
1544 if ( isset( $data[
'user_properties'] ) && is_array( $data[
'user_properties'] ) ) {
1557 foreach ( self::$mCacheVars as $var ) {
1558 $this->$var = $user->$var;
1566 if ( is_null( $this->mGroupMemberships ) ) {
1567 $db = ( $this->queryFlagsUsed & self::READ_LATEST )
1570 $this->mGroupMemberships = UserGroupMembership::getMembershipsForUser(
1597 if ( !count( $toPromote ) ) {
1607 foreach ( $toPromote as $group ) {
1610 $newGroups = array_merge( $oldGroups, $toPromote );
1614 Hooks::run(
'UserGroupsChanged', [ $this, $toPromote, [],
false,
false, $oldUGMs, $newUGMs ] );
1615 AuthManager::callLegacyAuthPlugin(
'updateExternalDBGroups', [ $this, $toPromote ] );
1618 $logEntry->setPerformer( $this );
1620 $logEntry->setParameters( [
1621 '4::oldgroups' => $oldGroups,
1622 '5::newgroups' => $newGroups,
1624 $logid = $logEntry->insert();
1626 $logEntry->publish( $logid );
1642 if ( $this->mTouched ) {
1644 $conditions[
'user_touched'] = $db->
timestamp( $this->mTouched );
1662 if ( !$this->mId ) {
1670 $dbw->update(
'user',
1671 [
'user_touched' => $dbw->timestamp( $newTouched ) ],
1672 $this->makeUpdateConditions( $dbw, [
1673 'user_id' => $this->mId,
1677 $success = ( $dbw->affectedRows() > 0 );
1680 $this->mTouched = $newTouched;
1698 $this->mNewtalk = -1;
1699 $this->mDatePreference =
null;
1700 $this->mBlockedby = -1; # Unset
1701 $this->mHash =
false;
1702 $this->mRights =
null;
1703 $this->mEffectiveGroups =
null;
1704 $this->mImplicitGroups =
null;
1705 $this->mGroupMemberships =
null;
1706 $this->mOptions =
null;
1707 $this->mOptionsLoaded =
false;
1708 $this->mEditCount =
null;
1710 if ( $reloadFrom ) {
1711 $this->mLoadedItems = [];
1712 $this->mFrom = $reloadFrom;
1725 static $defOpt =
null;
1726 static $defOptLang =
null;
1728 if ( $defOpt !==
null && $defOptLang ===
$wgContLang->getCode() ) {
1738 $defOpt[
'language'] = $defOptLang;
1739 foreach ( LanguageConverter::$languagesWithVariants as $langCode ) {
1740 $defOpt[$langCode ==
$wgContLang->getCode() ?
'variant' :
"variant-$langCode"] = $langCode;
1747 $defOpt[
'searchNs' . $nsnum] = (bool)$val;
1751 Hooks::run(
'UserGetDefaultOptions', [ &$defOpt ] );
1764 if ( isset( $defOpts[
$opt] ) ) {
1765 return $defOpts[
$opt];
1780 if ( -1 != $this->mBlockedby ) {
1784 wfDebug( __METHOD__ .
": checking...\n" );
1793 # We only need to worry about passing the IP address to the Block generator if the
1794 # user is not immune to autoblocks/hardblocks, and they are the current user so we
1795 # know which IP address they're actually coming from
1800 $globalUserName = $sessionUser->isSafeToLoad()
1801 ? $sessionUser->getName()
1802 : IP::sanitizeIP( $sessionUser->getRequest()->getIP() );
1803 if ( $this->
getName() === $globalUserName && !$this->
isAllowed(
'ipblock-exempt' ) ) {
1811 if ( !$block instanceof
Block ) {
1818 if ( self::isLocallyBlockedProxy( $ip ) ) {
1819 $block =
new Block( [
1823 'systemBlock' =>
'proxy',
1826 $block =
new Block( [
1830 'systemBlock' =>
'dnsbl',
1836 if ( !$block instanceof
Block
1841 $xff = $this->
getRequest()->getHeader(
'X-Forwarded-For' );
1842 $xff = array_map(
'trim', explode(
',', $xff ) );
1843 $xff = array_diff( $xff, [ $ip ] );
1846 if ( $block instanceof
Block ) {
1847 # Mangle the reason to alert the user that the block
1848 # originated from matching the X-Forwarded-For header.
1849 $block->mReason =
wfMessage(
'xffblockreason', $block->mReason )->text();
1853 if ( !$block instanceof
Block
1858 $block =
new Block( [
1860 'byText' =>
'MediaWiki default',
1861 'reason' =>
wfMessage(
'softblockrangesreason', $ip )->
text(),
1863 'systemBlock' =>
'wgSoftBlockRanges',
1867 if ( $block instanceof
Block ) {
1868 wfDebug( __METHOD__ .
": Found block.\n" );
1869 $this->mBlock = $block;
1870 $this->mBlockedby = $block->getByName();
1871 $this->mBlockreason = $block->mReason;
1872 $this->mHideName = $block->mHideName;
1873 $this->mAllowUsertalk = !$block->prevents(
'editownusertalk' );
1875 $this->mBlock =
null;
1876 $this->mBlockedby =
'';
1877 $this->mBlockreason =
'';
1878 $this->mHideName = 0;
1879 $this->mAllowUsertalk =
false;
1885 Hooks::run(
'GetBlockedStatus', [ &$thisUser ] );
1895 if ( strlen( $blockCookieVal ) < 1 || !is_numeric( substr( $blockCookieVal, 0, 1 ) ) ) {
1900 if ( $blockCookieId !==
null ) {
1903 if ( $tmpBlock instanceof
Block ) {
1906 && !$tmpBlock->isExpired()
1907 && $tmpBlock->isAutoblocking();
1909 $useBlockCookie = ( $config->get(
'CookieSetOnAutoblock' ) ===
true );
1910 if ( $blockIsValid && $useBlockCookie ) {
1956 if ( IP::isIPv4( $ip ) ) {
1958 $ipReversed = implode(
'.', array_reverse( explode(
'.', $ip ) ) );
1960 foreach ( (array)$bases as
$base ) {
1964 if ( is_array(
$base ) ) {
1965 if ( count(
$base ) >= 2 ) {
1967 $host =
"{$base[1]}.$ipReversed.{$base[0]}";
1969 $host =
"$ipReversed.{$base[0]}";
1971 $basename =
$base[0];
1973 $host =
"$ipReversed.$base";
1977 $ipList = gethostbynamel( $host );
1980 wfDebugLog(
'dnsblacklist',
"Hostname $host is {$ipList[0]}, it's a proxy says $basename!" );
1984 wfDebugLog(
'dnsblacklist',
"Requested $host, not found in $basename." );
2011 $resultProxyList = [];
2012 $deprecatedIPEntries = [];
2016 $keyIsIP = IP::isIPAddress( $key );
2017 $valueIsIP = IP::isIPAddress(
$value );
2018 if ( $keyIsIP && !$valueIsIP ) {
2019 $deprecatedIPEntries[] = $key;
2020 $resultProxyList[] = $key;
2021 } elseif ( $keyIsIP && $valueIsIP ) {
2022 $deprecatedIPEntries[] = $key;
2023 $resultProxyList[] = $key;
2024 $resultProxyList[] =
$value;
2026 $resultProxyList[] =
$value;
2030 if ( $deprecatedIPEntries ) {
2032 'IP addresses in the keys of $wgProxyList (found the following IP addresses in keys: ' .
2033 implode(
', ', $deprecatedIPEntries ) .
', please move them to values)',
'1.30' );
2036 $proxyListIPSet =
new IPSet( $resultProxyList );
2037 return $proxyListIPSet->match( $ip );
2053 return !$this->
isAllowed(
'noratelimit' );
2076 $logger = \MediaWiki\Logger\LoggerFactory::getInstance(
'ratelimit' );
2080 if ( !Hooks::run(
'PingLimiter', [ &$user, $action, &$result, $incrBy ] ) ) {
2089 $limits = array_merge(
2090 [
'&can-bypass' =>
true ],
2099 $logger->debug( __METHOD__ .
": limiting $action rate for {$this->getName()}" );
2102 $id = $this->
getId();
2104 $cache = ObjectCache::getLocalClusterInstance();
2108 if ( isset( $limits[
'anon'] ) ) {
2109 $keys[
$cache->makeKey(
'limiter', $action,
'anon' )] = $limits[
'anon'];
2113 if ( isset( $limits[
'user-global'] ) ) {
2114 $lookup = CentralIdLookup::factoryNonLocal();
2116 $centralId = $lookup
2117 ? $lookup->centralIdFromLocalUser( $this, CentralIdLookup::AUDIENCE_RAW )
2122 $realm = $lookup->getProviderId();
2124 $globalKey =
$cache->makeGlobalKey(
'limiter', $action,
'user-global',
2125 $realm, $centralId );
2128 $globalKey =
$cache->makeKey(
'limiter', $action,
'user-global',
2131 $keys[$globalKey] = $limits[
'user-global'];
2137 if ( isset( $limits[
'ip'] ) ) {
2139 $keys[
$cache->makeGlobalKey(
'limiter', $action,
'ip', $ip )] = $limits[
'ip'];
2142 if ( isset( $limits[
'subnet'] ) ) {
2144 $subnet = IP::getSubnet( $ip );
2145 if ( $subnet !==
false ) {
2146 $keys[
$cache->makeGlobalKey(
'limiter', $action,
'subnet', $subnet )] = $limits[
'subnet'];
2153 if ( $id !== 0 && isset( $limits[
'user'] ) ) {
2155 $userLimit = $limits[
'user'];
2158 if ( $id !== 0 && $isNewbie && isset( $limits[
'newbie'] ) ) {
2159 $userLimit = $limits[
'newbie'];
2163 foreach ( $this->
getGroups() as $group ) {
2164 if ( isset( $limits[$group] ) ) {
2165 if ( $userLimit ===
false
2166 || $limits[$group][0] / $limits[$group][1] > $userLimit[0] / $userLimit[1]
2168 $userLimit = $limits[$group];
2175 if ( $userLimit !==
false ) {
2176 list( $max, $period ) = $userLimit;
2177 $logger->debug( __METHOD__ .
": effective user limit: $max in {$period}s" );
2178 $keys[
$cache->makeKey(
'limiter', $action,
'user', $id )] = $userLimit;
2182 if ( isset( $limits[
'ip-all'] ) ) {
2185 if ( $isNewbie || $userLimit ===
false
2186 || $limits[
'ip-all'][0] / $limits[
'ip-all'][1] > $userLimit[0] / $userLimit[1] ) {
2187 $keys[
$cache->makeGlobalKey(
'limiter', $action,
'ip-all', $ip )] = $limits[
'ip-all'];
2192 if ( isset( $limits[
'subnet-all'] ) ) {
2194 $subnet = IP::getSubnet( $ip );
2195 if ( $subnet !==
false ) {
2197 if ( $isNewbie || $userLimit ===
false
2198 || $limits[
'ip-all'][0] / $limits[
'ip-all'][1]
2199 > $userLimit[0] / $userLimit[1] ) {
2200 $keys[
$cache->makeGlobalKey(
'limiter', $action,
'subnet-all', $subnet )]
2201 = $limits[
'subnet-all'];
2213 foreach (
$keys as $key => $limit ) {
2221 function (
$cache, $key, $data, &$expiry )
2222 use ( $action, $logger, &$triggered, $now, $clockFudge, $limit, $incrBy )
2227 list( $max, $period ) = $limit;
2229 $expiry = $now + (int)$period;
2236 $fields = explode(
'|', $data );
2237 $storedCount = (int)( $fields[0] ?? 0 );
2238 $storedExpiry = (int)( $fields[1] ?? PHP_INT_MAX );
2241 if ( $storedExpiry < ( $now + $clockFudge ) ) {
2243 'User::pingLimiter: '
2244 .
'Stale rate limit entry, cache key failed to expire (T246991)',
2246 'action' => $action,
2249 'period' => $period,
2250 'count' => $storedCount,
2252 'expiry' => MWTimestamp::convert( TS_DB, $storedExpiry ),
2258 $expiry = min( $storedExpiry, $now + (
int)$period );
2259 $count = $storedCount;
2264 if ( $count >= $max ) {
2265 if ( !$triggered ) {
2267 'User::pingLimiter: User tripped rate limit',
2269 'action' => $action,
2273 'period' => $period,
2284 $data =
"$count|$expiry";
2312 return $this->mBlock instanceof
Block ? $this->mBlock :
null;
2325 $blocked = $this->
isBlocked( $bFromSlave );
2328 if ( !$this->mHideName && $allowUsertalk && $title->getText() === $this->
getName()
2331 wfDebug( __METHOD__ .
": self-talk page, ignoring any blocks\n" );
2334 Hooks::run(
'UserIsBlockedFrom', [ $this, $title, &$blocked, &$allowUsertalk ] );
2363 return ( $this->mBlock ? $this->mBlock->getId() :
false );
2389 if ( $this->mGlobalBlock !==
null ) {
2390 return $this->mGlobalBlock ?:
null;
2393 if ( IP::isIPAddress( $this->
getName() ) ) {
2402 Hooks::run(
'UserIsBlockedGlobally', [ &$user, $ip, &$blocked, &$block ] );
2404 if ( $blocked && $block ===
null ) {
2406 $block =
new Block( [
2408 'systemBlock' =>
'global-block'
2412 $this->mGlobalBlock = $blocked ? $block :
false;
2413 return $this->mGlobalBlock ?:
null;
2422 if ( $this->mLocked !==
null ) {
2427 $authUser = AuthManager::callLegacyAuthPlugin(
'getUserInstance', [ &$user ],
null );
2428 $this->mLocked = $authUser && $authUser->isLocked();
2429 Hooks::run(
'UserIsLocked', [ $this, &$this->mLocked ] );
2439 if ( $this->mHideName !==
null ) {
2443 if ( !$this->mHideName ) {
2446 $authUser = AuthManager::callLegacyAuthPlugin(
'getUserInstance', [ &$user ],
null );
2447 $this->mHideName = $authUser && $authUser->isHidden();
2448 Hooks::run(
'UserIsHidden', [ $this, &$this->mHideName ] );
2458 if ( $this->mId ===
null && $this->mName !==
null && self::isIP( $this->mName ) ) {
2488 if ( $this->mName ===
false ) {
2490 $this->mName = IP::sanitizeIP( $this->
getRequest()->getIP() );
2511 $this->mName = $str;
2531 if ( $this->mActorId ===
null || !$this->mActorId && $dbw ) {
2532 $migration = MediaWikiServices::getInstance()->getActorMigration();
2537 $this->mActorId = $migration->getNewActorId( $dbw, $this );
2553 return str_replace(
' ',
'_', $this->
getName() );
2564 if ( $this->mNewtalk === -1 ) {
2565 $this->mNewtalk =
false; # reset talk page status
2569 if ( !$this->mId ) {
2573 $this->mNewtalk =
false;
2578 $this->mNewtalk = $this->
checkNewtalk(
'user_id', $this->mId );
2602 if ( !Hooks::run(
'UserRetrieveNewTalks', [ &$user, &$talks ] ) ) {
2610 $timestamp =
$dbr->selectField(
'user_newtalk',
2611 'MIN(user_last_timestamp)',
2612 $this->
isAnon() ? [
'user_ip' => $this->
getName() ] : [
'user_id' => $this->
getId() ],
2614 $rev = $timestamp ? Revision::loadFromTimestamp(
$dbr, $utp, $timestamp ) :
null;
2615 return [ [
'wiki' =>
wfWikiID(),
'link' => $utp->getLocalURL(),
'rev' =>
$rev ] ];
2624 $newMessageRevisionId =
null;
2626 if ( $newMessageLinks ) {
2630 if ( count( $newMessageLinks ) === 1
2631 && $newMessageLinks[0][
'wiki'] ===
wfWikiID()
2632 && $newMessageLinks[0][
'rev']
2635 $newMessageRevision = $newMessageLinks[0][
'rev'];
2636 $newMessageRevisionId = $newMessageRevision->getId();
2639 return $newMessageRevisionId;
2653 $ok =
$dbr->selectField(
'user_newtalk', $field, [ $field => $id ], __METHOD__ );
2655 return $ok !==
false;
2667 $prevRev = $curRev ? $curRev->getPrevious() :
false;
2668 $ts = $prevRev ? $prevRev->getTimestamp() :
null;
2671 $dbw->insert(
'user_newtalk',
2672 [ $field => $id,
'user_last_timestamp' => $dbw->timestampOrNull( $ts ) ],
2675 if ( $dbw->affectedRows() ) {
2676 wfDebug( __METHOD__ .
": set on ($field, $id)\n" );
2679 wfDebug( __METHOD__ .
" already set ($field, $id)\n" );
2692 $dbw->delete(
'user_newtalk',
2695 if ( $dbw->affectedRows() ) {
2696 wfDebug( __METHOD__ .
": killed on ($field, $id)\n" );
2699 wfDebug( __METHOD__ .
": already gone ($field, $id)\n" );
2716 $this->mNewtalk = $val;
2723 $id = $this->
getId();
2746 if ( $this->mTouched && $time <= $this->mTouched ) {
2764 if ( !$this->
getId() ) {
2768 $cache = ObjectCache::getMainWANInstance();
2770 if ( $mode ===
'refresh' ) {
2771 $cache->delete( $key, 1 );
2773 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
2774 if ( $lb->hasOrMadeRecentMasterChanges() ) {
2775 $lb->getConnection(
DB_MASTER )->onTransactionPreCommitOrIdle(
2776 function () use (
$cache, $key ) {
2810 $id = $this->
getId();
2812 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
2813 $key =
$cache->makeKey(
'user-quicktouched',
'id', $id );
2814 $cache->touchCheckKey( $key );
2815 $this->mQuickTouched =
null;
2825 return ( $timestamp >= $this->
getTouched() );
2840 if ( $this->mQuickTouched ===
null ) {
2841 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
2842 $key =
$cache->makeKey(
'user-quicktouched',
'id', $this->mId );
2847 return max( $this->mTouched, $this->mQuickTouched );
2905 $manager = AuthManager::singleton();
2908 if ( !$manager->userExists( $this->getName() ) ) {
2909 throw new LogicException(
'Cannot set a password for a user that is not in the database.' );
2913 'username' => $this->
getName(),
2918 \MediaWiki\Logger\LoggerFactory::getInstance(
'authentication' )
2919 ->info( __METHOD__ .
': Password change rejected: '
2920 .
$status->getWikiText(
null,
null,
'en' ) );
2924 $this->
setOption(
'watchlisttoken',
false );
2925 SessionManager::singleton()->invalidateSessionsForUser( $this );
2943 $manager = AuthManager::singleton();
2944 $reqs = $manager->getAuthenticationRequests( AuthManager::ACTION_CHANGE, $this );
2945 $reqs = AuthenticationRequest::loadRequestsFromSubmission( $reqs, $data );
2947 $status = Status::newGood(
'ignored' );
2948 foreach ( $reqs as
$req ) {
2949 $status->merge( $manager->allowsAuthenticationDataChange(
$req ),
true );
2951 if (
$status->getValue() ===
'ignored' ) {
2952 $status->warning(
'authenticationdatachange-ignored' );
2956 foreach ( $reqs as
$req ) {
2957 $manager->changeAuthenticationData(
$req );
2973 if ( !$this->mToken && $forceCreation ) {
2977 if ( !$this->mToken ) {
2980 } elseif ( $this->mToken === self::INVALID_TOKEN ) {
2992 $len = max( 32, self::TOKEN_LENGTH );
2993 if ( strlen(
$ret ) < $len ) {
2995 throw new \UnexpectedValueException(
'Hmac returned less than 128 bits' );
2997 return substr(
$ret, -$len );
3009 if ( $this->mToken === self::INVALID_TOKEN ) {
3010 \MediaWiki\Logger\LoggerFactory::getInstance(
'session' )
3011 ->debug( __METHOD__ .
": Ignoring attempt to set token for system user \"$this\"" );
3012 } elseif ( !$token ) {
3015 $this->mToken = $token;
3028 throw new BadMethodCallException( __METHOD__ .
' has been removed in 1.27' );
3037 Hooks::run(
'UserGetEmail', [ $this, &$this->mEmail ] );
3047 Hooks::run(
'UserGetEmailAuthenticationTimestamp', [ $this, &$this->mEmailAuthenticated ] );
3057 if ( $str == $this->mEmail ) {
3061 $this->mEmail = $str;
3062 Hooks::run(
'UserSetEmail', [ $this, &$this->mEmail ] );
3076 return Status::newFatal(
'emaildisabled' );
3080 if ( $str === $oldaddr ) {
3081 return Status::newGood(
true );
3084 $type = $oldaddr !=
'' ?
'changed' :
'set';
3085 $notificationResult =
null;
3090 if (
$type ==
'changed' ) {
3091 $change = $str !=
'' ?
'changed' :
'removed';
3092 $notificationResult = $this->
sendMail(
3093 wfMessage(
'notificationemail_subject_' . $change )->
text(),
3094 wfMessage(
'notificationemail_body_' . $change,
3108 if ( $notificationResult !==
null ) {
3109 $result->merge( $notificationResult );
3112 if ( $result->isGood() ) {
3114 $result->value =
'eauth';
3117 $result = Status::newGood(
true );
3141 $this->mRealName = $str;
3154 public function getOption( $oname, $defaultOverride =
null, $ignoreHidden =
false ) {
3158 # We want 'disabled' preferences to always behave as the default value for
3159 # users, even if they have set the option explicitly in their settings (ie they
3160 # set it, and then it was disabled removing their ability to change it). But
3161 # we don't want to erase the preferences in the database in case the preference
3162 # is re-enabled again. So don't touch $mOptions, just override the returned value
3167 if ( array_key_exists( $oname, $this->mOptions ) ) {
3168 return $this->mOptions[$oname];
3170 return $defaultOverride;
3187 # We want 'disabled' preferences to always behave as the default value for
3188 # users, even if they have set the option explicitly in their settings (ie they
3189 # set it, and then it was disabled removing their ability to change it). But
3190 # we don't want to erase the preferences in the database in case the preference
3191 # is re-enabled again. So don't touch $mOptions, just override the returned value
3192 foreach ( $wgHiddenPrefs as $pref ) {
3194 if ( $default !==
null ) {
3199 if ( $flags & self::GETOPTIONS_EXCLUDE_DEFAULTS ) {
3214 return (
bool)$this->
getOption( $oname );
3228 $val = $defaultOverride;
3230 return intval( $val );
3245 if ( is_null( $val ) ) {
3249 $this->mOptions[$oname] = $val;
3265 $id = $this->
getId();
3275 $token = hash_hmac(
'sha1',
"$oname:$id", $this->
getToken() );
3327 'registered-multiselect',
3328 'registered-checkmatrix',
3353 $preferencesFactory = MediaWikiServices::getInstance()->getPreferencesFactory();
3354 $prefs = $preferencesFactory->getFormDescriptor( $this,
$context );
3359 $specialOptions = array_fill_keys( $preferencesFactory->getSaveBlacklist(),
true );
3360 foreach ( $specialOptions as $name =>
$value ) {
3361 unset( $prefs[$name] );
3366 $multiselectOptions = [];
3367 foreach ( $prefs as $name => $info ) {
3368 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'multiselect' ) ||
3369 ( isset( $info[
'class'] ) && $info[
'class'] == HTMLMultiSelectField::class ) ) {
3370 $opts = HTMLFormField::flattenOptions( $info[
'options'] );
3371 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
3373 foreach ( $opts as
$value ) {
3374 $multiselectOptions[
"$prefix$value"] =
true;
3377 unset( $prefs[$name] );
3380 $checkmatrixOptions = [];
3381 foreach ( $prefs as $name => $info ) {
3382 if ( ( isset( $info[
'type'] ) && $info[
'type'] ==
'checkmatrix' ) ||
3383 ( isset( $info[
'class'] ) && $info[
'class'] == HTMLCheckMatrix::class ) ) {
3384 $columns = HTMLFormField::flattenOptions( $info[
'columns'] );
3385 $rows = HTMLFormField::flattenOptions( $info[
'rows'] );
3386 $prefix = isset( $info[
'prefix'] ) ? $info[
'prefix'] :
$name;
3388 foreach ( $columns as $column ) {
3389 foreach (
$rows as $row ) {
3390 $checkmatrixOptions[
"$prefix$column-$row"] =
true;
3394 unset( $prefs[$name] );
3400 if ( isset( $prefs[$key] ) ) {
3401 $mapping[$key] =
'registered';
3402 } elseif ( isset( $multiselectOptions[$key] ) ) {
3403 $mapping[$key] =
'registered-multiselect';
3404 } elseif ( isset( $checkmatrixOptions[$key] ) ) {
3405 $mapping[$key] =
'registered-checkmatrix';
3406 } elseif ( isset( $specialOptions[$key] ) ) {
3407 $mapping[$key] =
'special';
3408 } elseif ( substr( $key, 0, 7 ) ===
'userjs-' ) {
3409 $mapping[$key] =
'userjs';
3411 $mapping[$key] =
'unused';
3433 $resetKinds = [
'registered',
'registered-multiselect',
'registered-checkmatrix',
'unused' ],
3439 if ( !is_array( $resetKinds ) ) {
3440 $resetKinds = [ $resetKinds ];
3443 if ( in_array(
'all', $resetKinds ) ) {
3444 $newOptions = $defaultOptions;
3451 $resetKinds = array_intersect( $resetKinds, self::listOptionKinds() );
3456 foreach ( $this->mOptions as $key =>
$value ) {
3457 if ( in_array( $optionKinds[$key], $resetKinds ) ) {
3458 if ( array_key_exists( $key, $defaultOptions ) ) {
3459 $newOptions[$key] = $defaultOptions[$key];
3462 $newOptions[$key] =
$value;
3467 Hooks::run(
'UserResetAllOptions', [ $this, &$newOptions, $this->mOptions, $resetKinds ] );
3469 $this->mOptions = $newOptions;
3470 $this->mOptionsLoaded =
true;
3479 if ( is_null( $this->mDatePreference ) ) {
3482 $map =
$wgLang->getDatePreferenceMigrationMap();
3483 if ( isset( $map[
$value] ) ) {
3486 $this->mDatePreference =
$value;
3506 Hooks::run(
'UserRequiresHTTPS', [ $this, &$https ] );
3535 if ( is_null( $this->mRights ) ) {
3537 Hooks::run(
'UserGetRights', [ $this, &$this->mRights ] );
3541 if ( !defined(
'MW_NO_SESSION' ) ) {
3542 $allowedRights = $this->
getRequest()->getSession()->getAllowedUserRights();
3543 if ( $allowedRights !==
null ) {
3544 $this->mRights = array_intersect( $this->mRights, $allowedRights );
3549 $this->mRights = array_values( array_unique( $this->mRights ) );
3560 $config->get(
'BlockDisablesLogin' ) &&
3564 $this->mRights = array_intersect( $this->mRights, $anon->getRights() );
3578 return array_keys( $this->mGroupMemberships );
3602 if ( $recache || is_null( $this->mEffectiveGroups ) ) {
3603 $this->mEffectiveGroups = array_unique( array_merge(
3610 Hooks::run(
'UserEffectiveGroups', [ &$user, &$this->mEffectiveGroups ] );
3612 $this->mEffectiveGroups = array_values( array_unique( $this->mEffectiveGroups ) );
3625 if ( $recache || is_null( $this->mImplicitGroups ) ) {
3626 $this->mImplicitGroups = [
'*' ];
3627 if ( $this->
getId() ) {
3628 $this->mImplicitGroups[] =
'user';
3630 $this->mImplicitGroups = array_unique( array_merge(
3631 $this->mImplicitGroups,
3638 $this->mEffectiveGroups =
null;
3656 if ( is_null( $this->mFormerGroups ) ) {
3657 $db = ( $this->queryFlagsUsed & self::READ_LATEST )
3660 $res = $db->select(
'user_former_groups',
3662 [
'ufg_user' => $this->mId ],
3664 $this->mFormerGroups = [];
3665 foreach (
$res as $row ) {
3666 $this->mFormerGroups[] = $row->ufg_group;
3678 if ( !$this->
getId() ) {
3682 if ( $this->mEditCount ===
null ) {
3686 $count =
$dbr->selectField(
3687 'user',
'user_editcount',
3688 [
'user_id' => $this->mId ],
3692 if ( $count ===
null ) {
3696 $this->mEditCount = $count;
3720 if ( !Hooks::run(
'UserAddGroup', [ $this, &$group, &$expiry ] ) ) {
3726 if ( !$ugm->insert(
true ) ) {
3730 $this->mGroupMemberships[$group] = $ugm;
3735 $this->mRights =
null;
3751 if ( !Hooks::run(
'UserRemoveGroup', [ $this, &$group ] ) ) {
3755 $ugm = UserGroupMembership::getMembership( $this->mId, $group );
3757 if ( !$ugm || !$ugm->delete() ) {
3762 unset( $this->mGroupMemberships[$group] );
3767 $this->mRights =
null;
3783 return $this->
getId() != 0;
3814 Hooks::run(
"UserIsBot", [ $this, &$isBot ] );
3826 $permissions = func_get_args();
3827 foreach ( $permissions as $permission ) {
3828 if ( $this->
isAllowed( $permission ) ) {
3841 $permissions = func_get_args();
3842 foreach ( $permissions as $permission ) {
3843 if ( !$this->
isAllowed( $permission ) ) {
3856 if ( $action ===
'' ) {
3861 return in_array( $action, $this->
getRights(),
true );
3903 if ( $this->mRequest ) {
3919 public function isWatched( $title, $checkRights = self::CHECK_USER_RIGHTS ) {
3920 if ( $title->isWatchable() && ( !$checkRights || $this->isAllowed(
'viewmywatchlist' ) ) ) {
3921 return MediaWikiServices::getInstance()->getWatchedItemStore()->isWatched( $this, $title );
3933 public function addWatch( $title, $checkRights = self::CHECK_USER_RIGHTS ) {
3934 if ( !$checkRights || $this->
isAllowed(
'editmywatchlist' ) ) {
3935 MediaWikiServices::getInstance()->getWatchedItemStore()->addWatchBatchForUser(
3937 [ $title->getSubjectPage(), $title->getTalkPage() ]
3950 public function removeWatch( $title, $checkRights = self::CHECK_USER_RIGHTS ) {
3951 if ( !$checkRights || $this->
isAllowed(
'editmywatchlist' ) ) {
3952 $store = MediaWikiServices::getInstance()->getWatchedItemStore();
3953 $store->removeWatch( $this, $title->getSubjectPage() );
3954 $store->removeWatch( $this, $title->getTalkPage() );
3976 if ( !$this->
isAllowed(
'editmywatchlist' ) ) {
3981 if ( $title->getNamespace() ==
NS_USER_TALK && $title->getText() == $this->getName() ) {
3984 if ( !Hooks::run(
'UserClearNewTalkNotification', [ &$user, $oldid ] ) ) {
3989 DeferredUpdates::addCallableUpdate(
function () use ( $title, $oldid ) {
3999 ? $title->getNextRevisionID( $oldid, Title::GAID_FOR_UPDATE )
4002 $this->
setNewtalk(
true, Revision::newFromId( $nextid ) );
4025 MediaWikiServices::getInstance()->getWatchedItemStore()
4026 ->resetNotificationTimestamp( $this, $title, $force, $oldid );
4047 $id = $this->
getId();
4052 $watchedItemStore = MediaWikiServices::getInstance()->getWatchedItemStore();
4053 $watchedItemStore->resetAllNotificationTimestampsForUser( $this );
4082 $registration > $learnerRegistration
4087 $registration <= $experiencedRegistration
4089 return 'experienced';
4105 if ( 0 == $this->mId ) {
4109 $session = $this->
getRequest()->getSession();
4111 $session = $session->sessionWithRequest(
$request );
4113 $delay = $session->delaySave();
4115 if ( !$session->getUser()->equals( $this ) ) {
4116 if ( !$session->canSetUser() ) {
4117 \MediaWiki\Logger\LoggerFactory::getInstance(
'session' )
4118 ->warning( __METHOD__ .
4119 ": Cannot save user \"$this\" to a user \"{$session->getUser()}\"'s immutable session"
4123 $session->setUser( $this );
4126 $session->setRememberUser( $rememberMe );
4127 if ( $secure !==
null ) {
4128 $session->setForceHTTPS( $secure );
4131 $session->persist();
4133 ScopedCallback::consume( $delay );
4142 if ( Hooks::run(
'UserLogout', [ &$user ] ) ) {
4152 $session = $this->
getRequest()->getSession();
4153 if ( !$session->canSetUser() ) {
4154 \MediaWiki\Logger\LoggerFactory::getInstance(
'session' )
4155 ->warning( __METHOD__ .
": Cannot log out of an immutable session" );
4156 $error =
'immutable';
4157 } elseif ( !$session->getUser()->equals( $this ) ) {
4158 \MediaWiki\Logger\LoggerFactory::getInstance(
'session' )
4159 ->warning( __METHOD__ .
4160 ": Cannot log user \"$this\" out of a user \"{$session->getUser()}\"'s session"
4164 $error =
'wronguser';
4167 $delay = $session->delaySave();
4168 $session->unpersist();
4169 $session->setLoggedOutTimestamp( time() );
4170 $session->setUser(
new User );
4171 $session->set(
'wsUserID', 0 );
4172 $session->resetAllTokens();
4173 ScopedCallback::consume( $delay );
4176 \MediaWiki\Logger\LoggerFactory::getInstance(
'authevents' )->info(
'Logout', [
4177 'event' =>
'logout',
4178 'successful' => $error ===
false,
4179 'status' => $error ?:
'success',
4193 "Could not update user with ID '{$this->mId}'; DB is read-only."
4199 if ( 0 == $this->mId ) {
4209 $dbw->doAtomicSection( __METHOD__,
function ( $dbw,
$fname ) use ( $newTouched ) {
4212 $dbw->update(
'user',
4214 'user_name' => $this->mName,
4215 'user_real_name' => $this->mRealName,
4216 'user_email' => $this->mEmail,
4217 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
4218 'user_touched' => $dbw->timestamp( $newTouched ),
4219 'user_token' => strval( $this->mToken ),
4220 'user_email_token' => $this->mEmailToken,
4221 'user_email_token_expires' => $dbw->timestampOrNull( $this->mEmailTokenExpires ),
4222 ], $this->makeUpdateConditions( $dbw, [
4223 'user_id' => $this->mId,
4227 if ( !$dbw->affectedRows() ) {
4231 $from = ( $this->queryFlagsUsed & self::READ_LATEST ) ?
'master' :
'replica';
4233 "CAS update failed on user_touched for user ID '{$this->mId}' (read from $from);" .
4234 " the version of the user to be saved is older than the current version."
4241 [
'actor_name' => $this->mName ],
4242 [
'actor_user' => $this->mId ],
4248 $this->mTouched = $newTouched;
4251 Hooks::run(
'UserSaveSettings', [ $this ] );
4268 $db = ( ( $flags & self::READ_LATEST ) == self::READ_LATEST )
4273 ? [
'LOCK IN SHARE MODE' ]
4276 $id = $db->selectField(
'user',
4277 'user_id', [
'user_name' =>
$s ], __METHOD__,
$options );
4298 foreach ( [
'password',
'newpassword',
'newpass_time',
'password_expires' ] as $field ) {
4299 if ( isset(
$params[$field] ) ) {
4300 wfDeprecated( __METHOD__ .
" with param '$field'",
'1.27' );
4308 if ( isset(
$params[
'options'] ) ) {
4309 $user->mOptions =
$params[
'options'] + (
array)$user->mOptions;
4314 $noPass = PasswordFactory::newInvalidPassword()->toString();
4317 'user_name' =>
$name,
4318 'user_password' => $noPass,
4319 'user_newpassword' => $noPass,
4320 'user_email' => $user->mEmail,
4321 'user_email_authenticated' => $dbw->timestampOrNull( $user->mEmailAuthenticated ),
4322 'user_real_name' => $user->mRealName,
4323 'user_token' => strval( $user->mToken ),
4324 'user_registration' => $dbw->timestamp( $user->mRegistration ),
4325 'user_editcount' => 0,
4326 'user_touched' => $dbw->timestamp( $user->newTouchedTimestamp() ),
4329 $fields[
"user_$name"] =
$value;
4332 return $dbw->doAtomicSection( __METHOD__,
function ( $dbw,
$fname ) use ( $fields ) {
4333 $dbw->insert(
'user', $fields,
$fname, [
'IGNORE' ] );
4334 if ( $dbw->affectedRows() ) {
4335 $newUser = self::newFromId( $dbw->insertId() );
4337 $newUser->load( self::READ_LATEST );
4338 $newUser->updateActorId( $dbw );
4374 if ( !$this->mToken ) {
4378 if ( !is_string( $this->mName ) ) {
4379 throw new RuntimeException(
"User name field is not set." );
4385 $status = $dbw->doAtomicSection( __METHOD__,
function ( $dbw,
$fname ) {
4386 $noPass = PasswordFactory::newInvalidPassword()->toString();
4387 $dbw->insert(
'user',
4389 'user_name' => $this->mName,
4390 'user_password' => $noPass,
4391 'user_newpassword' => $noPass,
4392 'user_email' => $this->mEmail,
4393 'user_email_authenticated' => $dbw->timestampOrNull( $this->mEmailAuthenticated ),
4394 'user_real_name' => $this->mRealName,
4395 'user_token' => strval( $this->mToken ),
4396 'user_registration' => $dbw->timestamp( $this->mRegistration ),
4397 'user_editcount' => 0,
4398 'user_touched' => $dbw->timestamp( $this->mTouched ),
4402 if ( !$dbw->affectedRows() ) {
4404 $this->mId = $dbw->selectField(
4407 [
'user_name' => $this->mName ],
4409 [
'LOCK IN SHARE MODE' ]
4418 throw new MWException( __METHOD__ .
": hit a key conflict attempting " .
4419 "to insert user '{$this->mName}' row, but it was not present in select!" );
4421 return Status::newFatal(
'userexists' );
4423 $this->mId = $dbw->insertId();
4427 return Status::newGood();
4437 return Status::newGood();
4450 [
'actor_user' => $this->mId,
'actor_name' => $this->mName ],
4453 $this->mActorId = (int)$dbw->
insertId();
4476 wfDebug( __METHOD__ .
"()\n" );
4478 if ( $this->mId == 0 ) {
4483 if ( !$userblock ) {
4487 return (
bool)$userblock->doAutoblock( $this->
getRequest()->getIP() );
4496 if ( $this->mBlock && $this->mBlock->prevents(
'createaccount' ) ) {
4500 # T15611: if the IP address the user is trying to create an account from is
4501 # blocked with createaccount disabled, prevent new account creation there even
4502 # when the user is logged in
4503 if ( $this->mBlockedFromCreateAccount ===
false && !$this->
isAllowed(
'ipblock-exempt' ) ) {
4506 return $this->mBlockedFromCreateAccount instanceof
Block
4507 && $this->mBlockedFromCreateAccount->
prevents(
'createaccount' )
4508 ? $this->mBlockedFromCreateAccount
4518 return $this->mBlock && $this->mBlock->prevents(
'sendemail' );
4535 return Title::makeTitle( NS_USER, $this->
getName() );
4545 return $title->getTalkPage();
4554 return !$this->
isAllowed(
'autoconfirmed' );
4564 $manager = AuthManager::singleton();
4565 $reqs = AuthenticationRequest::loadRequestsFromSubmission(
4566 $manager->getAuthenticationRequests( AuthManager::ACTION_LOGIN ),
4568 'username' => $this->getName(),
4569 'password' => $password,
4572 $res = AuthManager::singleton()->beginAuthentication( $reqs,
'null:' );
4573 switch (
$res->status ) {
4574 case AuthenticationResponse::PASS:
4576 case AuthenticationResponse::FAIL:
4578 \MediaWiki\Logger\LoggerFactory::getInstance(
'authentication' )
4579 ->info( __METHOD__ .
': Authentication failed: ' .
$res->message->plain() );
4582 throw new BadMethodCallException(
4583 'AuthManager returned a response unsupported by ' . __METHOD__
4620 return $request->getSession()->getToken( $salt );
4667 $val = substr( $val, 0, strspn( $val,
'0123456789abcdef' ) ) . Token::SUFFIX;
4686 if (
$type ==
'created' ||
$type ===
false ) {
4687 $message =
'confirmemail_body';
4688 } elseif (
$type ===
true ) {
4689 $message =
'confirmemail_body_changed';
4692 $message =
'confirmemail_body_' .
$type;
4700 $wgLang->userTimeAndDate( $expiration, $this ),
4702 $wgLang->userDate( $expiration, $this ),
4703 $wgLang->userTime( $expiration, $this ) )->text() );
4717 public function sendMail( $subject, $body, $from =
null, $replyto =
null ) {
4720 if ( $from instanceof
User ) {
4729 'replyTo' => $replyto,
4750 $hash = md5( $token );
4751 $this->mEmailToken = $hash;
4752 $this->mEmailTokenExpires = $expiration;
4762 return $this->
getTokenUrl(
'ConfirmEmail', $token );
4771 return $this->
getTokenUrl(
'InvalidateEmail', $token );
4790 $title = Title::makeTitle(
NS_MAIN,
"Special:$page/$token" );
4791 return $title->getCanonicalURL();
4806 Hooks::run(
'ConfirmEmailComplete', [ $this ] );
4820 $this->mEmailToken =
null;
4821 $this->mEmailTokenExpires =
null;
4824 Hooks::run(
'InvalidateEmailComplete', [ $this ] );
4834 $this->mEmailAuthenticated = $timestamp;
4835 Hooks::run(
'UserSetEmailAuthenticationTimestamp', [ $this, &$this->mEmailAuthenticated ] );
4851 Hooks::run(
'UserCanSendEmail', [ &$user, &$canSend ] );
4880 if ( Hooks::run(
'EmailConfirmed', [ &$user, &$confirmed ] ) ) {
4884 if ( !Sanitizer::validateEmail( $this->mEmail ) ) {
4904 $this->mEmailToken &&
4930 if ( $this->
getId() == 0 ) {
4934 $actorWhere = ActorMigration::newMigration()->getWhere(
$dbr,
'rev_user', $this );
4936 [
'revision' ] + $actorWhere[
'tables'],
4938 [ $actorWhere[
'conds'] ],
4940 [
'ORDER BY' =>
'rev_timestamp ASC' ],
4941 $actorWhere[
'joins']
4959 foreach ( $groups as $group ) {
4961 $rights = array_merge( $rights,
4967 foreach ( $groups as $group ) {
4969 $rights = array_diff( $rights,
4973 return array_unique( $rights );
4984 $allowedGroups = [];
4986 if ( self::groupHasPermission( $group, $role ) ) {
4987 $allowedGroups[] = $group;
4990 return $allowedGroups;
5031 if ( isset(
$cache[$right] ) && !defined(
'MW_PHPUNIT_TEST' ) ) {
5042 if ( isset( $rights[$right] ) && $rights[$right] ) {
5050 if ( !defined(
'MW_NO_SESSION' ) ) {
5051 $allowedRights = SessionManager::getGlobalSession()->getAllowedUserRights();
5052 if ( $allowedRights !==
null && !in_array( $right, $allowedRights,
true ) ) {
5059 if ( !Hooks::run(
'UserIsEveryoneAllowed', [ $right ] ) ) {
5077 return UserGroupMembership::getGroupName( $group );
5090 return UserGroupMembership::getGroupMemberName( $group,
$username );
5103 self::getImplicitGroups()
5112 if ( self::$mAllRights ===
false ) {
5115 self::$mAllRights = array_unique( array_merge( self::$mCoreRights,
$wgAvailableRights ) );
5119 Hooks::run(
'UserGetAllRights', [ &self::$mAllRights ] );
5132 # Deprecated, use $wgImplicitGroups instead
5133 Hooks::run(
'UserGetImplicitGroups', [ &$groups ],
'1.25' );
5147 return UserGroupMembership::getGroupPage( $group );
5163 if ( $text ==
'' ) {
5164 $text = UserGroupMembership::getGroupName( $group );
5166 $title = UserGroupMembership::getGroupPage( $group );
5168 return MediaWikiServices::getInstance()
5169 ->getLinkRenderer()->makeLink( $title, $text );
5171 return htmlspecialchars( $text );
5188 if ( $text ==
'' ) {
5189 $text = UserGroupMembership::getGroupName( $group );
5191 $title = UserGroupMembership::getGroupPage( $group );
5193 $page = $title->getFullText();
5194 return "[[$page|$text]]";
5240 if ( is_int( $key ) ) {
5248 if ( is_int( $key ) ) {
5283 if ( $this->
isAllowed(
'userrights' ) ) {
5288 $all = array_merge( self::getAllGroups() );
5306 foreach ( $addergroups as $addergroup ) {
5307 $groups = array_merge_recursive(
5310 $groups[
'add'] = array_unique( $groups[
'add'] );
5311 $groups[
'remove'] = array_unique( $groups[
'remove'] );
5312 $groups[
'add-self'] = array_unique( $groups[
'add-self'] );
5313 $groups[
'remove-self'] = array_unique( $groups[
'remove-self'] );
5347 [
'user_editcount=user_editcount+1' ],
5348 [
'user_id' => $this->
getId(),
'user_editcount IS NOT NULL' ],
5352 if ( $dbw->affectedRows() == 0 ) {
5355 if (
$dbr !== $dbw ) {
5367 if ( $this->mEditCount ===
null ) {
5370 $this->mEditCount += (
$dbr !== $dbw ) ? 1 : 0;
5372 $this->mEditCount++;
5389 $actorWhere = ActorMigration::newMigration()->getWhere(
$dbr,
'rev_user', $this );
5390 $count = (int)
$dbr->selectField(
5391 [
'revision' ] + $actorWhere[
'tables'],
5393 [ $actorWhere[
'conds'] ],
5396 $actorWhere[
'joins']
5398 $count = $count + $add;
5403 [
'user_editcount' => $count ],
5404 [
'user_id' => $this->
getId() ],
5419 $key =
"right-$right";
5421 return $msg->isDisabled() ? $right : $msg->text();
5432 $key =
"grant-$grant";
5434 return $msg->isDisabled() ? $grant : $msg->text();
5485 if ( $this->mOptionsLoaded ) {
5491 if ( !$this->
getId() ) {
5497 $this->mOptions[
'variant'] = $variant;
5498 $this->mOptions[
'language'] = $variant;
5499 $this->mOptionsLoaded =
true;
5504 if ( !is_null( $this->mOptionOverrides ) ) {
5505 wfDebug(
"User: loading options for user " . $this->
getId() .
" from override cache.\n" );
5506 foreach ( $this->mOptionOverrides as $key =>
$value ) {
5507 $this->mOptions[$key] =
$value;
5510 if ( !is_array( $data ) ) {
5511 wfDebug(
"User: loading options for user " . $this->
getId() .
" from database.\n" );
5513 $dbr = ( $this->queryFlagsUsed & self::READ_LATEST )
5519 [
'up_property',
'up_value' ],
5520 [
'up_user' => $this->
getId() ],
5524 $this->mOptionOverrides = [];
5526 foreach (
$res as $row ) {
5531 if ( $row->up_value ===
'0' ) {
5534 $data[$row->up_property] = $row->up_value;
5540 if ( isset( $data[
'email-blacklist'] ) && $data[
'email-blacklist'] ) {
5541 $data[
'email-blacklist'] = array_map(
'intval', explode(
"\n", $data[
'email-blacklist'] ) );
5550 $this->mOptionsLoaded =
true;
5552 Hooks::run(
'UserLoadOptions', [ $this, &$this->mOptions ] );
5567 if ( isset( $this->mOptions[
'email-blacklist'] ) ) {
5568 if ( $this->mOptions[
'email-blacklist'] ) {
5569 $value = $this->mOptions[
'email-blacklist'];
5572 if ( is_array(
$value ) ) {
5573 $ids = array_filter(
$value,
'is_numeric' );
5575 $lookup = CentralIdLookup::factory();
5576 $ids = $lookup->centralIdsFromNames( explode(
"\n",
$value ), $this );
5578 $this->mOptions[
'email-blacklist'] = $ids;
5579 $saveOptions[
'email-blacklist'] = implode(
"\n", $this->mOptions[
'email-blacklist'] );
5582 $this->mOptions[
'email-blacklist'] =
null;
5588 if ( !Hooks::run(
'UserSaveOptions', [ $this, &$saveOptions ] ) ) {
5592 $userId = $this->
getId();
5595 foreach ( $saveOptions as $key =>
$value ) {
5598 if ( ( $defaultOption ===
null &&
$value !==
false &&
$value !==
null )
5599 ||
$value != $defaultOption
5602 'up_user' => $userId,
5603 'up_property' => $key,
5611 $res = $dbw->select(
'user_properties',
5612 [
'up_property',
'up_value' ], [
'up_user' => $userId ], __METHOD__ );
5617 foreach (
$res as $row ) {
5618 if ( !isset( $saveOptions[$row->up_property] )
5619 || strcmp( $saveOptions[$row->up_property], $row->up_value ) != 0
5621 $keysDelete[] = $row->up_property;
5625 if ( count( $keysDelete ) ) {
5633 $dbw->delete(
'user_properties',
5634 [
'up_user' => $userId,
'up_property' => $keysDelete ], __METHOD__ );
5637 $dbw->insert(
'user_properties', $insert_rows, __METHOD__, [
'IGNORE' ] );
5655 'user_email_authenticated',
5657 'user_email_token_expires',
5658 'user_registration',
5676 'tables' => [
'user' ],
5684 'user_email_authenticated',
5686 'user_email_token_expires',
5687 'user_registration',
5693 $ret[
'tables'][
'user_actor'] =
'actor';
5694 $ret[
'fields'][] =
'user_actor.actor_id';
5695 $ret[
'joins'][
'user_actor'] = [
5697 [
'user_actor.actor_user = user_id' ]
5714 foreach ( self::getGroupsWithPermission( $permission ) as $group ) {
5719 return Status::newFatal(
'badaccess-groups',
$wgLang->commaList( $groups ), count( $groups ) );
5721 return Status::newFatal(
'badaccess-group0' );
5735 if ( !$this->
getId() ) {
5740 if ( !$user->loadFromId( self::READ_EXCLUSIVE ) ) {
$wgRateLimitsExcludedIPs
Array of IPs / CIDR ranges which should be excluded from rate limits.
$wgApplyIpBlocksToXff
Whether to look at the X-Forwarded-For header's list of (potentially spoofed) IPs and apply IP blocks...
$wgUserEmailConfirmationTokenExpiry
The time, in seconds, when an email confirmation email expires.
$wgMaxArticleSize
Maximum article size in kilobytes.
$wgLearnerMemberSince
Name of the external diff engine to use.
$wgProxyList
Big list of banned IP addresses.
$wgHiddenPrefs
An array of preferences to not show for the user.
$wgDefaultUserOptions
Settings added to this array will override the default globals for the user preferences used by anony...
$wgDisableAnonTalk
Disable links to talk pages of anonymous users (IPs) in listings on special pages like page history,...
$wgAutopromoteOnceLogInRC
Put user rights log entries for autopromotion in recent changes?
$wgEnableUserEmail
Set to true to enable user-to-user e-mail.
$wgPasswordPolicy
Password policy for local wiki users.
$wgExperiencedUserMemberSince
Name of the external diff engine to use.
$wgUseFilePatrol
Use file patrolling to check new files on Special:Newfiles.
string null $wgAuthenticationTokenVersion
Versioning for authentication tokens.
string[] $wgSoftBlockRanges
IP ranges that should be considered soft-blocked (anon-only, account creation allowed).
$wgProxyWhitelist
Proxy whitelist, list of addresses that are assumed to be non-proxy despite what the other methods mi...
$wgClockSkewFudge
Clock skew or the one-second resolution of time() can occasionally cause cache problems when the user...
$wgGroupsAddToSelf
A map of group names that the user is in, to group names that those users are allowed to add or revok...
$wgShowUpdatedMarker
Show "Updated (since my last visit)" marker in RC view, watchlist and history view for watched pages ...
$wgUseRCPatrol
Use RC Patrolling to check for vandalism (from recent changes and watchlists) New pages and new files...
$wgLearnerEdits
The following variables define 3 user experience levels:
$wgUseNPPatrol
Use new page patrolling to check new pages on Special:Newpages.
$wgInvalidUsernameCharacters
Characters to prevent during new account creations.
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
$wgMaxNameChars
Maximum number of bytes in username.
$wgSecureLogin
This is to let user authenticate using https when they come from http.
$wgImplicitGroups
Implicit groups, aren't shown on Special:Listusers or somewhere else.
$wgAddGroups
$wgAddGroups and $wgRemoveGroups can be used to give finer control over who can assign which groups a...
$wgBlockAllowsUTEdit
Set this to true to allow blocked users to edit their own user talk page.
$wgExperiencedUserEdits
Name of the external diff engine to use.
$wgReservedUsernames
Array of usernames which may not be registered or logged in from Maintenance scripts can still use th...
$wgDefaultSkin
Default skin, for new users and anonymous visitors.
$wgRevokePermissions
Permission keys revoked from users in each group.
$wgEnableDnsBlacklist
Whether to use DNS blacklists in $wgDnsBlacklistUrls to check for open proxies.
bool $wgForceHTTPS
If this is true, when an insecure HTTP request is received, always redirect to HTTPS.
$wgDnsBlacklistUrls
List of DNS blacklists to use, if $wgEnableDnsBlacklist is true.
$wgMinimalPasswordLength
Specifies the minimal length of a user password.
$wgEmailAuthentication
Require email authentication before sending mail to an email address.
$wgPasswordSender
Sender email address for e-mail notifications.
$wgRateLimits
Simple rate limiter options to brake edit floods.
$wgNamespacesToBeSearchedDefault
List of namespaces which are searched by default.
int $wgActorTableSchemaMigrationStage
Actor table schema migration stage.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTimestampOrNull( $outputtype=TS_UNIX, $ts=null)
Return a formatted timestamp, or null if input is null.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfGetLB( $wiki=false)
Get a load balancer object.
wfReadOnly()
Check whether the wiki is in read-only mode.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfCanIPUseHTTPS( $ip)
Determine whether the client at a given source IP is likely to be able to access the wiki via HTTPS.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
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
$wgGroupPermissions['sysop']['replacetext']
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
foreach( $wgExtensionFunctions as $func) if(!defined('MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised
if(! $wgDBerrorLogTZ) $wgRequest
static clearCookie(WebResponse $response)
Unset the 'BlockID' cookie.
prevents( $action, $x=null)
Get/set whether the Block prevents a given action.
static newFromID( $id)
Load a blocked user from their block id.
static getBlocksForIPList(array $ipChain, $isAnon, $fromMaster=false)
Get all blocks that match any IP from an array of IP addresses.
static chooseBlock(array $blocks, array $ipChain)
From a list of multiple blocks, find the most exact and strongest Block.
static getIdFromCookieValue( $cookieValue)
Get the stored ID from the 'BlockID' cookie.
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
Value object representing a logged-out user's edit token.
static hmac( $data, $key, $raw=true)
Generate an acceptably unstable one-way-hmac of some text making use of the best hash algorithm that ...
static generateHex( $chars, $forceStrong=false)
Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format.
Stores a single person's name and email address.
static newFromUser(User $user)
Create a new MailAddress object for the given user.
Class for creating log entries manually, to inject them into the database.
static getMain()
Get the RequestContext object associated with the main request.
Represents a "user group membership" – a specific instance of a user belonging to a group.
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...
Check if a user's password complies with any password policies that apply to that user,...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
loadFromSession()
Load user data from the session.
addWatch( $title, $checkRights=self::CHECK_USER_RIGHTS)
Watch an article.
string $mTouched
TS_MW timestamp from the DB.
logout()
Log this user out.
getOptions( $flags=0)
Get all user's options.
getRequest()
Get the WebRequest object to use with this object.
getPasswordValidity( $password)
Given unvalidated password input, return error message on failure.
Block $mBlockedFromCreateAccount
getName()
Get the user name, or the IP of an anonymous user.
addToDatabase()
Add this existing user object to the database.
requiresHTTPS()
Determine based on the wiki configuration and the user's options, whether this user must be over HTTP...
isBlocked( $bFromSlave=true)
Check if user is blocked.
updateActorId(IDatabase $dbw)
Update the actor ID after an insert.
getExperienceLevel()
Compute experienced level based on edit count and registration date.
static isEveryoneAllowed( $right)
Check if all users may be assumed to have the given permission.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
resetOptions( $resetKinds=[ 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused'], IContextSource $context=null)
Reset certain (or all) options to the site defaults.
static whoIsReal( $id)
Get the real name of a user given their user ID.
invalidateCache()
Immediately touch the user data cache for this account.
static $mCacheVars
Array of Strings List of member variables which are saved to the shared cache (memcached).
getEmailAuthenticationTimestamp()
Get the timestamp of the user's e-mail authentication.
isBlockedFromEmailuser()
Get whether the user is blocked from using Special:Emailuser.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new user object.
$mOptionsLoaded
Bool Whether the cache variables have been loaded.
static isCreatableName( $name)
Usernames which fail to pass this function will be blocked from new account registrations,...
getFirstEditTimestamp()
Get the timestamp of the first edit.
getOptionKinds(IContextSource $context, $options=null)
Return an associative array mapping preferences keys to the kind of a preference they're used for.
getBlockedStatus( $bFromSlave=true)
Get blocking information.
static changeableByGroup( $group)
Returns an array of the groups that a particular group can add/remove.
const VERSION
@const int Serialized record version.
getEditTokenObject( $salt='', $request=null)
Initialize (if necessary) and return a session token value which can be used in edit forms to show th...
static getAllGroups()
Return the set of defined explicit groups.
string $mEmailTokenExpires
setCookies( $request=null, $secure=null, $rememberMe=false)
Persist this user's session (e.g.
getEditToken( $salt='', $request=null)
Initialize (if necessary) and return a session token value which can be used in edit forms to show th...
isDnsBlacklisted( $ip, $checkWhitelist=false)
Whether the given IP is in a DNS blacklist.
int $queryFlagsUsed
User::READ_* constant bitfield used to load data.
static $mAllRights
String Cached results of getAllRights()
getTokenUrl( $page, $token)
Internal function to format the e-mail validation/invalidation URLs.
addGroup( $group, $expiry=null)
Add the user to the given group.
isRegistered()
Alias of isLoggedIn() with a name that describes its actual functionality.
isBlockedGlobally( $ip='')
Check if user is blocked on all wikis.
string $mQuickTouched
TS_MW timestamp from cache.
const INVALID_TOKEN
@const string An invalid value for user_token
isSafeToLoad()
Test if it's safe to load this User object.
static groupHasPermission( $group, $role)
Check, if the given group has the given permission.
isEmailConfirmed()
Is this user's e-mail address valid-looking and confirmed within limits of the current site configura...
spreadAnyEditBlock()
If this user is logged-in and blocked, block any IP address they've successfully logged in from.
useFilePatrol()
Check whether to enable new files patrol features for this user.
loadFromId( $flags=self::READ_NORMAL)
Load user table data, given mId has already been set.
isAllowed( $action='')
Internal mechanics of testing a permission.
getDBTouched()
Get the user_touched timestamp field (time of last DB updates)
setName( $str)
Set the user name.
changeAuthenticationData(array $data)
Changes credentials of the user.
static $mCoreRights
Array of Strings Core rights.
getId()
Get the user's ID.
getRealName()
Get the user's real name.
loadOptions( $data=null)
Load the user options either from cache, the database or an array.
getBoolOption( $oname)
Get the user's current setting for a given option, as a boolean value.
getRegistration()
Get the timestamp of account creation.
static isLocallyBlockedProxy( $ip)
Check if an IP address is in the local proxy list.
getGlobalBlock( $ip='')
Check if user is blocked on all wikis.
static newFromAnyId( $userId, $userName, $actorId)
Static factory method for creation from an ID, name, and/or actor ID.
isItemLoaded( $item, $all='all')
Return whether an item has been loaded.
getMutableCacheKeys(WANObjectCache $cache)
getTokenFromOption( $oname)
Get a token stored in the preferences (like the watchlist one), resetting it if it's empty (and savin...
isNewbie()
Determine whether the user is a newbie.
clearNotification(&$title, $oldid=0)
Clear the user's notification timestamp for the given title.
static resetIdByNameCache()
Reset the cache used in idFromName().
deleteNewtalk( $field, $id)
Clear the new messages flag for the given user.
loadFromDatabase( $flags=self::READ_LATEST)
Load user and user_group data from the database.
invalidationTokenUrl( $token)
Return a URL the user can use to invalidate their email address.
useNPPatrol()
Check whether to enable new pages patrol features for this user.
static randomPassword()
Return a random password.
static purge( $wikiId, $userId)
getIntOption( $oname, $defaultOverride=0)
Get the user's current setting for a given option, as an integer value.
clearInstanceCache( $reloadFrom=false)
Clear various cached data stored in this object.
canReceiveEmail()
Is this user allowed to receive e-mails within limits of current site configuration?
loadDefaults( $name=false)
Set cached properties to default.
getOption( $oname, $defaultOverride=null, $ignoreHidden=false)
Get the user's current setting for a given option.
touch()
Update the "touched" timestamp for the user.
checkTemporaryPassword( $plaintext)
Check if the given clear-text password matches the temporary password sent by e-mail for password res...
isPingLimitable()
Is this user subject to rate limiting?
clearSharedCache( $mode='changed')
Clear user data from memcached.
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
static newFromRow( $row, $data=null)
Create a new user object from a user row.
getToken( $forceCreation=true)
Get the user's current token.
static newFromId( $id)
Static factory method for creation from a given user ID.
setInternalPassword( $str)
Set the password and reset the random token unconditionally.
confirmEmail()
Mark the e-mail address confirmed.
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
setId( $v)
Set the user and reload all fields according to a given ID.
static getGroupPermissions( $groups)
Get the permissions associated with a given list of groups.
$mNewtalk
Lazy-initialized variables, invalidated with clearInstanceCache.
static getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...
static findUsersByGroup( $groups, $limit=5000, $after=null)
Return the users who are members of the given group(s).
getEffectiveGroups( $recache=false)
Get the list of implicit group memberships this user has.
static selectFields()
Return the list of user fields that should be selected to create a new user object.
isHidden()
Check if user account is hidden.
static newFromConfirmationCode( $code, $flags=0)
Factory method to fetch whichever user has a given email confirmation code.
setEmailWithConfirmation( $str)
Set the user's e-mail address and a confirmation mail if needed.
newTouchedTimestamp()
Generate a current or new-future timestamp to be stored in the user_touched field when we update thin...
inDnsBlacklist( $ip, $bases)
Whether the given IP is in a given DNS blacklist.
loadFromUserObject( $user)
Load the data for this user object from another user object.
static isUsableName( $name)
Usernames which fail to pass this function will be blocked from user login and new account registrati...
static getDefaultOption( $opt)
Get a given default option value.
getDatePreference()
Get the user's preferred date format.
checkPasswordValidity( $password)
Check if this is a valid password for this user.
static getGroupPage( $group)
Get the title of a page describing a particular group.
idForName( $flags=0)
If only this user's username is known, and it exists, return the user ID.
getGroupMemberships()
Get the list of explicit group memberships this user has, stored as UserGroupMembership objects.
matchEditTokenNoSuffix( $val, $salt='', $request=null, $maxage=null)
Check given value against the token value stored in the session, ignoring the suffix.
isWatched( $title, $checkRights=self::CHECK_USER_RIGHTS)
Check the watched status of an article.
loadFromRow( $row, $data=null)
Initialize this object from a row from the user table.
setPassword( $str)
Set the password and reset the random token.
confirmationTokenUrl( $token)
Return a URL the user can use to confirm their email address.
isAllowedToCreateAccount()
Get whether the user is allowed to create an account.
static newFromSession(WebRequest $request=null)
Create a new user object using data from session.
incEditCountImmediate()
Increment the user's edit-count field.
static getAllRights()
Get a list of all available permissions.
getNewtalk()
Check if the user has new messages.
getGroups()
Get the list of explicit group memberships this user has.
addNewUserLogEntry( $action=false, $reason='')
Add a newuser log entry for this user.
validateCache( $timestamp)
Validate the cache for this account.
useRCPatrol()
Check whether to enable recent changes patrol features for this user.
loadGroups()
Load the groups from the database if they aren't already loaded.
static whoIs( $id)
Get the username corresponding to a given user ID.
invalidateEmail()
Invalidate the user's e-mail confirmation, and unauthenticate the e-mail address if it was already co...
setEmailAuthenticationTimestamp( $timestamp)
Set the e-mail authentication timestamp.
static newSystemUser( $name, $options=[])
Static factory method for creation of a "system" user from username.
setOption( $oname, $val)
Set the given option for a user.
saveOptions()
Saves the non-default options for this user, as previously set e.g.
static getRightDescription( $right)
Get the description of a given right.
getEditCount()
Get the user's edit count.
getActorId(IDatabase $dbw=null)
Get the user's actor ID.
UserGroupMembership[] $mGroupMemberships
Associative array of (group name => UserGroupMembership object)
addAutopromoteOnceGroups( $event)
Add the user to the group if he/she meets given criteria.
isValidPassword( $password)
Is the input a valid password for this user?
getBlock( $bFromSlave=true)
Get the block affecting the user, or null if the user is not blocked.
isBlockedFromCreateAccount()
Get whether the user is explicitly blocked from account creation.
spreadBlock()
If this (non-anonymous) user is blocked, block the IP address they've successfully logged in from.
getFormerGroups()
Returns the groups the user has belonged to.
setRealName( $str)
Set the user's real name.
getTitleKey()
Get the user's name escaped by underscores.
static isIP( $name)
Does the string match an anonymous IP address?
static makeGroupLinkWiki( $group, $text='')
Create a link to the group in Wikitext, if available; else return the group name.
getTouched()
Get the user touched timestamp.
sendMail( $subject, $body, $from=null, $replyto=null)
Send an e-mail to this user's account.
isLocked()
Check if user account is locked.
checkAndSetTouched()
Bump user_touched if it didn't change since this object was loaded.
removeWatch( $title, $checkRights=self::CHECK_USER_RIGHTS)
Stop watching an article.
setPasswordInternal( $str)
Actually set the password and such.
isEmailConfirmationPending()
Check whether there is an outstanding request for e-mail confirmation.
checkNewtalk( $field, $id)
Internal uncached check for new messages.
isBlockedFrom( $title, $bFromSlave=false)
Check if user is blocked from editing a particular article.
getUserPage()
Get this user's personal page title.
isIPRange()
Is the user an IP range?
$mFrom
String Initialization data source if mLoadedItems!==true.
confirmationToken(&$expiration)
Generate, store, and return a new e-mail confirmation code.
canSendEmail()
Is this user allowed to send e-mails within limits of current site configuration?
getBlockId()
If user is blocked, return the ID for the block.
__construct()
Lightweight constructor for an anonymous user.
setNewtalk( $val, $curRev=null)
Update the 'You have new messages!' status.
getStubThreshold()
Get the user preferred stub threshold.
pingLimiter( $action='edit', $incrBy=1)
Primitive rate limits: enforce maximum actions per time period to put a brake on flooding.
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...
getTalkPage()
Get this user's talk page title.
isLoggedIn()
Get whether the user is registered.
static idFromName( $name, $flags=self::READ_NORMAL)
Get database id given a user name.
loadFromCache()
Load user data from shared cache, given mId has already been set.
getCacheKey(WANObjectCache $cache)
initEditCount( $add=0)
Initialize user_editcount from data out of the revision table.
saveSettings()
Save this user's settings into the database.
getNewMessageRevisionId()
Get the revision ID for the last talk page revision viewed by the talk page owner.
getBlockFromCookieValue( $blockCookieVal)
Try to load a Block from an ID given in a cookie value.
static getGrantName( $grant)
Get the name of a given grant.
isAllowedAny()
Check if user is allowed to access a feature / make an action.
getEmail()
Get the user's e-mail address.
static newFatalPermissionDeniedStatus( $permission)
Factory function for fatal permission-denied errors.
setNewpassword( $str, $throttle=true)
Set the password for a password reminder or new account email.
getAutomaticGroups( $recache=false)
Get the list of implicit group memberships this user has.
load( $flags=self::READ_NORMAL)
Load the user table data for this object from the source given by mFrom.
blockedBy()
If user is blocked, return the name of the user who placed the block.
getRights()
Get the permissions this user has.
matchEditToken( $val, $salt='', $request=null, $maxage=null)
Check given value against the token value stored in the session.
string $mEmailAuthenticated
const GETOPTIONS_EXCLUDE_DEFAULTS
Exclude user options that are set to their default value.
const TOKEN_LENGTH
@const int Number of characters in user_token field.
equals(User $user)
Checks if two user objects point to the same user.
setToken( $token=false)
Set the random token (used for persistent authentication) Called from loadDefaults() among other plac...
updateNewtalk( $field, $id, $curRev=null)
Add or update the new messages flag.
static createNew( $name, $params=[])
Add a user to the database, return the user object.
static getGroupMember( $group, $username='#')
Get the localized descriptive name for a member of a group, if it exists.
addNewUserLogEntryAutoCreate()
Add an autocreate newuser log entry for this user Used by things like CentralAuth and perhaps other a...
doLogout()
Clear the user's session, and reset the instance cache.
setItemLoaded( $item)
Set that an item has been loaded.
incEditCount()
Deferred version of incEditCountImmediate()
$mLoadedItems
Array with already loaded items or true if all items have been loaded.
blockedFor()
If user is blocked, return the specified reason for the block.
static getGroupName( $group)
Get the localized descriptive name for a group, if it exists.
static listOptionKinds()
Return a list of the types of user options currently returned by User::getOptionKinds().
resetTokenFromOption( $oname)
Reset a token stored in the preferences (like the watchlist one).
static makeGroupLinkHTML( $group, $text='')
Create a link to the group in HTML, if available; else return the group name.
static getImplicitGroups()
Get a list of implicit groups.
changeableGroups()
Returns an array of groups that this user can add and remove.
getNewMessageLinks()
Return the data needed to construct links for new talk page message alerts.
isAnon()
Get whether the user is anonymous.
setEmail( $str)
Set the user's e-mail address.
checkPassword( $password)
Check to see if the given clear-text password is one of the accepted passwords.
getInstanceForUpdate()
Get a new instance of this user that was loaded from the master via a locking read.
makeUpdateConditions(Database $db, array $conditions)
Builds update conditions.
const EDIT_TOKEN_SUFFIX
Global constant made accessible as class constants so that autoloader magic can be used.
static newFromActorId( $id)
Static factory method for creation from a given actor ID.
clearAllNotifications()
Resets all of the given user's page-change notification timestamps.
removeGroup( $group)
Remove the user from the given group.
Multi-datacenter aware caching interface.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
The ContentHandler facility adds support for arbitrary content types on wiki pages
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
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
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 local content language as $wgContLang
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
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
this hook is for auditing only $req
the array() calling protocol came about after MediaWiki 1.4rc1.
namespace being checked & $result
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
see documentation in includes Linker php for Linker::makeImageLink & $time
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy: boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
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
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
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 "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
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
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
this hook is for auditing only or null if authentication failed before getting that far $username
Allows to change the fields on the form that will be generated $name
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
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
processing should stop and the error should be shown to the user * false
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 local account $user
Interface for objects which can provide a MediaWiki context on request.
Interface for database access objects.
const READ_LOCKING
Constants for object loading bitfield flags (higher => higher QoS)
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy load