MediaWiki  master
UserTest.php
Go to the documentation of this file.
1 <?php
2 
3 define( 'NS_UNITTEST', 5600 );
4 define( 'NS_UNITTEST_TALK', 5601 );
5 
9 class UserTest extends MediaWikiTestCase {
13  protected $user;
14 
15  protected function setUp() {
16  parent::setUp();
17 
18  $this->setMwGlobals( [
19  'wgGroupPermissions' => [],
20  'wgRevokePermissions' => [],
21  ] );
22 
23  $this->setUpPermissionGlobals();
24 
25  $this->user = new User;
26  $this->user->addGroup( 'unittesters' );
27  }
28 
29  private function setUpPermissionGlobals() {
31 
32  # Data for regular $wgGroupPermissions test
33  $wgGroupPermissions['unittesters'] = [
34  'test' => true,
35  'runtest' => true,
36  'writetest' => false,
37  'nukeworld' => false,
38  ];
39  $wgGroupPermissions['testwriters'] = [
40  'test' => true,
41  'writetest' => true,
42  'modifytest' => true,
43  ];
44 
45  # Data for regular $wgRevokePermissions test
46  $wgRevokePermissions['formertesters'] = [
47  'runtest' => true,
48  ];
49 
50  # For the options test
51  $wgGroupPermissions['*'] = [
52  'editmyoptions' => true,
53  ];
54  }
55 
59  public function testGroupPermissions() {
60  $rights = User::getGroupPermissions( [ 'unittesters' ] );
61  $this->assertContains( 'runtest', $rights );
62  $this->assertNotContains( 'writetest', $rights );
63  $this->assertNotContains( 'modifytest', $rights );
64  $this->assertNotContains( 'nukeworld', $rights );
65 
66  $rights = User::getGroupPermissions( [ 'unittesters', 'testwriters' ] );
67  $this->assertContains( 'runtest', $rights );
68  $this->assertContains( 'writetest', $rights );
69  $this->assertContains( 'modifytest', $rights );
70  $this->assertNotContains( 'nukeworld', $rights );
71  }
72 
76  public function testRevokePermissions() {
77  $rights = User::getGroupPermissions( [ 'unittesters', 'formertesters' ] );
78  $this->assertNotContains( 'runtest', $rights );
79  $this->assertNotContains( 'writetest', $rights );
80  $this->assertNotContains( 'modifytest', $rights );
81  $this->assertNotContains( 'nukeworld', $rights );
82  }
83 
87  public function testUserPermissions() {
88  $rights = $this->user->getRights();
89  $this->assertContains( 'runtest', $rights );
90  $this->assertNotContains( 'writetest', $rights );
91  $this->assertNotContains( 'modifytest', $rights );
92  $this->assertNotContains( 'nukeworld', $rights );
93  }
94 
99  public function testGetGroupsWithPermission( $expected, $right ) {
101  sort( $result );
102  sort( $expected );
103 
104  $this->assertEquals( $expected, $result, "Groups with permission $right" );
105  }
106 
107  public static function provideGetGroupsWithPermission() {
108  return [
109  [
110  [ 'unittesters', 'testwriters' ],
111  'test'
112  ],
113  [
114  [ 'unittesters' ],
115  'runtest'
116  ],
117  [
118  [ 'testwriters' ],
119  'writetest'
120  ],
121  [
122  [ 'testwriters' ],
123  'modifytest'
124  ],
125  ];
126  }
127 
132  public function testIsIP( $value, $result, $message ) {
133  $this->assertEquals( $this->user->isIP( $value ), $result, $message );
134  }
135 
136  public static function provideIPs() {
137  return [
138  [ '', false, 'Empty string' ],
139  [ ' ', false, 'Blank space' ],
140  [ '10.0.0.0', true, 'IPv4 private 10/8' ],
141  [ '10.255.255.255', true, 'IPv4 private 10/8' ],
142  [ '192.168.1.1', true, 'IPv4 private 192.168/16' ],
143  [ '203.0.113.0', true, 'IPv4 example' ],
144  [ '2002:ffff:ffff:ffff:ffff:ffff:ffff:ffff', true, 'IPv6 example' ],
145  // Not valid IPs but classified as such by MediaWiki for negated asserting
146  // of whether this might be the identifier of a logged-out user or whether
147  // to allow usernames like it.
148  [ '300.300.300.300', true, 'Looks too much like an IPv4 address' ],
149  [ '203.0.113.xxx', true, 'Assigned by UseMod to cloaked logged-out users' ],
150  ];
151  }
152 
157  public function testIsValidUserName( $username, $result, $message ) {
158  $this->assertEquals( $this->user->isValidUserName( $username ), $result, $message );
159  }
160 
161  public static function provideUserNames() {
162  return [
163  [ '', false, 'Empty string' ],
164  [ ' ', false, 'Blank space' ],
165  [ 'abcd', false, 'Starts with small letter' ],
166  [ 'Ab/cd', false, 'Contains slash' ],
167  [ 'Ab cd', true, 'Whitespace' ],
168  [ '192.168.1.1', false, 'IP' ],
169  [ 'User:Abcd', false, 'Reserved Namespace' ],
170  [ '12abcd232', true, 'Starts with Numbers' ],
171  [ '?abcd', true, 'Start with ? mark' ],
172  [ '#abcd', false, 'Start with #' ],
173  [ 'Abcdകഖഗഘ', true, ' Mixed scripts' ],
174  [ 'ജോസ്‌തോമസ്', false, 'ZWNJ- Format control character' ],
175  [ 'Ab cd', false, ' Ideographic space' ],
176  [ '300.300.300.300', false, 'Looks too much like an IPv4 address' ],
177  [ '302.113.311.900', false, 'Looks too much like an IPv4 address' ],
178  [ '203.0.113.xxx', false, 'Reserved for usage by UseMod for cloaked logged-out users' ],
179  ];
180  }
181 
187  public function testAllRightsWithMessage() {
188  // Getting all user rights, for core: User::$mCoreRights, for extensions: $wgAvailableRights
189  $allRights = User::getAllRights();
190  $allMessageKeys = Language::getMessageKeysFor( 'en' );
191 
192  $rightsWithMessage = [];
193  foreach ( $allMessageKeys as $message ) {
194  // === 0: must be at beginning of string (position 0)
195  if ( strpos( $message, 'right-' ) === 0 ) {
196  $rightsWithMessage[] = substr( $message, strlen( 'right-' ) );
197  }
198  }
199 
200  sort( $allRights );
201  sort( $rightsWithMessage );
202 
203  $this->assertEquals(
204  $allRights,
205  $rightsWithMessage,
206  'Each user rights (core/extensions) has a corresponding right- message.'
207  );
208  }
209 
215  public function testEditCount() {
216  $user = $this->getMutableTestUser()->getUser();
217 
218  // let the user have a few (3) edits
219  $page = WikiPage::factory( Title::newFromText( 'Help:UserTest_EditCount' ) );
220  for ( $i = 0; $i < 3; $i++ ) {
221  $page->doEdit( (string)$i, 'test', 0, false, $user );
222  }
223 
225  $this->assertEquals(
226  3,
227  $user->getEditCount(),
228  'After three edits, the user edit count should be 3'
229  );
230 
231  // increase the edit count and clear the cache
232  $user->incEditCount();
233 
235  $this->assertEquals(
236  4,
237  $user->getEditCount(),
238  'After increasing the edit count manually, the user edit count should be 4'
239  );
240  }
241 
247  public function testOptions() {
248  $user = $this->getMutableTestUser()->getUser();
249 
250  $user->setOption( 'userjs-someoption', 'test' );
251  $user->setOption( 'cols', 200 );
252  $user->saveSettings();
253 
255  $this->assertEquals( 'test', $user->getOption( 'userjs-someoption' ) );
256  $this->assertEquals( 200, $user->getOption( 'cols' ) );
257  }
258 
264  public function testAnonOptions() {
266  $this->user->setOption( 'userjs-someoption', 'test' );
267  $this->assertEquals( $wgDefaultUserOptions['cols'], $this->user->getOption( 'cols' ) );
268  $this->assertEquals( 'test', $this->user->getOption( 'userjs-someoption' ) );
269  }
270 
280  public function testCheckPasswordValidity() {
281  $this->setMwGlobals( [
282  'wgPasswordPolicy' => [
283  'policies' => [
284  'sysop' => [
285  'MinimalPasswordLength' => 8,
286  'MinimumPasswordLengthToLogin' => 1,
287  'PasswordCannotMatchUsername' => 1,
288  ],
289  'default' => [
290  'MinimalPasswordLength' => 6,
291  'PasswordCannotMatchUsername' => true,
292  'PasswordCannotMatchBlacklist' => true,
293  'MaximalPasswordLength' => 40,
294  ],
295  ],
296  'checks' => [
297  'MinimalPasswordLength' => 'PasswordPolicyChecks::checkMinimalPasswordLength',
298  'MinimumPasswordLengthToLogin' => 'PasswordPolicyChecks::checkMinimumPasswordLengthToLogin',
299  'PasswordCannotMatchUsername' => 'PasswordPolicyChecks::checkPasswordCannotMatchUsername',
300  'PasswordCannotMatchBlacklist' => 'PasswordPolicyChecks::checkPasswordCannotMatchBlacklist',
301  'MaximalPasswordLength' => 'PasswordPolicyChecks::checkMaximalPasswordLength',
302  ],
303  ],
304  ] );
305 
306  $user = static::getTestUser()->getUser();
307 
308  // Sanity
309  $this->assertTrue( $user->isValidPassword( 'Password1234' ) );
310 
311  // Minimum length
312  $this->assertFalse( $user->isValidPassword( 'a' ) );
313  $this->assertFalse( $user->checkPasswordValidity( 'a' )->isGood() );
314  $this->assertTrue( $user->checkPasswordValidity( 'a' )->isOK() );
315  $this->assertEquals( 'passwordtooshort', $user->getPasswordValidity( 'a' ) );
316 
317  // Maximum length
318  $longPass = str_repeat( 'a', 41 );
319  $this->assertFalse( $user->isValidPassword( $longPass ) );
320  $this->assertFalse( $user->checkPasswordValidity( $longPass )->isGood() );
321  $this->assertFalse( $user->checkPasswordValidity( $longPass )->isOK() );
322  $this->assertEquals( 'passwordtoolong', $user->getPasswordValidity( $longPass ) );
323 
324  // Matches username
325  $this->assertFalse( $user->checkPasswordValidity( $user->getName() )->isGood() );
326  $this->assertTrue( $user->checkPasswordValidity( $user->getName() )->isOK() );
327  $this->assertEquals( 'password-name-match', $user->getPasswordValidity( $user->getName() ) );
328 
329  // On the forbidden list
330  $user = User::newFromName( 'Useruser' );
331  $this->assertFalse( $user->checkPasswordValidity( 'Passpass' )->isGood() );
332  $this->assertEquals( 'password-login-forbidden', $user->getPasswordValidity( 'Passpass' ) );
333  }
334 
339  public function testGetCanonicalName( $name, $expectedArray ) {
340  // fake interwiki map for the 'Interwiki prefix' testcase
341  $this->mergeMwGlobalArrayValue( 'wgHooks', [
342  'InterwikiLoadPrefix' => [
343  function ( $prefix, &$iwdata ) {
344  if ( $prefix === 'interwiki' ) {
345  $iwdata = [
346  'iw_url' => 'http://example.com/',
347  'iw_local' => 0,
348  'iw_trans' => 0,
349  ];
350  return false;
351  }
352  },
353  ],
354  ] );
355 
356  foreach ( $expectedArray as $validate => $expected ) {
357  $this->assertEquals(
358  $expected,
359  User::getCanonicalName( $name, $validate === 'false' ? false : $validate ), $validate );
360  }
361  }
362 
363  public static function provideGetCanonicalName() {
364  return [
365  'Leading space' => [ ' Leading space', [ 'creatable' => 'Leading space' ] ],
366  'Trailing space ' => [ 'Trailing space ', [ 'creatable' => 'Trailing space' ] ],
367  'Namespace prefix' => [ 'Talk:Username', [ 'creatable' => false, 'usable' => false,
368  'valid' => false, 'false' => 'Talk:Username' ] ],
369  'Interwiki prefix' => [ 'interwiki:Username', [ 'creatable' => false, 'usable' => false,
370  'valid' => false, 'false' => 'Interwiki:Username' ] ],
371  'With hash' => [ 'name with # hash', [ 'creatable' => false, 'usable' => false ] ],
372  'Multi spaces' => [ 'Multi spaces', [ 'creatable' => 'Multi spaces',
373  'usable' => 'Multi spaces' ] ],
374  'Lowercase' => [ 'lowercase', [ 'creatable' => 'Lowercase' ] ],
375  'Invalid character' => [ 'in[]valid', [ 'creatable' => false, 'usable' => false,
376  'valid' => false, 'false' => 'In[]valid' ] ],
377  'With slash' => [ 'with / slash', [ 'creatable' => false, 'usable' => false, 'valid' => false,
378  'false' => 'With / slash' ] ],
379  ];
380  }
381 
385  public function testEquals() {
386  $first = $this->getMutableTestUser()->getUser();
387  $second = User::newFromName( $first->getName() );
388 
389  $this->assertTrue( $first->equals( $first ) );
390  $this->assertTrue( $first->equals( $second ) );
391  $this->assertTrue( $second->equals( $first ) );
392 
393  $third = $this->getMutableTestUser()->getUser();
394  $fourth = $this->getMutableTestUser()->getUser();
395 
396  $this->assertFalse( $third->equals( $fourth ) );
397  $this->assertFalse( $fourth->equals( $third ) );
398 
399  // Test users loaded from db with id
400  $user = $this->getMutableTestUser()->getUser();
401  $fifth = User::newFromId( $user->getId() );
402  $sixth = User::newFromName( $user->getName() );
403  $this->assertTrue( $fifth->equals( $sixth ) );
404  }
405 
409  public function testGetId() {
410  $user = static::getTestUser()->getUser();
411  $this->assertTrue( $user->getId() > 0 );
412 
413  }
414 
419  public function testLoggedIn() {
420  $user = $this->getMutableTestUser()->getUser();
421  $this->assertTrue( $user->isLoggedIn() );
422  $this->assertFalse( $user->isAnon() );
423 
424  // Non-existent users are perceived as anonymous
425  $user = User::newFromName( 'UTNonexistent' );
426  $this->assertFalse( $user->isLoggedIn() );
427  $this->assertTrue( $user->isAnon() );
428 
429  $user = new User;
430  $this->assertFalse( $user->isLoggedIn() );
431  $this->assertTrue( $user->isAnon() );
432  }
433 
437  public function testCheckAndSetTouched() {
438  $user = $this->getMutableTestUser()->getUser();
440  $this->assertTrue( $user->isLoggedIn() );
441 
442  $touched = $user->getDBTouched();
443  $this->assertTrue(
444  $user->checkAndSetTouched(), "checkAndSetTouched() succeded" );
445  $this->assertGreaterThan(
446  $touched, $user->getDBTouched(), "user_touched increased with casOnTouched()" );
447 
448  $touched = $user->getDBTouched();
449  $this->assertTrue(
450  $user->checkAndSetTouched(), "checkAndSetTouched() succeded #2" );
451  $this->assertGreaterThan(
452  $touched, $user->getDBTouched(), "user_touched increased with casOnTouched() #2" );
453  }
454 
458  public function testFindUsersByGroup() {
460  $this->assertEquals( 0, iterator_count( $users ) );
461 
462  $users = User::findUsersByGroup( 'foo' );
463  $this->assertEquals( 0, iterator_count( $users ) );
464 
465  $user = $this->getMutableTestUser( [ 'foo' ] )->getUser();
466  $users = User::findUsersByGroup( 'foo' );
467  $this->assertEquals( 1, iterator_count( $users ) );
468  $users->rewind();
469  $this->assertTrue( $user->equals( $users->current() ) );
470 
471  // arguments have OR relationship
472  $user2 = $this->getMutableTestUser( [ 'bar' ] )->getUser();
473  $users = User::findUsersByGroup( [ 'foo', 'bar' ] );
474  $this->assertEquals( 2, iterator_count( $users ) );
475  $users->rewind();
476  $this->assertTrue( $user->equals( $users->current() ) );
477  $users->next();
478  $this->assertTrue( $user2->equals( $users->current() ) );
479 
480  // users are not duplicated
481  $user = $this->getMutableTestUser( [ 'baz', 'boom' ] )->getUser();
482  $users = User::findUsersByGroup( [ 'baz', 'boom' ] );
483  $this->assertEquals( 1, iterator_count( $users ) );
484  $users->rewind();
485  $this->assertTrue( $user->equals( $users->current() ) );
486  }
487 }
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
Definition: User.php:522
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:101
mergeMwGlobalArrayValue($name, $values)
Merges the given values into a MW global array variable.
testIsIP($value, $result, $message)
provideIPs User::isIP
Definition: UserTest.php:132
testGetGroupsWithPermission($expected, $right)
provideGetGroupsWithPermission User::getGroupsWithPermission
Definition: UserTest.php:99
testLoggedIn()
User::isLoggedIn User::isAnon.
Definition: UserTest.php:419
testGetId()
User::getId.
Definition: UserTest.php:409
User $user
Definition: UserTest.php:13
clearInstanceCache($reloadFrom=false)
Clear various cached data stored in this object.
Definition: User.php:1536
$wgDefaultUserOptions
Settings added to this array will override the default globals for the user preferences used by anony...
testRevokePermissions()
User::getGroupPermissions.
Definition: UserTest.php:76
isValidPassword($password)
Is the input a valid password for this user?
Definition: User.php:994
saveSettings()
Save this user's settings into the database.
Definition: User.php:3942
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
static getCanonicalName($name, $validate= 'valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid...
Definition: User.php:1082
testIsValidUserName($username, $result, $message)
provideUserNames User::isValidUserName
Definition: UserTest.php:157
testUserPermissions()
User::getRights.
Definition: UserTest.php:87
testCheckPasswordValidity()
Test password validity checks.
Definition: UserTest.php:280
checkPasswordValidity($password, $purpose= 'login')
Check if this is a valid password for this user.
Definition: User.php:1042
static findUsersByGroup($groups, $limit=5000, $after=null)
Return the users who are members of the given group(s).
Definition: User.php:924
$value
checkAndSetTouched()
Bump user_touched if it didn't change since this object was loaded.
Definition: User.php:1498
static newFromId($id)
Static factory method for creation from a given user ID.
Definition: User.php:545
testGetCanonicalName($name, $expectedArray)
User::getCanonicalName() provideGetCanonicalName.
Definition: UserTest.php:339
isLoggedIn()
Get whether the user is logged in.
Definition: User.php:3513
static getMessageKeysFor($code)
Get all message keys for a given language.
Definition: Language.php:4389
getDBTouched()
Get the user_touched timestamp field (time of last DB updates)
Definition: User.php:2472
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:256
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
$wgRevokePermissions
Permission keys revoked from users in each group.
setOption($oname, $val)
Set the given option for a user.
Definition: User.php:3002
getName()
Get the user name, or the IP of an anonymous user.
Definition: User.php:2139
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:Associative array mapping language codes to prefixed links of the form"language:title".&$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
Definition: hooks.txt:1814
$wgGroupPermissions
Permission keys given to users in each group.
testEditCount()
Test User::editCount medium User::getEditCount.
Definition: UserTest.php:215
static getAllRights()
Get a list of all available permissions.
Definition: User.php:4926
static provideGetCanonicalName()
Definition: UserTest.php:363
static provideIPs()
Definition: UserTest.php:136
testCheckAndSetTouched()
User::checkAndSetTouched.
Definition: UserTest.php:437
isAnon()
Get whether the user is anonymous.
Definition: User.php:3521
incEditCount()
Deferred version of incEditCountImmediate()
Definition: User.php:5132
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
Wikitext formatted, in the key only.
Definition: distributors.txt:9
testFindUsersByGroup()
User::findUsersByGroup.
Definition: UserTest.php:458
static provideUserNames()
Definition: UserTest.php:161
setUpPermissionGlobals()
Definition: UserTest.php:29
getPasswordValidity($password)
Given unvalidated password input, return error message on failure.
Definition: User.php:1005
testAnonOptions()
Bug 37963 Make sure defaults are loaded when setOption is called.
Definition: UserTest.php:264
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
Definition: distributors.txt:9
testAllRightsWithMessage()
Test, if for all rights a right- message exist, which is used on Special:ListGroupRights as help text...
Definition: UserTest.php:187
getOption($oname, $defaultOverride=null, $ignoreHidden=false)
Get the user's current setting for a given option.
Definition: User.php:2915
static TestUser[] $users
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
Definition: injection.txt:35
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:776
getId()
Get the user's ID.
Definition: User.php:2114
getEditCount()
Get the user's edit count.
Definition: User.php:3403
static getMutableTestUser($groups=[])
Convenience method for getting a mutable test user.
static provideGetGroupsWithPermission()
Definition: UserTest.php:107
equals(User $user)
Checks if two user objects point to the same user.
Definition: User.php:5613
static newFromObject($object)
Return the same object, without access restrictions.
setMwGlobals($pairs, $value=null)
static getGroupPermissions($groups)
Get the permissions associated with a given list of groups.
Definition: User.php:4772
testOptions()
Test changing user options.
Definition: UserTest.php:247
testGroupPermissions()
User::getGroupPermissions.
Definition: UserTest.php:59
Database.
Definition: UserTest.php:9
static getGroupsWithPermission($role)
Get all the groups who have a given permission.
Definition: User.php:4799
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2376
testEquals()
User::equals.
Definition: UserTest.php:385
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:310