Go to the documentation of this file.
3 define(
'NS_UNITTEST', 5600 );
4 define(
'NS_UNITTEST_TALK', 5601 );
7 use Wikimedia\TestingAccessWrapper;
22 'wgGroupPermissions' => [],
23 'wgRevokePermissions' => [],
34 # Data for regular $wgGroupPermissions test
35 $wgGroupPermissions[
'unittesters'] = [
47 # Data for regular $wgRevokePermissions test
52 # For the options test
54 'editmyoptions' =>
true,
63 $this->assertContains(
'runtest', $rights );
64 $this->assertNotContains(
'writetest', $rights );
65 $this->assertNotContains(
'modifytest', $rights );
66 $this->assertNotContains(
'nukeworld', $rights );
69 $this->assertContains(
'runtest', $rights );
70 $this->assertContains(
'writetest', $rights );
71 $this->assertContains(
'modifytest', $rights );
72 $this->assertNotContains(
'nukeworld', $rights );
80 $this->assertNotContains(
'runtest', $rights );
81 $this->assertNotContains(
'writetest', $rights );
82 $this->assertNotContains(
'modifytest', $rights );
83 $this->assertNotContains(
'nukeworld', $rights );
90 $rights = $this->
user->getRights();
91 $this->assertContains(
'runtest', $rights );
92 $this->assertNotContains(
'writetest', $rights );
93 $this->assertNotContains(
'modifytest', $rights );
94 $this->assertNotContains(
'nukeworld', $rights );
102 $userWrapper = TestingAccessWrapper::newFromObject(
$user );
105 $this->assertContains(
'test', $rights,
'sanity check' );
106 $this->assertContains(
'runtest', $rights,
'sanity check' );
107 $this->assertContains(
'writetest', $rights,
'sanity check' );
108 $this->assertNotContains(
'nukeworld', $rights,
'sanity check' );
112 $rights[] =
'nukeworld';
113 $rights = array_diff( $rights, [
'writetest' ] );
116 $userWrapper->mRights =
null;
118 $this->assertContains(
'test', $rights );
119 $this->assertContains(
'runtest', $rights );
120 $this->assertNotContains(
'writetest', $rights );
121 $this->assertContains(
'nukeworld', $rights );
125 ->setMethods( [
'getAllowedUserRights',
'deregisterSession',
'getSessionId' ] )
127 $mock->method(
'getAllowedUserRights' )->willReturn( [
'test',
'writetest' ] );
128 $mock->method(
'getSessionId' )->willReturn(
129 new MediaWiki\Session\SessionId( str_repeat(
'X', 32 ) )
133 ->setMethods( [
'getSession' ] )
135 $mockRequest->method(
'getSession' )->willReturn( $session );
136 $userWrapper->mRequest = $mockRequest;
138 $userWrapper->mRights =
null;
140 $this->assertContains(
'test', $rights );
141 $this->assertNotContains(
'runtest', $rights );
142 $this->assertNotContains(
'writetest', $rights );
143 $this->assertNotContains(
'nukeworld', $rights );
155 $this->assertEquals( $expected,
$result,
"Groups with permission $right" );
161 [
'unittesters',
'testwriters' ],
189 [
'',
false,
'Empty string' ],
190 [
' ',
false,
'Blank space' ],
191 [
'10.0.0.0',
true,
'IPv4 private 10/8' ],
192 [
'10.255.255.255',
true,
'IPv4 private 10/8' ],
193 [
'192.168.1.1',
true,
'IPv4 private 192.168/16' ],
194 [
'203.0.113.0',
true,
'IPv4 example' ],
195 [
'2002:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
true,
'IPv6 example' ],
199 [
'300.300.300.300',
true,
'Looks too much like an IPv4 address' ],
200 [
'203.0.113.xxx',
true,
'Assigned by UseMod to cloaked logged-out users' ],
214 [
'',
false,
'Empty string' ],
215 [
' ',
false,
'Blank space' ],
216 [
'abcd',
false,
'Starts with small letter' ],
217 [
'Ab/cd',
false,
'Contains slash' ],
218 [
'Ab cd',
true,
'Whitespace' ],
219 [
'192.168.1.1',
false,
'IP' ],
220 [
'116.17.184.5/32',
false,
'IP range' ],
221 [
'::e:f:2001/96',
false,
'IPv6 range' ],
222 [
'User:Abcd',
false,
'Reserved Namespace' ],
223 [
'12abcd232',
true,
'Starts with Numbers' ],
224 [
'?abcd',
true,
'Start with ? mark' ],
225 [
'#abcd',
false,
'Start with #' ],
226 [
'Abcdകഖഗഘ',
true,
' Mixed scripts' ],
227 [
'ജോസ്തോമസ്',
false,
'ZWNJ- Format control character' ],
228 [
'Ab cd',
false,
' Ideographic space' ],
229 [
'300.300.300.300',
false,
'Looks too much like an IPv4 address' ],
230 [
'302.113.311.900',
false,
'Looks too much like an IPv4 address' ],
231 [
'203.0.113.xxx',
false,
'Reserved for usage by UseMod for cloaked logged-out users' ],
245 $rightsWithMessage = [];
246 foreach ( $allMessageKeys
as $message ) {
248 if ( strpos( $message,
'right-' ) === 0 ) {
249 $rightsWithMessage[] = substr( $message, strlen(
'right-' ) );
254 sort( $rightsWithMessage );
259 'Each user rights (core/extensions) has a corresponding right- message.'
273 for ( $i = 0; $i < 3; $i++ ) {
274 $page->doEditContent(
286 'After three edits, the user edit count should be 3'
295 'After increasing the edit count manually, the user edit count should be 4'
309 'Edit count starts null for anonymous users.'
316 'Edit count remains null for anonymous users despite calls to increase it.'
330 $reloadedUser->incEditCount();
334 $reloadedUser->getEditCount(),
335 'Increasing the edit count after a fresh load leaves the object up to date.'
353 $this->assertEquals(
'test',
$user->
getOption(
'userjs-someoption' ) );
357 MediaWikiServices::getInstance()->getMainWANObjectCache()->clearProcessCache();
358 $this->assertEquals(
'test',
$user->
getOption(
'userjs-someoption' ) );
369 $this->
user->setOption(
'userjs-someoption',
'test' );
371 $this->assertEquals(
'test', $this->
user->getOption(
'userjs-someoption' ) );
385 'wgPasswordPolicy' => [
388 'MinimalPasswordLength' => 8,
389 'MinimumPasswordLengthToLogin' => 1,
390 'PasswordCannotMatchUsername' => 1,
393 'MinimalPasswordLength' => 6,
394 'PasswordCannotMatchUsername' =>
true,
395 'PasswordCannotMatchBlacklist' =>
true,
396 'MaximalPasswordLength' => 40,
400 'MinimalPasswordLength' =>
'PasswordPolicyChecks::checkMinimalPasswordLength',
401 'MinimumPasswordLengthToLogin' =>
'PasswordPolicyChecks::checkMinimumPasswordLengthToLogin',
402 'PasswordCannotMatchUsername' =>
'PasswordPolicyChecks::checkPasswordCannotMatchUsername',
403 'PasswordCannotMatchBlacklist' =>
'PasswordPolicyChecks::checkPasswordCannotMatchBlacklist',
404 'MaximalPasswordLength' =>
'PasswordPolicyChecks::checkMaximalPasswordLength',
409 $user = static::getTestUser()->getUser();
421 $longPass = str_repeat(
'a', 41 );
445 'InterwikiLoadPrefix' => [
446 function ( $prefix, &$iwdata ) {
447 if ( $prefix ===
'interwiki' ) {
449 'iw_url' =>
'http://example.com/',
459 foreach ( $expectedArray
as $validate => $expected ) {
468 'Leading space' => [
' Leading space', [
'creatable' =>
'Leading space' ] ],
469 'Trailing space ' => [
'Trailing space ', [
'creatable' =>
'Trailing space' ] ],
470 'Namespace prefix' => [
'Talk:Username', [
'creatable' =>
false,
'usable' =>
false,
471 'valid' =>
false,
'false' =>
'Talk:Username' ] ],
472 'Interwiki prefix' => [
'interwiki:Username', [
'creatable' =>
false,
'usable' =>
false,
473 'valid' =>
false,
'false' =>
'Interwiki:Username' ] ],
474 'With hash' => [
'name with # hash', [
'creatable' =>
false,
'usable' =>
false ] ],
475 'Multi spaces' => [
'Multi spaces', [
'creatable' =>
'Multi spaces',
476 'usable' =>
'Multi spaces' ] ],
477 'Lowercase' => [
'lowercase', [
'creatable' =>
'Lowercase' ] ],
478 'Invalid character' => [
'in[]valid', [
'creatable' =>
false,
'usable' =>
false,
479 'valid' =>
false,
'false' =>
'In[]valid' ] ],
480 'With slash' => [
'with / slash', [
'creatable' =>
false,
'usable' =>
false,
'valid' =>
false,
481 'false' =>
'With / slash' ] ],
492 $this->assertTrue( $first->equals( $first ) );
493 $this->assertTrue( $first->equals( $second ) );
494 $this->assertTrue( $second->equals( $first ) );
499 $this->assertFalse( $third->equals( $fourth ) );
500 $this->assertFalse( $fourth->equals( $third ) );
506 $this->assertTrue( $fifth->equals( $sixth ) );
513 $user = static::getTestUser()->getUser();
541 $user = TestingAccessWrapper::newFromObject(
$user );
547 $this->assertGreaterThan(
553 $this->assertGreaterThan(
554 $touched,
$user->
getDBTouched(),
"user_touched increased with casOnTouched() #2" );
562 $this->assertEquals( 0, iterator_count(
$users ) );
565 $this->assertEquals( 0, iterator_count(
$users ) );
569 $this->assertEquals( 1, iterator_count(
$users ) );
576 $this->assertEquals( 2, iterator_count(
$users ) );
580 $this->assertTrue( $user2->equals(
$users->current() ) );
585 $this->assertEquals( 1, iterator_count(
$users ) );
598 'wgCookieSetOnAutoblock' =>
true,
599 'wgCookiePrefix' =>
'wmsitetitle',
606 $request1->getSession()->setUser( $user1tmp );
607 $expiryFiveHours =
wfTimestamp() + ( 5 * 60 * 60 );
608 $block =
new Block( [
609 'enableAutoblock' =>
true,
610 'expiry' =>
wfTimestamp( TS_MW, $expiryFiveHours ),
612 $block->setTarget( $user1tmp );
615 $user1->mBlock = $block;
619 $this->assertTrue( $user1->isLoggedIn() );
620 $this->assertTrue( $user1->isBlocked() );
622 $this->assertTrue( $block->isAutoblocking() );
623 $this->assertGreaterThanOrEqual( 1, $block->getId() );
626 $cookies = $request1->response()->getCookies();
627 $this->assertArrayHasKey(
'wmsitetitleBlockID', $cookies );
628 $this->assertEquals( $expiryFiveHours, $cookies[
'wmsitetitleBlockID'][
'expire'] );
630 $this->assertEquals( $block->getId(), $cookieValue );
634 $request2->setCookie(
'BlockID', $block->getCookieValue() );
637 $this->assertNotEquals( $user1->getId(), $user2->getId() );
638 $this->assertNotEquals( $user1->getToken(), $user2->getToken() );
639 $this->assertTrue( $user2->isAnon() );
640 $this->assertFalse( $user2->isLoggedIn() );
641 $this->assertTrue( $user2->isBlocked() );
642 $this->assertEquals(
true, $user2->getBlock()->isAutoblocking() );
645 $this->assertEquals( $block->getId(), $user2->getBlock()->getId() );
646 $this->assertEquals( $block->getExpiry(), $user2->getBlock()->getExpiry() );
651 $request3->getSession()->setUser( $user3tmp );
652 $request3->setCookie(
'BlockID', $block->getId() );
655 $this->assertTrue( $user3->isLoggedIn() );
656 $this->assertTrue( $user3->isBlocked() );
657 $this->assertEquals(
true, $user3->getBlock()->isAutoblocking() );
670 'wgCookieSetOnAutoblock' =>
false,
671 'wgCookiePrefix' =>
'wm_no_cookies',
678 $request1->getSession()->setUser( $testUser );
679 $block =
new Block( [
'enableAutoblock' =>
true ] );
680 $block->setTarget( $testUser );
683 $user->mBlock = $block;
690 $this->assertTrue( $block->isAutoblocking() );
692 $this->assertGreaterThanOrEqual( $block->getId(),
$user->
getBlockId() );
693 $cookies = $request1->response()->getCookies();
694 $this->assertArrayNotHasKey(
'wm_no_cookiesBlockID', $cookies );
707 'wgCookieSetOnAutoblock' =>
true,
708 'wgCookiePrefix' =>
'wm_infinite_block',
714 $request1->getSession()->setUser( $user1Tmp );
715 $block =
new Block( [
'enableAutoblock' =>
true,
'expiry' =>
'infinity' ] );
716 $block->setTarget( $user1Tmp );
719 $user1->mBlock = $block;
723 $this->assertTrue( $user1->isLoggedIn() );
724 $this->assertTrue( $user1->isBlocked() );
726 $this->assertTrue( $block->isAutoblocking() );
727 $this->assertGreaterThanOrEqual( 1, $user1->getBlockId() );
728 $cookies = $request1->response()->getCookies();
730 $this->assertArrayHasKey(
'wm_infinite_blockBlockID', $cookies );
735 $cookies[
'wm_infinite_blockBlockID'][
'expire'],
742 $block->mExpiry =
wfTimestamp( TS_MW, $newExpiry );
746 $request2->getSession()->setUser( $user2tmp );
748 $user2->mBlock = $block;
750 $cookies = $request2->response()->getCookies();
751 $this->assertEquals(
wfTimestamp( TS_MW, $newExpiry ), $block->getExpiry() );
752 $this->assertEquals( $newExpiry, $cookies[
'wm_infinite_blockBlockID'][
'expire'] );
762 'wgSoftBlockRanges' => [
'10.0.0.0/8' ],
770 $this->assertNull(
$wgUser->getBlock() );
778 $this->assertSame(
'wgSoftBlockRanges', $block->getSystemBlockType() );
783 $this->assertFalse(
$wgUser->isAnon(),
'sanity check' );
784 $this->assertNull(
$wgUser->getBlock() );
793 'wgCookieSetOnAutoblock' =>
true,
794 'wgCookiePrefix' =>
'wmsitetitle',
801 $request1->getSession()->setUser( $user1tmp );
802 $block =
new Block( [
'enableAutoblock' =>
true ] );
803 $block->setTarget( $user1tmp );
806 $user1->mBlock = $block;
812 $request2->setCookie(
'BlockID', $block->getId() .
'!zzzzzzz' );
815 $this->assertTrue( $user2->isAnon() );
816 $this->assertFalse( $user2->isLoggedIn() );
817 $this->assertFalse( $user2->isBlocked() );
830 'wgCookieSetOnAutoblock' =>
true,
831 'wgCookiePrefix' =>
'wmsitetitle',
832 'wgSecretKey' =>
null,
838 $request1->getSession()->setUser( $user1tmp );
839 $block =
new Block( [
'enableAutoblock' =>
true ] );
840 $block->setTarget( $user1tmp );
843 $user1->mBlock = $block;
845 $this->assertTrue( $user1->isBlocked() );
850 $request2->setCookie(
'BlockID', $block->getId() );
853 $this->assertNotEquals( $user1->getId(), $user2->getId() );
854 $this->assertNotEquals( $user1->getToken(), $user2->getToken() );
855 $this->assertTrue( $user2->isAnon() );
856 $this->assertFalse( $user2->isLoggedIn() );
857 $this->assertTrue( $user2->isBlocked() );
858 $this->assertEquals(
true, $user2->getBlock()->isAutoblocking() );
872 $this->
setMwGlobals(
'wgRateLimitsExcludedIPs', [
'1.2.3.4' ] );
875 $this->
setMwGlobals(
'wgRateLimitsExcludedIPs', [
'1.2.3.0/8' ] );
879 $noRateLimitUser = $this->getMockBuilder(
User::class )->disableOriginalConstructor()
880 ->setMethods( [
'getIP',
'getRights' ] )->getMock();
881 $noRateLimitUser->expects( $this->
any() )->method(
'getIP' )->willReturn(
'1.2.3.4' );
882 $noRateLimitUser->expects( $this->
any() )->method(
'getRights' )->willReturn( [
'noratelimit' ] );
883 $this->assertFalse( $noRateLimitUser->isPingLimitable() );
888 [ 2, 2,
'newcomer' ],
889 [ 12, 3,
'newcomer' ],
890 [ 8, 5,
'newcomer' ],
891 [ 15, 10,
'learner' ],
892 [ 450, 20,
'learner' ],
893 [ 460, 33,
'learner' ],
894 [ 525, 28,
'learner' ],
895 [ 538, 33,
'experienced' ],
904 'wgLearnerEdits' => 10,
905 'wgLearnerMemberSince' => 4,
906 'wgExperiencedUserEdits' => 500,
907 'wgExperiencedUserMemberSince' => 30,
912 $data =
new stdClass();
914 $data->user_name =
'name';
915 $data->user_real_name =
'Real Name';
916 $data->user_touched = 1;
917 $data->user_token =
'token';
918 $data->user_email =
'a@a.a';
919 $data->user_email_authenticated =
null;
920 $data->user_email_token =
'token';
921 $data->user_email_token_expires =
null;
922 $data->user_editcount = $editCount;
923 $data->user_registration =
$db->timestamp( time() - $memberSince * 86400 );
937 [
'1.2.3.4',
'1.2.3.4' ],
938 [
'1.2.3.4',
'1.2.3.0/16' ],
963 'test' => $blockListEntry
969 'IP addresses in the keys of $wgProxyList (found the following IP ' .
970 'addresses in keys: ' . $blockListEntry .
', please move them to values)'
975 $blockListEntry =>
'test'
load( $flags=self::READ_NORMAL)
Load the user table data for this object from the source given by mFrom.
testGetCanonicalName( $name, $expectedArray)
User::getCanonicalName() provideGetCanonicalName.
static provideGetGroupsWithPermission()
WebRequest clone which takes values from a provided array.
static newFromId( $id)
Static factory method for creation from a given user ID.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
processing should stop and the error should be shown to the user * false
isValidPassword( $password)
Is the input a valid password for this user?
getId()
Get the user's ID.
testCheckAndSetTouched()
User::checkAndSetTouched.
isAnon()
Get whether the user is anonymous.
testIsIP( $value, $result, $message)
provideIPs User::isIP
static isLocallyBlockedProxy( $ip)
Check if an IP address is in the local proxy list.
$wgRevokePermissions
Permission keys revoked from users in each group.
getEditCount()
Get the user's edit count.
incEditCount()
Deferred version of incEditCountImmediate()
static newFromSession(WebRequest $request=null)
Create a new user object using data from session.
testFindUsersByGroup()
User::findUsersByGroup.
getBlockId()
If user is blocked, return the ID for the block.
testUserGetRightsHooks()
User::getRights.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
$wgDefaultUserOptions
Settings added to this array will override the default globals for the user preferences used by anony...
testLoggedIn()
User::isLoggedIn User::isAnon.
testAllRightsWithMessage()
Test, if for all rights a right- message exist, which is used on Special:ListGroupRights as help text...
testAutoblockCookieInauthentic()
Test that a modified BlockID cookie doesn't actually load the relevant block (T152951).
testOptions()
Test changing user options.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static provideIsLocallBlockedProxy()
static generateHex( $chars, $forceStrong=false)
Generate a run of (ideally) cryptographically random data and return it in hexadecimal string format.
Allows to change the fields on the form that will be generated $name
static newFromRow( $row, $data=null)
Create a new user object from a user row.
testExperienceLevel( $editCount, $memberSince, $expLevel)
provideExperienceLevel
testIsLocallyBlockedProxy( $ip, $blockListEntry)
provideIsLocallBlockedProxy User::isLocallyBlockedProxy
equals(User $user)
Checks if two user objects point to the same user.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
getRights()
Get the permissions this user has.
testGroupPermissions()
User::getGroupPermissions.
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
checkPasswordValidity( $password)
Check if this is a valid password for this user.
testAnonOptions()
T39963 Make sure defaults are loaded when setOption is called.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
testGetEditCountForAnons()
Test User::editCount medium User::getEditCount.
testAutoblockCookieNoSecretKey()
The BlockID cookie is normally verified with a HMAC, but not if wgSecretKey is not set.
testCheckPasswordValidity()
Test password validity checks.
isPingLimitable()
Is this user subject to rate limiting?
when a variable name is used in a it is silently declared as a new masking the global
testUserPermissions()
User::getRights.
saveSettings()
Save this user's settings into the database.
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
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
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
static getIdFromCookieValue( $cookieValue)
Get the stored ID from the 'BlockID' cookie.
getOption( $oname, $defaultOverride=null, $ignoreHidden=false)
Get the user's current setting for a given option.
testAutoblockCookiesDisabled()
Make sure that no cookie is set to track autoblocked users when $wgCookieSetOnAutoblock is false.
static provideGetCanonicalName()
checkAndSetTouched()
Bump user_touched if it didn't change since this object was loaded.
static getGroupPermissions( $groups)
Get the permissions associated with a given list of groups.
testIncEditCount()
Test User::editCount medium User::incEditCount.
testAutoblockCookieInfiniteExpiry()
When a user is autoblocked and a cookie is set to track them, the expiry time of the cookie should ma...
static getAllRights()
Get a list of all available permissions.
getDBTouched()
Get the user_touched timestamp field (time of last DB updates)
testGetGroupsWithPermission( $expected, $right)
provideGetGroupsWithPermission User::getGroupsWithPermission
getExperienceLevel()
Compute experienced level based on edit count and registration date.
isLoggedIn()
Get whether the user is logged in.
$wgGroupPermissions
Permission keys given to users in each group.
static findUsersByGroup( $groups, $limit=5000, $after=null)
Return the users who are members of the given group(s).
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static getMessageKeysFor( $code)
Get all message keys for a given language.
testExperienceLevelAnon()
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
isBlocked( $bFromSlave=true)
Check if user is blocked.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
setOption( $oname, $val)
Set the given option for a user.
this hook is for auditing only or null if authentication failed before getting that far $username
static provideUserNames()
getPasswordValidity( $password)
Given unvalidated password input, return error message on failure.
testRevokePermissions()
User::getGroupPermissions.
getName()
Get the user name, or the IP of an anonymous user.
testGetEditCount()
Test User::editCount medium User::getEditCount.
testEquals()
User::equals.
static getGroupsWithPermission( $role)
Get all the groups who have a given permission.
testIsValidUserName( $username, $result, $message)
provideUserNames User::isValidUserName
testAutoblockCookies()
When a user is autoblocked a cookie is set with which to track them in case they log out and change I...