MediaWiki  1.33.0
BlockRestrictionStoreTest.php
Go to the documentation of this file.
1 <?php
2 
4 
10 
17 
20 
21  public function setUp() {
22  parent::setUp();
23 
24  $this->blockRestrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore();
25  }
26 
27  public function tearDown() {
28  parent::tearDown();
29  $this->resetTables();
30  }
31 
37  public function testLoadMultipleRestrictions() {
38  $this->setMwGlobals( [
39  'wgBlockDisablesLogin' => false,
40  ] );
41  $block = $this->insertBlock();
42 
43  $pageFoo = $this->getExistingTestPage( 'Foo' );
44  $pageBar = $this->getExistingTestPage( 'Bar' );
45 
46  $this->blockRestrictionStore->insert( [
47  new PageRestriction( $block->getId(), $pageFoo->getId() ),
48  new PageRestriction( $block->getId(), $pageBar->getId() ),
49  new NamespaceRestriction( $block->getId(), NS_USER ),
50  ] );
51 
52  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
53 
54  $this->assertCount( 3, $restrictions );
55  }
56 
62  public function testWithNoRestrictions() {
63  $block = $this->insertBlock();
64  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
65  $this->assertEmpty( $restrictions );
66  }
67 
73  public function testWithEmptyParam() {
74  $restrictions = $this->blockRestrictionStore->loadByBlockId( [] );
75  $this->assertEmpty( $restrictions );
76  }
77 
83  public function testIgnoreNotSupportedTypes() {
84  $block = $this->insertBlock();
85 
86  $pageFoo = $this->getExistingTestPage( 'Foo' );
87  $pageBar = $this->getExistingTestPage( 'Bar' );
88 
89  // valid type
90  $this->insertRestriction( $block->getId(), PageRestriction::TYPE_ID, $pageFoo->getId() );
91  $this->insertRestriction( $block->getId(), NamespaceRestriction::TYPE_ID, NS_USER );
92 
93  // invalid type
94  $this->insertRestriction( $block->getId(), 9, $pageBar->getId() );
95  $this->insertRestriction( $block->getId(), 10, NS_FILE );
96 
97  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
98  $this->assertCount( 2, $restrictions );
99  }
100 
107  $block = $this->insertBlock();
108  $title = 'Lady Macbeth';
109  $page = $this->getExistingTestPage( $title );
110 
111  // Test Page Restrictions.
112  $this->blockRestrictionStore->insert( [
113  new PageRestriction( $block->getId(), $page->getId() ),
114  ] );
115 
116  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
117 
118  list( $pageRestriction ) = $restrictions;
119  $this->assertInstanceOf( PageRestriction::class, $pageRestriction );
120  $this->assertEquals( $block->getId(), $pageRestriction->getBlockId() );
121  $this->assertEquals( $page->getId(), $pageRestriction->getValue() );
122  $this->assertEquals( $pageRestriction->getType(), PageRestriction::TYPE );
123  $this->assertEquals( $pageRestriction->getTitle()->getText(), $title );
124  }
125 
132  $block = $this->insertBlock();
133 
134  $this->blockRestrictionStore->insert( [
135  new NamespaceRestriction( $block->getId(), NS_USER ),
136  ] );
137 
138  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
139 
140  list( $namespaceRestriction ) = $restrictions;
141  $this->assertInstanceOf( NamespaceRestriction::class, $namespaceRestriction );
142  $this->assertEquals( $block->getId(), $namespaceRestriction->getBlockId() );
143  $this->assertSame( NS_USER, $namespaceRestriction->getValue() );
144  $this->assertEquals( $namespaceRestriction->getType(), NamespaceRestriction::TYPE );
145  }
146 
150  public function testInsert() {
151  $block = $this->insertBlock();
152 
153  $pageFoo = $this->getExistingTestPage( 'Foo' );
154  $pageBar = $this->getExistingTestPage( 'Bar' );
155 
156  $restrictions = [
157  new \stdClass(),
158  new PageRestriction( $block->getId(), $pageFoo->getId() ),
159  new PageRestriction( $block->getId(), $pageBar->getId() ),
160  new NamespaceRestriction( $block->getId(), NS_USER )
161  ];
162 
163  $result = $this->blockRestrictionStore->insert( $restrictions );
164  $this->assertTrue( $result );
165 
166  $restrictions = [
167  new \stdClass(),
168  ];
169 
170  $result = $this->blockRestrictionStore->insert( $restrictions );
171  $this->assertFalse( $result );
172 
173  $result = $this->blockRestrictionStore->insert( [] );
174  $this->assertFalse( $result );
175  }
176 
180  public function testInsertTypes() {
181  $block = $this->insertBlock();
182 
183  $pageFoo = $this->getExistingTestPage( 'Foo' );
184  $pageBar = $this->getExistingTestPage( 'Bar' );
185 
186  $invalid = $this->createMock( Restriction::class );
187  $invalid->method( 'toRow' )
188  ->willReturn( [
189  'ir_ipb_id' => $block->getId(),
190  'ir_type' => 9,
191  'ir_value' => 42,
192  ] );
193 
194  $restrictions = [
195  new \stdClass(),
196  new PageRestriction( $block->getId(), $pageFoo->getId() ),
197  new PageRestriction( $block->getId(), $pageBar->getId() ),
198  new NamespaceRestriction( $block->getId(), NS_USER ),
199  $invalid,
200  ];
201 
202  $result = $this->blockRestrictionStore->insert( $restrictions );
203  $this->assertTrue( $result );
204 
205  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
206  $this->assertCount( 3, $restrictions );
207  }
208 
214  public function testUpdateInsert() {
215  $block = $this->insertBlock();
216  $pageFoo = $this->getExistingTestPage( 'Foo' );
217  $pageBar = $this->getExistingTestPage( 'Bar' );
218  $this->blockRestrictionStore->insert( [
219  new PageRestriction( $block->getId(), $pageFoo->getId() ),
220  ] );
221 
222  $this->blockRestrictionStore->update( [
223  new \stdClass(),
224  new PageRestriction( $block->getId(), $pageBar->getId() ),
225  new NamespaceRestriction( $block->getId(), NS_USER ),
226  ] );
227 
228  $db = wfGetDb( DB_REPLICA );
229  $result = $db->select(
230  [ 'ipblocks_restrictions' ],
231  [ '*' ],
232  [ 'ir_ipb_id' => $block->getId() ]
233  );
234 
235  $this->assertEquals( 2, $result->numRows() );
236  $row = $result->fetchObject();
237  $this->assertEquals( $block->getId(), $row->ir_ipb_id );
238  $this->assertEquals( $pageBar->getId(), $row->ir_value );
239  }
240 
246  public function testUpdateChange() {
247  $block = $this->insertBlock();
248  $page = $this->getExistingTestPage( 'Foo' );
249 
250  $this->blockRestrictionStore->update( [
251  new PageRestriction( $block->getId(), $page->getId() ),
252  ] );
253 
254  $db = wfGetDb( DB_REPLICA );
255  $result = $db->select(
256  [ 'ipblocks_restrictions' ],
257  [ '*' ],
258  [ 'ir_ipb_id' => $block->getId() ]
259  );
260 
261  $this->assertEquals( 1, $result->numRows() );
262  $row = $result->fetchObject();
263  $this->assertEquals( $block->getId(), $row->ir_ipb_id );
264  $this->assertEquals( $page->getId(), $row->ir_value );
265  }
266 
272  public function testUpdateNoRestrictions() {
273  $block = $this->insertBlock();
274 
275  $this->blockRestrictionStore->update( [] );
276 
277  $db = wfGetDb( DB_REPLICA );
278  $result = $db->select(
279  [ 'ipblocks_restrictions' ],
280  [ '*' ],
281  [ 'ir_ipb_id' => $block->getId() ]
282  );
283 
284  $this->assertEquals( 0, $result->numRows() );
285  }
286 
292  public function testUpdateSame() {
293  $block = $this->insertBlock();
294  $page = $this->getExistingTestPage( 'Foo' );
295  $this->blockRestrictionStore->insert( [
296  new PageRestriction( $block->getId(), $page->getId() ),
297  ] );
298 
299  $this->blockRestrictionStore->update( [
300  new PageRestriction( $block->getId(), $page->getId() ),
301  ] );
302 
303  $db = wfGetDb( DB_REPLICA );
304  $result = $db->select(
305  [ 'ipblocks_restrictions' ],
306  [ '*' ],
307  [ 'ir_ipb_id' => $block->getId() ]
308  );
309 
310  $this->assertEquals( 1, $result->numRows() );
311  $row = $result->fetchObject();
312  $this->assertEquals( $block->getId(), $row->ir_ipb_id );
313  $this->assertEquals( $page->getId(), $row->ir_value );
314  }
315 
320  // Create a block and an autoblock (a child block)
321  $block = $this->insertBlock();
322  $pageFoo = $this->getExistingTestPage( 'Foo' );
323  $pageBar = $this->getExistingTestPage( 'Bar' );
324  $this->blockRestrictionStore->insert( [
325  new PageRestriction( $block->getId(), $pageFoo->getId() ),
326  ] );
327  $autoblockId = $block->doAutoblock( '127.0.0.1' );
328 
329  // Ensure that the restrictions on the block have not changed.
330  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
331  $this->assertCount( 1, $restrictions );
332  $this->assertEquals( $pageFoo->getId(), $restrictions[0]->getValue() );
333 
334  // Ensure that the restrictions on the autoblock are the same as the block.
335  $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
336  $this->assertCount( 1, $restrictions );
337  $this->assertEquals( $pageFoo->getId(), $restrictions[0]->getValue() );
338 
339  // Update the restrictions on the autoblock (but leave the block unchanged)
340  $this->blockRestrictionStore->updateByParentBlockId( $block->getId(), [
341  new PageRestriction( $block->getId(), $pageBar->getId() ),
342  ] );
343 
344  // Ensure that the restrictions on the block have not changed.
345  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
346  $this->assertCount( 1, $restrictions );
347  $this->assertEquals( $pageFoo->getId(), $restrictions[0]->getValue() );
348 
349  // Ensure that the restrictions on the autoblock have been updated.
350  $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
351  $this->assertCount( 1, $restrictions );
352  $this->assertEquals( $pageBar->getId(), $restrictions[0]->getValue() );
353  }
354 
358  public function testUpdateByParentBlockId() {
359  // Create a block and an autoblock (a child block)
360  $block = $this->insertBlock();
361  $page = $this->getExistingTestPage( 'Foo' );
362  $this->blockRestrictionStore->insert( [
363  new PageRestriction( $block->getId(), $page->getId() ),
364  ] );
365  $autoblockId = $block->doAutoblock( '127.0.0.1' );
366 
367  // Ensure that the restrictions on the block have not changed.
368  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
369  $this->assertCount( 1, $restrictions );
370 
371  // Ensure that the restrictions on the autoblock have not changed.
372  $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
373  $this->assertCount( 1, $restrictions );
374 
375  // Remove the restrictions on the autoblock (but leave the block unchanged)
376  $this->blockRestrictionStore->updateByParentBlockId( $block->getId(), [] );
377 
378  // Ensure that the restrictions on the block have not changed.
379  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
380  $this->assertCount( 1, $restrictions );
381 
382  // Ensure that the restrictions on the autoblock have been updated.
383  $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
384  $this->assertCount( 0, $restrictions );
385  }
386 
391  // Create a block with no autoblock.
392  $block = $this->insertBlock();
393  $page = $this->getExistingTestPage( 'Foo' );
394  $this->blockRestrictionStore->insert( [
395  new PageRestriction( $block->getId(), $page->getId() ),
396  ] );
397 
398  // Ensure that the restrictions on the block have not changed.
399  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
400  $this->assertCount( 1, $restrictions );
401 
402  // Update the restrictions on any autoblocks (there are none).
403  $this->blockRestrictionStore->updateByParentBlockId( $block->getId(), $restrictions );
404 
405  // Ensure that the restrictions on the block have not changed.
406  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
407  $this->assertCount( 1, $restrictions );
408  }
409 
413  public function testDelete() {
414  $block = $this->insertBlock();
415  $page = $this->getExistingTestPage( 'Foo' );
416  $this->blockRestrictionStore->insert( [
417  new PageRestriction( $block->getId(), $page->getId() ),
418  ] );
419 
420  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
421  $this->assertCount( 1, $restrictions );
422 
423  $result = $this->blockRestrictionStore->delete(
424  array_merge( $restrictions, [ new \stdClass() ] )
425  );
426  $this->assertTrue( $result );
427 
428  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
429  $this->assertCount( 0, $restrictions );
430  }
431 
435  public function testDeleteByBlockId() {
436  $block = $this->insertBlock();
437  $page = $this->getExistingTestPage( 'Foo' );
438  $this->blockRestrictionStore->insert( [
439  new PageRestriction( $block->getId(), $page->getId() ),
440  ] );
441 
442  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
443  $this->assertCount( 1, $restrictions );
444 
445  $result = $this->blockRestrictionStore->deleteByBlockId( $block->getId() );
446  $this->assertNotFalse( $result );
447 
448  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
449  $this->assertCount( 0, $restrictions );
450  }
451 
455  public function testDeleteByParentBlockId() {
456  // Create a block with no autoblock.
457  $block = $this->insertBlock();
458  $page = $this->getExistingTestPage( 'Foo' );
459  $this->blockRestrictionStore->insert( [
460  new PageRestriction( $block->getId(), $page->getId() ),
461  ] );
462  $autoblockId = $block->doAutoblock( '127.0.0.1' );
463 
464  // Ensure that the restrictions on the block have not changed.
465  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
466  $this->assertCount( 1, $restrictions );
467 
468  // Ensure that the restrictions on the autoblock are the same as the block.
469  $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
470  $this->assertCount( 1, $restrictions );
471 
472  // Remove all of the restrictions on the autoblock (but leave the block unchanged).
473  $result = $this->blockRestrictionStore->deleteByParentBlockId( $block->getId() );
474  // NOTE: commented out until https://gerrit.wikimedia.org/r/c/mediawiki/core/+/469324 is merged
475  //$this->assertTrue( $result );
476 
477  // Ensure that the restrictions on the block have not changed.
478  $restrictions = $this->blockRestrictionStore->loadByBlockId( $block->getId() );
479  $this->assertCount( 1, $restrictions );
480 
481  // Ensure that the restrictions on the autoblock have been removed.
482  $restrictions = $this->blockRestrictionStore->loadByBlockId( $autoblockId );
483  $this->assertCount( 0, $restrictions );
484  }
485 
494  public function testEquals( array $a, array $b, $expected ) {
495  $this->assertSame( $expected, $this->blockRestrictionStore->equals( $a, $b ) );
496  }
497 
498  public function equalsDataProvider() {
499  return [
500  [
501  [
502  new \stdClass(),
503  new PageRestriction( 1, 1 ),
504  ],
505  [
506  new \stdClass(),
507  new PageRestriction( 1, 2 )
508  ],
509  false,
510  ],
511  [
512  [
513  new PageRestriction( 1, 1 ),
514  ],
515  [
516  new PageRestriction( 1, 1 ),
517  new PageRestriction( 1, 2 )
518  ],
519  false,
520  ],
521  [
522  [],
523  [],
524  true,
525  ],
526  [
527  [
528  new PageRestriction( 1, 1 ),
529  new PageRestriction( 1, 2 ),
530  new PageRestriction( 2, 3 ),
531  ],
532  [
533  new PageRestriction( 2, 3 ),
534  new PageRestriction( 1, 2 ),
535  new PageRestriction( 1, 1 ),
536  ],
537  true
538  ],
539  [
540  [
541  new NamespaceRestriction( 1, NS_USER ),
542  ],
543  [
544  new NamespaceRestriction( 1, NS_USER ),
545  ],
546  true
547  ],
548  [
549  [
550  new NamespaceRestriction( 1, NS_USER ),
551  ],
552  [
553  new NamespaceRestriction( 1, NS_TALK ),
554  ],
555  false
556  ],
557  ];
558  }
559 
563  public function testSetBlockId() {
564  $restrictions = [
565  new \stdClass(),
566  new PageRestriction( 1, 1 ),
567  new PageRestriction( 1, 2 ),
568  new NamespaceRestriction( 1, NS_USER ),
569  ];
570 
571  $this->assertSame( 1, $restrictions[1]->getBlockId() );
572  $this->assertSame( 1, $restrictions[2]->getBlockId() );
573  $this->assertSame( 1, $restrictions[3]->getBlockId() );
574 
575  $result = $this->blockRestrictionStore->setBlockId( 2, $restrictions );
576 
577  foreach ( $result as $restriction ) {
578  $this->assertSame( 2, $restriction->getBlockId() );
579  }
580  }
581 
582  protected function insertBlock() {
583  $badActor = $this->getTestUser()->getUser();
584  $sysop = $this->getTestSysop()->getUser();
585 
586  $block = new \Block( [
587  'address' => $badActor->getName(),
588  'user' => $badActor->getId(),
589  'by' => $sysop->getId(),
590  'expiry' => 'infinity',
591  'sitewide' => 0,
592  'enableAutoblock' => true,
593  ] );
594 
595  $block->insert();
596 
597  return $block;
598  }
599 
600  protected function insertRestriction( $blockId, $type, $value ) {
601  $this->db->insert( 'ipblocks_restrictions', [
602  'ir_ipb_id' => $blockId,
603  'ir_type' => $type,
604  'ir_value' => $value,
605  ] );
606  }
607 
608  protected function resetTables() {
609  $this->db->delete( 'ipblocks', '*', __METHOD__ );
610  $this->db->delete( 'ipblocks_restrictions', '*', __METHOD__ );
611  }
612 }
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
MediaWiki\Block\Restriction\PageRestriction\TYPE_ID
const TYPE_ID
@inheritDoc
Definition: PageRestriction.php:35
MediaWikiTestCase\getTestUser
static getTestUser( $groups=[])
Convenience method for getting an immutable test user.
Definition: MediaWikiTestCase.php:180
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testUpdateSame
testUpdateSame()
::update ::restrictionsByBlockId ::restrictionsToRemove
Definition: BlockRestrictionStoreTest.php:292
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testMappingNamespaceRestrictionObject
testMappingNamespaceRestrictionObject()
::loadByBlockId ::resultToRestrictions ::rowToRestriction
Definition: BlockRestrictionStoreTest.php:131
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testUpdateNoRestrictions
testUpdateNoRestrictions()
::update ::restrictionsByBlockId ::restrictionsToRemove
Definition: BlockRestrictionStoreTest.php:272
MediaWiki\Tests\Block\BlockRestrictionStoreTest\tearDown
tearDown()
Definition: BlockRestrictionStoreTest.php:27
$result
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 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name '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. '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 '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 since 1.28! 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:1983
MediaWiki\Block\Restriction\NamespaceRestriction\TYPE
const TYPE
@inheritDoc
Definition: NamespaceRestriction.php:30
MediaWiki\Tests\Block\BlockRestrictionStoreTest\insertRestriction
insertRestriction( $blockId, $type, $value)
Definition: BlockRestrictionStoreTest.php:600
NS_FILE
const NS_FILE
Definition: Defines.php:70
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testUpdateChange
testUpdateChange()
::update ::restrictionsByBlockId ::restrictionsToRemove
Definition: BlockRestrictionStoreTest.php:246
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testDelete
testDelete()
::delete
Definition: BlockRestrictionStoreTest.php:413
MediaWiki\Tests\Block\BlockRestrictionStoreTest\setUp
setUp()
Definition: BlockRestrictionStoreTest.php:21
MediaWiki\Tests\Block\BlockRestrictionStoreTest\insertBlock
insertBlock()
Definition: BlockRestrictionStoreTest.php:582
php
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
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testInsertTypes
testInsertTypes()
insert
Definition: BlockRestrictionStoreTest.php:180
MediaWiki\Block\Restriction\NamespaceRestriction\TYPE_ID
const TYPE_ID
@inheritDoc
Definition: NamespaceRestriction.php:35
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition: MediaWikiTestCase.php:709
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testDeleteByBlockId
testDeleteByBlockId()
::deleteByBlockId
Definition: BlockRestrictionStoreTest.php:435
MediaWiki\Block\Restriction\Restriction
Definition: Restriction.php:25
use
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
Definition: MIT-LICENSE.txt:10
MediaWiki\Block\Restriction\PageRestriction\TYPE
const TYPE
@inheritDoc
Definition: PageRestriction.php:30
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testIgnoreNotSupportedTypes
testIgnoreNotSupportedTypes()
::loadByBlockId ::resultToRestrictions ::rowToRestriction
Definition: BlockRestrictionStoreTest.php:83
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testSetBlockId
testSetBlockId()
::setBlockId
Definition: BlockRestrictionStoreTest.php:563
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
list
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
Definition: deferred.txt:11
MediaWiki\Tests\Block\BlockRestrictionStoreTest\equalsDataProvider
equalsDataProvider()
Definition: BlockRestrictionStoreTest.php:498
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testInsert
testInsert()
insert
Definition: BlockRestrictionStoreTest.php:150
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
Definition: MediaWikiServices.php:124
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testWithEmptyParam
testWithEmptyParam()
::loadByBlockId ::resultToRestrictions ::rowToRestriction
Definition: BlockRestrictionStoreTest.php:73
$value
$value
Definition: styleTest.css.php:49
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testUpdateByParentBlockId
testUpdateByParentBlockId()
::updateByParentBlockId
Definition: BlockRestrictionStoreTest.php:358
MediaWiki\Tests\Block\BlockRestrictionStoreTest\$blockRestrictionStore
BlockRestrictionStore $blockRestrictionStore
Definition: BlockRestrictionStoreTest.php:19
MediaWikiTestCase\getTestSysop
static getTestSysop()
Convenience method for getting an immutable admin test user.
Definition: MediaWikiTestCase.php:204
MediaWikiLangTestCase
Base class that store and restore the Language objects.
Definition: MediaWikiLangTestCase.php:8
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testMappingPageRestrictionObject
testMappingPageRestrictionObject()
::loadByBlockId ::resultToRestrictions ::rowToRestriction
Definition: BlockRestrictionStoreTest.php:106
MediaWiki\Tests\Block\BlockRestrictionStoreTest\resetTables
resetTables()
Definition: BlockRestrictionStoreTest.php:608
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testWithNoRestrictions
testWithNoRestrictions()
::loadByBlockId ::resultToRestrictions ::rowToRestriction
Definition: BlockRestrictionStoreTest.php:62
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testDeleteByParentBlockId
testDeleteByParentBlockId()
::deleteByParentBlockId
Definition: BlockRestrictionStoreTest.php:455
MediaWikiTestCase\getExistingTestPage
getExistingTestPage( $title=null)
Returns a WikiPage representing an existing page.
Definition: MediaWikiTestCase.php:220
MediaWiki\Block\Restriction\NamespaceRestriction
Definition: NamespaceRestriction.php:25
MediaWiki\Tests\Block
Definition: BlockRestrictionStoreTest.php:3
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testLoadMultipleRestrictions
testLoadMultipleRestrictions()
::loadByBlockId ::resultToRestrictions ::rowToRestriction
Definition: BlockRestrictionStoreTest.php:37
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testEquals
testEquals(array $a, array $b, $expected)
::equals equalsDataProvider
Definition: BlockRestrictionStoreTest.php:494
MediaWiki\Block\Restriction\PageRestriction
Definition: PageRestriction.php:25
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testUpdateInsert
testUpdateInsert()
::update ::restrictionsByBlockId ::restrictionsToRemove
Definition: BlockRestrictionStoreTest.php:214
as
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
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testNoAutoblocksUpdateByParentBlockId
testNoAutoblocksUpdateByParentBlockId()
::updateByParentBlockId
Definition: BlockRestrictionStoreTest.php:390
MediaWiki\Tests\Block\BlockRestrictionStoreTest
Database Blocking @coversDefaultClass \MediaWiki\Block\BlockRestrictionStore.
Definition: BlockRestrictionStoreTest.php:16
NS_USER
const NS_USER
Definition: Defines.php:66
MediaWiki\Tests\Block\BlockRestrictionStoreTest\testDeleteAllUpdateByParentBlockId
testDeleteAllUpdateByParentBlockId()
::updateByParentBlockId
Definition: BlockRestrictionStoreTest.php:319
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 just before the function returns a value If you return true
Definition: hooks.txt:1985
NS_TALK
const NS_TALK
Definition: Defines.php:65
class
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
Definition: maintenance.txt:52
MediaWikiServices
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
Definition: injection.txt:23
MediaWikiTestCase\$db
Database $db
Primary database.
Definition: MediaWikiTestCase.php:61
MediaWiki\Block\BlockRestrictionStore
Definition: BlockRestrictionStore.php:33
$type
$type
Definition: testCompression.php:48