MediaWiki  REL1_31
RevisionStoreDbTest.php
Go to the documentation of this file.
1 <?php
2 
4 
6 use Exception;
8 use InvalidArgumentException;
22 use Title;
31 
36 
37  public function setUp() {
38  parent::setUp();
39  $this->tablesUsed[] = 'archive';
40  $this->tablesUsed[] = 'page';
41  $this->tablesUsed[] = 'revision';
42  $this->tablesUsed[] = 'comment';
43  }
44 
48  private function getLoadBalancerMock( array $server ) {
49  $lb = $this->getMockBuilder( LoadBalancer::class )
50  ->setMethods( [ 'reallyOpenConnection' ] )
51  ->setConstructorArgs( [ [ 'servers' => [ $server ] ] ] )
52  ->getMock();
53 
54  $lb->method( 'reallyOpenConnection' )->willReturnCallback(
55  function ( array $server, $dbNameOverride ) {
56  return $this->getDatabaseMock( $server );
57  }
58  );
59 
60  return $lb;
61  }
62 
66  private function getDatabaseMock( array $params ) {
67  $db = $this->getMockBuilder( DatabaseSqlite::class )
68  ->setMethods( [ 'select', 'doQuery', 'open', 'closeConnection', 'isOpen' ] )
69  ->setConstructorArgs( [ $params ] )
70  ->getMock();
71 
72  $db->method( 'select' )->willReturn( new FakeResultWrapper( [] ) );
73  $db->method( 'isOpen' )->willReturn( true );
74 
75  return $db;
76  }
77 
78  public function provideDomainCheck() {
79  yield [ false, 'test', '' ];
80  yield [ 'test', 'test', '' ];
81 
82  yield [ false, 'test', 'foo_' ];
83  yield [ 'test-foo_', 'test', 'foo_' ];
84 
85  yield [ false, 'dash-test', '' ];
86  yield [ 'dash-test', 'dash-test', '' ];
87 
88  yield [ false, 'underscore_test', 'foo_' ];
89  yield [ 'underscore_test-foo_', 'underscore_test', 'foo_' ];
90  }
91 
96  public function testDomainCheck( $wikiId, $dbName, $dbPrefix ) {
97  $this->setMwGlobals(
98  [
99  'wgDBname' => $dbName,
100  'wgDBprefix' => $dbPrefix,
101  ]
102  );
103 
104  $loadBalancer = $this->getLoadBalancerMock(
105  [
106  'host' => '*dummy*',
107  'dbDirectory' => '*dummy*',
108  'user' => 'test',
109  'password' => 'test',
110  'flags' => 0,
111  'variables' => [],
112  'schema' => '',
113  'cliMode' => true,
114  'agent' => '',
115  'load' => 100,
116  'profiler' => null,
117  'trxProfiler' => new TransactionProfiler(),
118  'connLogger' => new \Psr\Log\NullLogger(),
119  'queryLogger' => new \Psr\Log\NullLogger(),
120  'errorLogger' => function () {
121  },
122  'deprecationLogger' => function () {
123  },
124  'type' => 'test',
125  'dbname' => $dbName,
126  'tablePrefix' => $dbPrefix,
127  ]
128  );
129  $db = $loadBalancer->getConnection( DB_REPLICA );
130 
131  $blobStore = $this->getMockBuilder( SqlBlobStore::class )
132  ->disableOriginalConstructor()
133  ->getMock();
134 
135  $store = new RevisionStore(
136  $loadBalancer,
137  $blobStore,
138  new WANObjectCache( [ 'cache' => new HashBagOStuff() ] ),
139  MediaWikiServices::getInstance()->getCommentStore(),
140  MediaWikiServices::getInstance()->getActorMigration(),
141  $wikiId
142  );
143 
144  $count = $store->countRevisionsByPageId( $db, 0 );
145 
146  // Dummy check to make PhpUnit happy. We are really only interested in
147  // countRevisionsByPageId not failing due to the DB domain check.
148  $this->assertSame( 0, $count );
149  }
150 
151  private function assertLinkTargetsEqual( LinkTarget $l1, LinkTarget $l2 ) {
152  $this->assertEquals( $l1->getDBkey(), $l2->getDBkey() );
153  $this->assertEquals( $l1->getNamespace(), $l2->getNamespace() );
154  $this->assertEquals( $l1->getFragment(), $l2->getFragment() );
155  $this->assertEquals( $l1->getInterwiki(), $l2->getInterwiki() );
156  }
157 
159  $this->assertEquals( $r1->getUser()->getName(), $r2->getUser()->getName() );
160  $this->assertEquals( $r1->getUser()->getId(), $r2->getUser()->getId() );
161  $this->assertEquals( $r1->getComment(), $r2->getComment() );
162  $this->assertEquals( $r1->getPageAsLinkTarget(), $r2->getPageAsLinkTarget() );
163  $this->assertEquals( $r1->getTimestamp(), $r2->getTimestamp() );
164  $this->assertEquals( $r1->getVisibility(), $r2->getVisibility() );
165  $this->assertEquals( $r1->getSha1(), $r2->getSha1() );
166  $this->assertEquals( $r1->getParentId(), $r2->getParentId() );
167  $this->assertEquals( $r1->getSize(), $r2->getSize() );
168  $this->assertEquals( $r1->getPageId(), $r2->getPageId() );
169  $this->assertEquals( $r1->getSlotRoles(), $r2->getSlotRoles() );
170  $this->assertEquals( $r1->getWikiId(), $r2->getWikiId() );
171  $this->assertEquals( $r1->isMinor(), $r2->isMinor() );
172  foreach ( $r1->getSlotRoles() as $role ) {
173  $this->assertSlotRecordsEqual( $r1->getSlot( $role ), $r2->getSlot( $role ) );
174  $this->assertTrue( $r1->getContent( $role )->equals( $r2->getContent( $role ) ) );
175  }
176  foreach ( [
181  ] as $field ) {
182  $this->assertEquals( $r1->isDeleted( $field ), $r2->isDeleted( $field ) );
183  }
184  }
185 
186  private function assertSlotRecordsEqual( SlotRecord $s1, SlotRecord $s2 ) {
187  $this->assertSame( $s1->getRole(), $s2->getRole() );
188  $this->assertSame( $s1->getModel(), $s2->getModel() );
189  $this->assertSame( $s1->getFormat(), $s2->getFormat() );
190  $this->assertSame( $s1->getSha1(), $s2->getSha1() );
191  $this->assertSame( $s1->getSize(), $s2->getSize() );
192  $this->assertTrue( $s1->getContent()->equals( $s2->getContent() ) );
193 
194  $s1->hasRevision() ? $this->assertSame( $s1->getRevision(), $s2->getRevision() ) : null;
195  $s1->hasAddress() ? $this->assertSame( $s1->hasAddress(), $s2->hasAddress() ) : null;
196  }
197 
199  foreach ( $r->getSlotRoles() as $role ) {
200  $this->assertSlotCompleteness( $r, $r->getSlot( $role ) );
201  }
202  }
203 
204  private function assertSlotCompleteness( RevisionRecord $r, SlotRecord $slot ) {
205  $this->assertTrue( $slot->hasAddress() );
206  $this->assertSame( $r->getId(), $slot->getRevision() );
207  }
208 
214  private function getRevisionRecordFromDetailsArray( $title, $details = [] ) {
215  // Convert some values that can't be provided by dataProviders
216  $page = WikiPage::factory( $title );
217  if ( isset( $details['user'] ) && $details['user'] === true ) {
218  $details['user'] = $this->getTestUser()->getUser();
219  }
220  if ( isset( $details['page'] ) && $details['page'] === true ) {
221  $details['page'] = $page->getId();
222  }
223  if ( isset( $details['parent'] ) && $details['parent'] === true ) {
224  $details['parent'] = $page->getLatest();
225  }
226 
227  // Create the RevisionRecord with any available data
229  isset( $details['slot'] ) ? $rev->setSlot( $details['slot'] ) : null;
230  isset( $details['parent'] ) ? $rev->setParentId( $details['parent'] ) : null;
231  isset( $details['page'] ) ? $rev->setPageId( $details['page'] ) : null;
232  isset( $details['size'] ) ? $rev->setSize( $details['size'] ) : null;
233  isset( $details['sha1'] ) ? $rev->setSha1( $details['sha1'] ) : null;
234  isset( $details['comment'] ) ? $rev->setComment( $details['comment'] ) : null;
235  isset( $details['timestamp'] ) ? $rev->setTimestamp( $details['timestamp'] ) : null;
236  isset( $details['minor'] ) ? $rev->setMinorEdit( $details['minor'] ) : null;
237  isset( $details['user'] ) ? $rev->setUser( $details['user'] ) : null;
238  isset( $details['visibility'] ) ? $rev->setVisibility( $details['visibility'] ) : null;
239  isset( $details['id'] ) ? $rev->setId( $details['id'] ) : null;
240 
241  return $rev;
242  }
243 
244  private function getRandomCommentStoreComment() {
245  return CommentStoreComment::newUnsavedComment( __METHOD__ . '.' . rand( 0, 1000 ) );
246  }
247 
249  yield 'Bare minimum revision insertion' => [
250  Title::newFromText( 'UTPage' ),
251  [
252  'slot' => SlotRecord::newUnsaved( 'main', new WikitextContent( 'Chicken' ) ),
253  'parent' => true,
254  'comment' => $this->getRandomCommentStoreComment(),
255  'timestamp' => '20171117010101',
256  'user' => true,
257  ],
258  ];
259  yield 'Detailed revision insertion' => [
260  Title::newFromText( 'UTPage' ),
261  [
262  'slot' => SlotRecord::newUnsaved( 'main', new WikitextContent( 'Chicken' ) ),
263  'parent' => true,
264  'page' => true,
265  'comment' => $this->getRandomCommentStoreComment(),
266  'timestamp' => '20171117010101',
267  'user' => true,
268  'minor' => true,
269  'visibility' => RevisionRecord::DELETED_RESTRICTED,
270  ],
271  ];
272  }
273 
278  public function testInsertRevisionOn_successes( Title $title, array $revDetails = [] ) {
279  $rev = $this->getRevisionRecordFromDetailsArray( $title, $revDetails );
280 
281  $store = MediaWikiServices::getInstance()->getRevisionStore();
282  $return = $store->insertRevisionOn( $rev, wfGetDB( DB_MASTER ) );
283 
284  $this->assertLinkTargetsEqual( $title, $return->getPageAsLinkTarget() );
285  $this->assertRevisionRecordsEqual( $rev, $return );
286  $this->assertRevisionCompleteness( $return );
287  }
288 
293  $title = Title::newFromText( 'UTPage' );
294  $revDetails = [
295  'slot' => SlotRecord::newUnsaved( 'main', new WikitextContent( 'Chicken' ) ),
296  'parent' => true,
297  'comment' => $this->getRandomCommentStoreComment(),
298  'timestamp' => '20171117010101',
299  'user' => true,
300  ];
301 
302  $store = MediaWikiServices::getInstance()->getRevisionStore();
303 
304  // Insert the first revision
305  $revOne = $this->getRevisionRecordFromDetailsArray( $title, $revDetails );
306  $firstReturn = $store->insertRevisionOn( $revOne, wfGetDB( DB_MASTER ) );
307  $this->assertLinkTargetsEqual( $title, $firstReturn->getPageAsLinkTarget() );
308  $this->assertRevisionRecordsEqual( $revOne, $firstReturn );
309 
310  // Insert a second revision inheriting the same blob address
311  $revDetails['slot'] = SlotRecord::newInherited( $firstReturn->getSlot( 'main' ) );
312  $revTwo = $this->getRevisionRecordFromDetailsArray( $title, $revDetails );
313  $secondReturn = $store->insertRevisionOn( $revTwo, wfGetDB( DB_MASTER ) );
314  $this->assertLinkTargetsEqual( $title, $secondReturn->getPageAsLinkTarget() );
315  $this->assertRevisionRecordsEqual( $revTwo, $secondReturn );
316 
317  // Assert that the same blob address has been used.
318  $this->assertEquals(
319  $firstReturn->getSlot( 'main' )->getAddress(),
320  $secondReturn->getSlot( 'main' )->getAddress()
321  );
322  // And that different revisions have been created.
323  $this->assertNotSame(
324  $firstReturn->getId(),
325  $secondReturn->getId()
326  );
327  }
328 
330  yield 'no slot' => [
331  Title::newFromText( 'UTPage' ),
332  [
333  'comment' => $this->getRandomCommentStoreComment(),
334  'timestamp' => '20171117010101',
335  'user' => true,
336  ],
337  new InvalidArgumentException( 'At least one slot needs to be defined!' )
338  ];
339  yield 'slot that is not main slot' => [
340  Title::newFromText( 'UTPage' ),
341  [
342  'slot' => SlotRecord::newUnsaved( 'lalala', new WikitextContent( 'Chicken' ) ),
343  'comment' => $this->getRandomCommentStoreComment(),
344  'timestamp' => '20171117010101',
345  'user' => true,
346  ],
347  new InvalidArgumentException( 'Only the main slot is supported for now!' )
348  ];
349  yield 'no timestamp' => [
350  Title::newFromText( 'UTPage' ),
351  [
352  'slot' => SlotRecord::newUnsaved( 'main', new WikitextContent( 'Chicken' ) ),
353  'comment' => $this->getRandomCommentStoreComment(),
354  'user' => true,
355  ],
356  new IncompleteRevisionException( 'timestamp field must not be NULL!' )
357  ];
358  yield 'no comment' => [
359  Title::newFromText( 'UTPage' ),
360  [
361  'slot' => SlotRecord::newUnsaved( 'main', new WikitextContent( 'Chicken' ) ),
362  'timestamp' => '20171117010101',
363  'user' => true,
364  ],
365  new IncompleteRevisionException( 'comment must not be NULL!' )
366  ];
367  yield 'no user' => [
368  Title::newFromText( 'UTPage' ),
369  [
370  'slot' => SlotRecord::newUnsaved( 'main', new WikitextContent( 'Chicken' ) ),
371  'comment' => $this->getRandomCommentStoreComment(),
372  'timestamp' => '20171117010101',
373  ],
374  new IncompleteRevisionException( 'user must not be NULL!' )
375  ];
376  }
377 
383  Title $title,
384  array $revDetails = [],
385  Exception $exception ) {
386  $rev = $this->getRevisionRecordFromDetailsArray( $title, $revDetails );
387 
388  $store = MediaWikiServices::getInstance()->getRevisionStore();
389 
390  $this->setExpectedException(
391  get_class( $exception ),
392  $exception->getMessage(),
393  $exception->getCode()
394  );
395  $store->insertRevisionOn( $rev, wfGetDB( DB_MASTER ) );
396  }
397 
398  public function provideNewNullRevision() {
399  yield [
400  Title::newFromText( 'UTPage' ),
401  CommentStoreComment::newUnsavedComment( __METHOD__ . ' comment1' ),
402  true,
403  ];
404  yield [
405  Title::newFromText( 'UTPage' ),
406  CommentStoreComment::newUnsavedComment( __METHOD__ . ' comment2', [ 'a' => 1 ] ),
407  false,
408  ];
409  }
410 
415  public function testNewNullRevision( Title $title, $comment, $minor ) {
416  $store = MediaWikiServices::getInstance()->getRevisionStore();
417  $user = TestUserRegistry::getMutableTestUser( __METHOD__ )->getUser();
418 
419  $parent = $store->getRevisionByTitle( $title );
420  $record = $store->newNullRevision(
421  wfGetDB( DB_MASTER ),
422  $title,
423  $comment,
424  $minor,
425  $user
426  );
427 
428  $this->assertEquals( $title->getNamespace(), $record->getPageAsLinkTarget()->getNamespace() );
429  $this->assertEquals( $title->getDBkey(), $record->getPageAsLinkTarget()->getDBkey() );
430  $this->assertEquals( $comment, $record->getComment() );
431  $this->assertEquals( $minor, $record->isMinor() );
432  $this->assertEquals( $user->getName(), $record->getUser()->getName() );
433  $this->assertEquals( $parent->getId(), $record->getParentId() );
434 
435  $parentSlot = $parent->getSlot( 'main' );
436  $slot = $record->getSlot( 'main' );
437 
438  $this->assertTrue( $slot->isInherited(), 'isInherited' );
439  $this->assertSame( $parentSlot->getOrigin(), $slot->getOrigin(), 'getOrigin' );
440  $this->assertSame( $parentSlot->getAddress(), $slot->getAddress(), 'getAddress' );
441  }
442 
447  $store = MediaWikiServices::getInstance()->getRevisionStore();
448  $record = $store->newNullRevision(
449  wfGetDB( DB_MASTER ),
450  Title::newFromText( __METHOD__ . '.iDontExist!' ),
451  CommentStoreComment::newUnsavedComment( __METHOD__ . ' comment' ),
452  false,
453  TestUserRegistry::getMutableTestUser( __METHOD__ )->getUser()
454  );
455  $this->assertNull( $record );
456  }
457 
462  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
463  $status = $page->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
465  $rev = $status->value['revision'];
466 
467  $store = MediaWikiServices::getInstance()->getRevisionStore();
468  $revisionRecord = $store->getRevisionById( $rev->getId() );
469  $result = $store->getRcIdIfUnpatrolled( $revisionRecord );
470 
471  $this->assertGreaterThan( 0, $result );
472  $this->assertSame(
473  $page->getRevision()->getRecentChange()->getAttribute( 'rc_id' ),
474  $result
475  );
476  }
477 
482  // This assumes that sysops are auto patrolled
483  $sysop = $this->getTestSysop()->getUser();
484  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
485  $status = $page->doEditContent(
486  new WikitextContent( __METHOD__ ),
487  __METHOD__,
488  0,
489  false,
490  $sysop
491  );
493  $rev = $status->value['revision'];
494 
495  $store = MediaWikiServices::getInstance()->getRevisionStore();
496  $revisionRecord = $store->getRevisionById( $rev->getId() );
497  $result = $store->getRcIdIfUnpatrolled( $revisionRecord );
498 
499  $this->assertSame( 0, $result );
500  }
501 
505  public function testGetRecentChange() {
506  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
507  $content = new WikitextContent( __METHOD__ );
508  $status = $page->doEditContent( $content, __METHOD__ );
510  $rev = $status->value['revision'];
511 
512  $store = MediaWikiServices::getInstance()->getRevisionStore();
513  $revRecord = $store->getRevisionById( $rev->getId() );
514  $recentChange = $store->getRecentChange( $revRecord );
515 
516  $this->assertEquals( $rev->getId(), $recentChange->getAttribute( 'rc_this_oldid' ) );
517  $this->assertEquals( $rev->getRecentChange(), $recentChange );
518  }
519 
523  public function testGetRevisionById() {
524  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
525  $content = new WikitextContent( __METHOD__ );
526  $status = $page->doEditContent( $content, __METHOD__ );
528  $rev = $status->value['revision'];
529 
530  $store = MediaWikiServices::getInstance()->getRevisionStore();
531  $revRecord = $store->getRevisionById( $rev->getId() );
532 
533  $this->assertSame( $rev->getId(), $revRecord->getId() );
534  $this->assertTrue( $revRecord->getSlot( 'main' )->getContent()->equals( $content ) );
535  $this->assertSame( __METHOD__, $revRecord->getComment()->text );
536  }
537 
541  public function testGetRevisionByTitle() {
542  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
543  $content = new WikitextContent( __METHOD__ );
544  $status = $page->doEditContent( $content, __METHOD__ );
546  $rev = $status->value['revision'];
547 
548  $store = MediaWikiServices::getInstance()->getRevisionStore();
549  $revRecord = $store->getRevisionByTitle( $page->getTitle() );
550 
551  $this->assertSame( $rev->getId(), $revRecord->getId() );
552  $this->assertTrue( $revRecord->getSlot( 'main' )->getContent()->equals( $content ) );
553  $this->assertSame( __METHOD__, $revRecord->getComment()->text );
554  }
555 
559  public function testGetRevisionByPageId() {
560  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
561  $content = new WikitextContent( __METHOD__ );
562  $status = $page->doEditContent( $content, __METHOD__ );
564  $rev = $status->value['revision'];
565 
566  $store = MediaWikiServices::getInstance()->getRevisionStore();
567  $revRecord = $store->getRevisionByPageId( $page->getId() );
568 
569  $this->assertSame( $rev->getId(), $revRecord->getId() );
570  $this->assertTrue( $revRecord->getSlot( 'main' )->getContent()->equals( $content ) );
571  $this->assertSame( __METHOD__, $revRecord->getComment()->text );
572  }
573 
577  public function testGetRevisionByTimestamp() {
578  // Make sure there is 1 second between the last revision and the rev we create...
579  // Otherwise we might not get the correct revision and the test may fail...
580  // :(
581  sleep( 1 );
582  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
583  $content = new WikitextContent( __METHOD__ );
584  $status = $page->doEditContent( $content, __METHOD__ );
586  $rev = $status->value['revision'];
587 
588  $store = MediaWikiServices::getInstance()->getRevisionStore();
589  $revRecord = $store->getRevisionByTimestamp(
590  $page->getTitle(),
591  $rev->getTimestamp()
592  );
593 
594  $this->assertSame( $rev->getId(), $revRecord->getId() );
595  $this->assertTrue( $revRecord->getSlot( 'main' )->getContent()->equals( $content ) );
596  $this->assertSame( __METHOD__, $revRecord->getComment()->text );
597  }
598 
599  private function revisionToRow( Revision $rev ) {
600  $page = WikiPage::factory( $rev->getTitle() );
601 
602  return (object)[
603  'rev_id' => (string)$rev->getId(),
604  'rev_page' => (string)$rev->getPage(),
605  'rev_text_id' => (string)$rev->getTextId(),
606  'rev_timestamp' => (string)$rev->getTimestamp(),
607  'rev_user_text' => (string)$rev->getUserText(),
608  'rev_user' => (string)$rev->getUser(),
609  'rev_minor_edit' => $rev->isMinor() ? '1' : '0',
610  'rev_deleted' => (string)$rev->getVisibility(),
611  'rev_len' => (string)$rev->getSize(),
612  'rev_parent_id' => (string)$rev->getParentId(),
613  'rev_sha1' => (string)$rev->getSha1(),
614  'rev_comment_text' => $rev->getComment(),
615  'rev_comment_data' => null,
616  'rev_comment_cid' => null,
617  'rev_content_format' => $rev->getContentFormat(),
618  'rev_content_model' => $rev->getContentModel(),
619  'page_namespace' => (string)$page->getTitle()->getNamespace(),
620  'page_title' => $page->getTitle()->getDBkey(),
621  'page_id' => (string)$page->getId(),
622  'page_latest' => (string)$page->getLatest(),
623  'page_is_redirect' => $page->isRedirect() ? '1' : '0',
624  'page_len' => (string)$page->getContent()->getSize(),
625  'user_name' => (string)$rev->getUserText(),
626  ];
627  }
628 
630  Revision $rev,
631  RevisionRecord $record
632  ) {
633  $this->assertSame( $rev->getId(), $record->getId() );
634  $this->assertSame( $rev->getPage(), $record->getPageId() );
635  $this->assertSame( $rev->getTimestamp(), $record->getTimestamp() );
636  $this->assertSame( $rev->getUserText(), $record->getUser()->getName() );
637  $this->assertSame( $rev->getUser(), $record->getUser()->getId() );
638  $this->assertSame( $rev->isMinor(), $record->isMinor() );
639  $this->assertSame( $rev->getVisibility(), $record->getVisibility() );
640  $this->assertSame( $rev->getSize(), $record->getSize() );
645  $expectedParent = $rev->getParentId();
646  if ( $expectedParent === null ) {
647  $expectedParent = 0;
648  }
649  $this->assertSame( $expectedParent, $record->getParentId() );
650  $this->assertSame( $rev->getSha1(), $record->getSha1() );
651  $this->assertSame( $rev->getComment(), $record->getComment()->text );
652  $this->assertSame( $rev->getContentFormat(), $record->getContent( 'main' )->getDefaultFormat() );
653  $this->assertSame( $rev->getContentModel(), $record->getContent( 'main' )->getModel() );
654  $this->assertLinkTargetsEqual( $rev->getTitle(), $record->getPageAsLinkTarget() );
655  }
656 
662  $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_WRITE_BOTH );
663  $this->overrideMwServices();
664 
665  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
666  $text = __METHOD__ . 'a-ä';
668  $rev = $page->doEditContent(
669  new WikitextContent( $text ),
670  __METHOD__ . 'a'
671  )->value['revision'];
672 
673  $store = MediaWikiServices::getInstance()->getRevisionStore();
674  $record = $store->newRevisionFromRow(
675  $this->revisionToRow( $rev ),
676  [],
677  $page->getTitle()
678  );
679  $this->assertRevisionRecordMatchesRevision( $rev, $record );
680  $this->assertSame( $text, $rev->getContent()->serialize() );
681  }
682 
688  $this->setMwGlobals( 'wgLegacyEncoding', 'windows-1252' );
689  $this->overrideMwServices();
690  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
691  $text = __METHOD__ . 'a-ä';
693  $rev = $page->doEditContent(
694  new WikitextContent( $text ),
695  __METHOD__. 'a'
696  )->value['revision'];
697 
698  $store = MediaWikiServices::getInstance()->getRevisionStore();
699  $record = $store->newRevisionFromRow(
700  $this->revisionToRow( $rev ),
701  [],
702  $page->getTitle()
703  );
704  $this->assertRevisionRecordMatchesRevision( $rev, $record );
705  $this->assertSame( $text, $rev->getContent()->serialize() );
706  }
707 
713  $this->setMwGlobals( 'wgActorTableSchemaMigrationStage', MIGRATION_WRITE_BOTH );
714  $this->overrideMwServices();
715 
716  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
717  $text = __METHOD__ . 'b-ä';
719  $rev = $page->doEditContent(
720  new WikitextContent( $text ),
721  __METHOD__ . 'b',
722  0,
723  false,
724  $this->getTestUser()->getUser()
725  )->value['revision'];
726 
727  $store = MediaWikiServices::getInstance()->getRevisionStore();
728  $record = $store->newRevisionFromRow(
729  $this->revisionToRow( $rev ),
730  [],
731  $page->getTitle()
732  );
733  $this->assertRevisionRecordMatchesRevision( $rev, $record );
734  $this->assertSame( $text, $rev->getContent()->serialize() );
735  }
736 
740  public function testNewRevisionFromArchiveRow() {
741  $store = MediaWikiServices::getInstance()->getRevisionStore();
742  $title = Title::newFromText( __METHOD__ );
743  $text = __METHOD__ . '-bä';
744  $page = WikiPage::factory( $title );
746  $orig = $page->doEditContent( new WikitextContent( $text ), __METHOD__ )
747  ->value['revision'];
748  $page->doDeleteArticle( __METHOD__ );
749 
750  $db = wfGetDB( DB_MASTER );
751  $arQuery = $store->getArchiveQueryInfo();
752  $res = $db->select(
753  $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
754  __METHOD__, [], $arQuery['joins']
755  );
756  $this->assertTrue( is_object( $res ), 'query failed' );
757 
758  $row = $res->fetchObject();
759  $res->free();
760  $record = $store->newRevisionFromArchiveRow( $row );
761 
762  $this->assertRevisionRecordMatchesRevision( $orig, $record );
763  $this->assertSame( $text, $record->getContent( 'main' )->serialize() );
764  }
765 
770  $this->setMwGlobals( 'wgLegacyEncoding', 'windows-1252' );
771  $this->overrideMwServices();
772  $store = MediaWikiServices::getInstance()->getRevisionStore();
773  $title = Title::newFromText( __METHOD__ );
774  $text = __METHOD__ . '-bä';
775  $page = WikiPage::factory( $title );
777  $orig = $page->doEditContent( new WikitextContent( $text ), __METHOD__ )
778  ->value['revision'];
779  $page->doDeleteArticle( __METHOD__ );
780 
781  $db = wfGetDB( DB_MASTER );
782  $arQuery = $store->getArchiveQueryInfo();
783  $res = $db->select(
784  $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
785  __METHOD__, [], $arQuery['joins']
786  );
787  $this->assertTrue( is_object( $res ), 'query failed' );
788 
789  $row = $res->fetchObject();
790  $res->free();
791  $record = $store->newRevisionFromArchiveRow( $row );
792 
793  $this->assertRevisionRecordMatchesRevision( $orig, $record );
794  $this->assertSame( $text, $record->getContent( 'main' )->serialize() );
795  }
796 
800  public function testLoadRevisionFromId() {
801  $title = Title::newFromText( __METHOD__ );
802  $page = WikiPage::factory( $title );
804  $rev = $page->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ )
805  ->value['revision'];
806 
807  $store = MediaWikiServices::getInstance()->getRevisionStore();
808  $result = $store->loadRevisionFromId( wfGetDB( DB_MASTER ), $rev->getId() );
810  }
811 
815  public function testLoadRevisionFromPageId() {
816  $title = Title::newFromText( __METHOD__ );
817  $page = WikiPage::factory( $title );
819  $rev = $page->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ )
820  ->value['revision'];
821 
822  $store = MediaWikiServices::getInstance()->getRevisionStore();
823  $result = $store->loadRevisionFromPageId( wfGetDB( DB_MASTER ), $page->getId() );
825  }
826 
830  public function testLoadRevisionFromTitle() {
831  $title = Title::newFromText( __METHOD__ );
832  $page = WikiPage::factory( $title );
834  $rev = $page->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ )
835  ->value['revision'];
836 
837  $store = MediaWikiServices::getInstance()->getRevisionStore();
838  $result = $store->loadRevisionFromTitle( wfGetDB( DB_MASTER ), $title );
840  }
841 
845  public function testLoadRevisionFromTimestamp() {
846  $title = Title::newFromText( __METHOD__ );
847  $page = WikiPage::factory( $title );
849  $revOne = $page->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ )
850  ->value['revision'];
851  // Sleep to ensure different timestamps... )(evil)
852  sleep( 1 );
854  $revTwo = $page->doEditContent( new WikitextContent( __METHOD__ . 'a' ), '' )
855  ->value['revision'];
856 
857  $store = MediaWikiServices::getInstance()->getRevisionStore();
858  $this->assertNull(
859  $store->loadRevisionFromTimestamp( wfGetDB( DB_MASTER ), $title, '20150101010101' )
860  );
861  $this->assertSame(
862  $revOne->getId(),
863  $store->loadRevisionFromTimestamp(
864  wfGetDB( DB_MASTER ),
865  $title,
866  $revOne->getTimestamp()
867  )->getId()
868  );
869  $this->assertSame(
870  $revTwo->getId(),
871  $store->loadRevisionFromTimestamp(
872  wfGetDB( DB_MASTER ),
873  $title,
874  $revTwo->getTimestamp()
875  )->getId()
876  );
877  }
878 
882  public function testGetParentLengths() {
883  $page = WikiPage::factory( Title::newFromText( __METHOD__ ) );
885  $revOne = $page->doEditContent(
886  new WikitextContent( __METHOD__ ), __METHOD__
887  )->value['revision'];
889  $revTwo = $page->doEditContent(
890  new WikitextContent( __METHOD__ . '2' ), __METHOD__
891  )->value['revision'];
892 
893  $store = MediaWikiServices::getInstance()->getRevisionStore();
894  $this->assertSame(
895  [
896  $revOne->getId() => strlen( __METHOD__ ),
897  ],
898  $store->listRevisionSizes(
899  wfGetDB( DB_MASTER ),
900  [ $revOne->getId() ]
901  )
902  );
903  $this->assertSame(
904  [
905  $revOne->getId() => strlen( __METHOD__ ),
906  $revTwo->getId() => strlen( __METHOD__ ) + 1,
907  ],
908  $store->listRevisionSizes(
909  wfGetDB( DB_MASTER ),
910  [ $revOne->getId(), $revTwo->getId() ]
911  )
912  );
913  }
914 
918  public function testGetPreviousRevision() {
919  $page = WikiPage::factory( Title::newFromText( __METHOD__ ) );
921  $revOne = $page->doEditContent(
922  new WikitextContent( __METHOD__ ), __METHOD__
923  )->value['revision'];
925  $revTwo = $page->doEditContent(
926  new WikitextContent( __METHOD__ . '2' ), __METHOD__
927  )->value['revision'];
928 
929  $store = MediaWikiServices::getInstance()->getRevisionStore();
930  $this->assertNull(
931  $store->getPreviousRevision( $store->getRevisionById( $revOne->getId() ) )
932  );
933  $this->assertSame(
934  $revOne->getId(),
935  $store->getPreviousRevision( $store->getRevisionById( $revTwo->getId() ) )->getId()
936  );
937  }
938 
942  public function testGetNextRevision() {
943  $page = WikiPage::factory( Title::newFromText( __METHOD__ ) );
945  $revOne = $page->doEditContent(
946  new WikitextContent( __METHOD__ ), __METHOD__
947  )->value['revision'];
949  $revTwo = $page->doEditContent(
950  new WikitextContent( __METHOD__ . '2' ), __METHOD__
951  )->value['revision'];
952 
953  $store = MediaWikiServices::getInstance()->getRevisionStore();
954  $this->assertSame(
955  $revTwo->getId(),
956  $store->getNextRevision( $store->getRevisionById( $revOne->getId() ) )->getId()
957  );
958  $this->assertNull(
959  $store->getNextRevision( $store->getRevisionById( $revTwo->getId() ) )
960  );
961  }
962 
966  public function testGetTimestampFromId_found() {
967  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
969  $rev = $page->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ )
970  ->value['revision'];
971 
972  $store = MediaWikiServices::getInstance()->getRevisionStore();
973  $result = $store->getTimestampFromId(
974  $page->getTitle(),
975  $rev->getId()
976  );
977 
978  $this->assertSame( $rev->getTimestamp(), $result );
979  }
980 
985  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
987  $rev = $page->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ )
988  ->value['revision'];
989 
990  $store = MediaWikiServices::getInstance()->getRevisionStore();
991  $result = $store->getTimestampFromId(
992  $page->getTitle(),
993  $rev->getId() + 1
994  );
995 
996  $this->assertFalse( $result );
997  }
998 
1002  public function testCountRevisionsByPageId() {
1003  $store = MediaWikiServices::getInstance()->getRevisionStore();
1004  $page = WikiPage::factory( Title::newFromText( __METHOD__ ) );
1005 
1006  $this->assertSame(
1007  0,
1008  $store->countRevisionsByPageId( wfGetDB( DB_MASTER ), $page->getId() )
1009  );
1010  $page->doEditContent( new WikitextContent( 'a' ), 'a' );
1011  $this->assertSame(
1012  1,
1013  $store->countRevisionsByPageId( wfGetDB( DB_MASTER ), $page->getId() )
1014  );
1015  $page->doEditContent( new WikitextContent( 'b' ), 'b' );
1016  $this->assertSame(
1017  2,
1018  $store->countRevisionsByPageId( wfGetDB( DB_MASTER ), $page->getId() )
1019  );
1020  }
1021 
1025  public function testCountRevisionsByTitle() {
1026  $store = MediaWikiServices::getInstance()->getRevisionStore();
1027  $page = WikiPage::factory( Title::newFromText( __METHOD__ ) );
1028 
1029  $this->assertSame(
1030  0,
1031  $store->countRevisionsByTitle( wfGetDB( DB_MASTER ), $page->getTitle() )
1032  );
1033  $page->doEditContent( new WikitextContent( 'a' ), 'a' );
1034  $this->assertSame(
1035  1,
1036  $store->countRevisionsByTitle( wfGetDB( DB_MASTER ), $page->getTitle() )
1037  );
1038  $page->doEditContent( new WikitextContent( 'b' ), 'b' );
1039  $this->assertSame(
1040  2,
1041  $store->countRevisionsByTitle( wfGetDB( DB_MASTER ), $page->getTitle() )
1042  );
1043  }
1044 
1048  public function testUserWasLastToEdit_false() {
1049  $sysop = $this->getTestSysop()->getUser();
1050  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
1051  $page->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
1052 
1053  $store = MediaWikiServices::getInstance()->getRevisionStore();
1054  $result = $store->userWasLastToEdit(
1055  wfGetDB( DB_MASTER ),
1056  $page->getId(),
1057  $sysop->getId(),
1058  '20160101010101'
1059  );
1060  $this->assertFalse( $result );
1061  }
1062 
1066  public function testUserWasLastToEdit_true() {
1067  $startTime = wfTimestampNow();
1068  $sysop = $this->getTestSysop()->getUser();
1069  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
1070  $page->doEditContent(
1071  new WikitextContent( __METHOD__ ),
1072  __METHOD__,
1073  0,
1074  false,
1075  $sysop
1076  );
1077 
1078  $store = MediaWikiServices::getInstance()->getRevisionStore();
1079  $result = $store->userWasLastToEdit(
1080  wfGetDB( DB_MASTER ),
1081  $page->getId(),
1082  $sysop->getId(),
1083  $startTime
1084  );
1085  $this->assertTrue( $result );
1086  }
1087 
1091  public function testGetKnownCurrentRevision() {
1092  $page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
1094  $rev = $page->doEditContent(
1095  new WikitextContent( __METHOD__ . 'b' ),
1096  __METHOD__ . 'b',
1097  0,
1098  false,
1099  $this->getTestUser()->getUser()
1100  )->value['revision'];
1101 
1102  $store = MediaWikiServices::getInstance()->getRevisionStore();
1103  $record = $store->getKnownCurrentRevision(
1104  $page->getTitle(),
1105  $rev->getId()
1106  );
1107 
1108  $this->assertRevisionRecordMatchesRevision( $rev, $record );
1109  }
1110 
1112  yield 'Basic array, with page & id' => [
1113  [
1114  'id' => 2,
1115  'page' => 1,
1116  'text_id' => 2,
1117  'timestamp' => '20171017114835',
1118  'user_text' => '111.0.1.2',
1119  'user' => 0,
1120  'minor_edit' => false,
1121  'deleted' => 0,
1122  'len' => 46,
1123  'parent_id' => 1,
1124  'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1125  'comment' => 'Goat Comment!',
1126  'content_format' => 'text/x-wiki',
1127  'content_model' => 'wikitext',
1128  ]
1129  ];
1130  yield 'Basic array, content object' => [
1131  [
1132  'id' => 2,
1133  'page' => 1,
1134  'timestamp' => '20171017114835',
1135  'user_text' => '111.0.1.2',
1136  'user' => 0,
1137  'minor_edit' => false,
1138  'deleted' => 0,
1139  'len' => 46,
1140  'parent_id' => 1,
1141  'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1142  'comment' => 'Goat Comment!',
1143  'content' => new WikitextContent( 'Some Content' ),
1144  ]
1145  ];
1146  yield 'Basic array, serialized text' => [
1147  [
1148  'id' => 2,
1149  'page' => 1,
1150  'timestamp' => '20171017114835',
1151  'user_text' => '111.0.1.2',
1152  'user' => 0,
1153  'minor_edit' => false,
1154  'deleted' => 0,
1155  'len' => 46,
1156  'parent_id' => 1,
1157  'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1158  'comment' => 'Goat Comment!',
1159  'text' => ( new WikitextContent( 'Söme Content' ) )->serialize(),
1160  ]
1161  ];
1162  yield 'Basic array, serialized text, utf-8 flags' => [
1163  [
1164  'id' => 2,
1165  'page' => 1,
1166  'timestamp' => '20171017114835',
1167  'user_text' => '111.0.1.2',
1168  'user' => 0,
1169  'minor_edit' => false,
1170  'deleted' => 0,
1171  'len' => 46,
1172  'parent_id' => 1,
1173  'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1174  'comment' => 'Goat Comment!',
1175  'text' => ( new WikitextContent( 'Söme Content' ) )->serialize(),
1176  'flags' => 'utf-8',
1177  ]
1178  ];
1179  yield 'Basic array, with title' => [
1180  [
1181  'title' => Title::newFromText( 'SomeText' ),
1182  'text_id' => 2,
1183  'timestamp' => '20171017114835',
1184  'user_text' => '111.0.1.2',
1185  'user' => 0,
1186  'minor_edit' => false,
1187  'deleted' => 0,
1188  'len' => 46,
1189  'parent_id' => 1,
1190  'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1191  'comment' => 'Goat Comment!',
1192  'content_format' => 'text/x-wiki',
1193  'content_model' => 'wikitext',
1194  ]
1195  ];
1196  yield 'Basic array, no user field' => [
1197  [
1198  'id' => 2,
1199  'page' => 1,
1200  'text_id' => 2,
1201  'timestamp' => '20171017114835',
1202  'user_text' => '111.0.1.3',
1203  'minor_edit' => false,
1204  'deleted' => 0,
1205  'len' => 46,
1206  'parent_id' => 1,
1207  'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
1208  'comment' => 'Goat Comment!',
1209  'content_format' => 'text/x-wiki',
1210  'content_model' => 'wikitext',
1211  ]
1212  ];
1213  }
1214 
1219  public function testNewMutableRevisionFromArray( array $array ) {
1220  $store = MediaWikiServices::getInstance()->getRevisionStore();
1221 
1222  $result = $store->newMutableRevisionFromArray( $array );
1223 
1224  if ( isset( $array['id'] ) ) {
1225  $this->assertSame( $array['id'], $result->getId() );
1226  }
1227  if ( isset( $array['page'] ) ) {
1228  $this->assertSame( $array['page'], $result->getPageId() );
1229  }
1230  $this->assertSame( $array['timestamp'], $result->getTimestamp() );
1231  $this->assertSame( $array['user_text'], $result->getUser()->getName() );
1232  if ( isset( $array['user'] ) ) {
1233  $this->assertSame( $array['user'], $result->getUser()->getId() );
1234  }
1235  $this->assertSame( (bool)$array['minor_edit'], $result->isMinor() );
1236  $this->assertSame( $array['deleted'], $result->getVisibility() );
1237  $this->assertSame( $array['len'], $result->getSize() );
1238  $this->assertSame( $array['parent_id'], $result->getParentId() );
1239  $this->assertSame( $array['sha1'], $result->getSha1() );
1240  $this->assertSame( $array['comment'], $result->getComment()->text );
1241  if ( isset( $array['content'] ) ) {
1242  $this->assertTrue(
1243  $result->getSlot( 'main' )->getContent()->equals( $array['content'] )
1244  );
1245  } elseif ( isset( $array['text'] ) ) {
1246  $this->assertSame( $array['text'], $result->getSlot( 'main' )->getContent()->serialize() );
1247  } else {
1248  $this->assertSame(
1249  $array['content_format'],
1250  $result->getSlot( 'main' )->getContent()->getDefaultFormat()
1251  );
1252  $this->assertSame( $array['content_model'], $result->getSlot( 'main' )->getModel() );
1253  }
1254  }
1255 
1261  $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
1262  $blobStore = new SqlBlobStore( wfGetLB(), $cache );
1263  $blobStore->setLegacyEncoding( 'windows-1252', Language::factory( 'en' ) );
1264 
1265  $factory = $this->getMockBuilder( BlobStoreFactory::class )
1266  ->setMethods( [ 'newBlobStore', 'newSqlBlobStore' ] )
1267  ->disableOriginalConstructor()
1268  ->getMock();
1269  $factory->expects( $this->any() )
1270  ->method( 'newBlobStore' )
1271  ->willReturn( $blobStore );
1272  $factory->expects( $this->any() )
1273  ->method( 'newSqlBlobStore' )
1274  ->willReturn( $blobStore );
1275 
1276  $this->setService( 'BlobStoreFactory', $factory );
1277 
1278  $this->testNewMutableRevisionFromArray( $array );
1279  }
1280 
1281 }
MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromArchiveRow
testNewRevisionFromArchiveRow()
\MediaWiki\Storage\RevisionStore::newRevisionFromArchiveRow
Definition: RevisionStoreDbTest.php:740
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:247
MediaWiki\Tests\Storage\RevisionStoreDbTest\provideDomainCheck
provideDomainCheck()
Definition: RevisionStoreDbTest.php:78
Wikimedia\Rdbms\Database
Relational database abstraction object.
Definition: Database.php:48
CommentStoreComment\newUnsavedComment
static newUnsavedComment( $comment, array $data=null)
Create a new, unsaved CommentStoreComment.
Definition: CommentStoreComment.php:65
MediaWiki\Storage\RevisionRecord\getVisibility
getVisibility()
Get the deletion bitfield of the revision.
Definition: RevisionRecord.php:381
MediaWiki\Linker\LinkTarget\getInterwiki
getInterwiki()
The interwiki component of this LinkTarget.
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:273
MediaWiki\Storage\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:69
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRevisionByPageId
testGetRevisionByPageId()
\MediaWiki\Storage\RevisionStore::getRevisionByPageId
Definition: RevisionStoreDbTest.php:559
MediaWiki\Storage\SlotRecord\getSha1
getSha1()
Returns the content size.
Definition: SlotRecord.php:495
MediaWiki\Tests\Storage\RevisionStoreDbTest\testInsertRevisionOn_failures
testInsertRevisionOn_failures(Title $title, array $revDetails=[], Exception $exception)
provideInsertRevisionOn_failures \MediaWiki\Storage\RevisionStore::insertRevisionOn
Definition: RevisionStoreDbTest.php:382
Wikimedia\Rdbms\DatabaseSqlite
Definition: DatabaseSqlite.php:37
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
MediaWiki\Storage\SlotRecord\getRevision
getRevision()
Returns the ID of the revision this slot is associated with.
Definition: SlotRecord.php:390
HashBagOStuff
Simple store for keeping values in an associative array for the current process.
Definition: HashBagOStuff.php:31
MediaWiki\Storage\RevisionRecord\getSlot
getSlot( $role, $audience=self::FOR_PUBLIC, User $user=null)
Returns meta-data for the given slot.
Definition: RevisionRecord.php:189
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetNextRevision
testGetNextRevision()
\MediaWiki\Storage\RevisionStore::getNextRevision
Definition: RevisionStoreDbTest.php:942
MediaWiki\Tests\Storage\RevisionStoreDbTest\getRandomCommentStoreComment
getRandomCommentStoreComment()
Definition: RevisionStoreDbTest.php:244
MediaWikiTestCase\getTestUser
static getTestUser( $groups=[])
Convenience method for getting an immutable test user.
Definition: MediaWikiTestCase.php:153
array
the array() calling protocol came about after MediaWiki 1.4rc1.
MediaWiki\Storage\SlotRecord\getContent
getContent()
Returns the Content of the given slot.
Definition: SlotRecord.php:303
wfGetLB
wfGetLB( $wiki=false)
Get a load balancer object.
Definition: GlobalFunctions.php:2825
TestUserRegistry
Definition: TestUserRegistry.php:6
MediaWiki\Tests\Storage\RevisionStoreDbTest\testDomainCheck
testDomainCheck( $wikiId, $dbName, $dbPrefix)
provideDomainCheck \MediaWiki\Storage\RevisionStore::checkDatabaseWikiId
Definition: RevisionStoreDbTest.php:96
MediaWiki\Storage\SlotRecord\getModel
getModel()
Returns the content model.
Definition: SlotRecord.php:518
MediaWiki\Storage\SqlBlobStore
Service for storing and loading Content objects.
Definition: SqlBlobStore.php:50
string
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition: hooks.txt:181
MediaWiki\Tests\Storage\RevisionStoreDbTest\assertSlotCompleteness
assertSlotCompleteness(RevisionRecord $r, SlotRecord $slot)
Definition: RevisionStoreDbTest.php:204
MediaWiki\Tests\Storage\RevisionStoreDbTest\testUserWasLastToEdit_false
testUserWasLastToEdit_false()
\MediaWiki\Storage\RevisionStore::userWasLastToEdit
Definition: RevisionStoreDbTest.php:1048
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:37
$params
$params
Definition: styleTest.css.php:40
MediaWiki\Storage\RevisionRecord\getWikiId
getWikiId()
Get the ID of the wiki this revision belongs to.
Definition: RevisionRecord.php:290
MIGRATION_WRITE_BOTH
const MIGRATION_WRITE_BOTH
Definition: Defines.php:303
serialize
serialize()
Definition: ApiMessage.php:184
MediaWiki\Tests\Storage\RevisionStoreDbTest
Database.
Definition: RevisionStoreDbTest.php:35
$res
$res
Definition: database.txt:21
MediaWiki\Storage\SlotRecord\getFormat
getFormat()
Returns the blob serialization format as a MIME type.
Definition: SlotRecord.php:538
$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. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. '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. '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
Definition: hooks.txt:1993
MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordMatchesRevision
assertRevisionRecordMatchesRevision(Revision $rev, RevisionRecord $record)
Definition: RevisionStoreDbTest.php:629
Wikimedia\Rdbms\FakeResultWrapper
Overloads the relevant methods of the real ResultsWrapper so it doesn't go anywhere near an actual da...
Definition: FakeResultWrapper.php:11
MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_userEdit
testNewRevisionFromRow_userEdit()
\MediaWiki\Storage\RevisionStore::newRevisionFromRow \MediaWiki\Storage\RevisionStore::newRevisionFro...
Definition: RevisionStoreDbTest.php:712
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetKnownCurrentRevision
testGetKnownCurrentRevision()
\MediaWiki\Storage\RevisionStore::getKnownCurrentRevision
Definition: RevisionStoreDbTest.php:1091
MediaWiki\Tests\Storage\RevisionStoreDbTest\testLoadRevisionFromTimestamp
testLoadRevisionFromTimestamp()
\MediaWiki\Storage\RevisionStore::loadRevisionFromTimestamp
Definition: RevisionStoreDbTest.php:845
MediaWiki\Tests\Storage\RevisionStoreDbTest\testCountRevisionsByTitle
testCountRevisionsByTitle()
\MediaWiki\Storage\RevisionStore::countRevisionsByTitle
Definition: RevisionStoreDbTest.php:1025
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:37
MediaWiki\Tests\Storage\RevisionStoreDbTest\testInsertRevisionOn_blobAddressExists
testInsertRevisionOn_blobAddressExists()
\MediaWiki\Storage\RevisionStore::insertRevisionOn
Definition: RevisionStoreDbTest.php:292
MediaWikiTestCase\overrideMwServices
overrideMwServices(Config $configOverrides=null, array $services=[])
Stashes the global instance of MediaWikiServices, and installs a new one, allowing test cases to over...
Definition: MediaWikiTestCase.php:845
Revision
Definition: Revision.php:41
MediaWiki\Storage\RevisionRecord\getComment
getComment( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision comment, if it's available to the specified audience.
Definition: RevisionRecord.php:346
MediaWiki\Storage\SlotRecord\hasAddress
hasAddress()
Whether this slot has an address.
Definition: SlotRecord.php:429
MediaWiki\Linker\LinkTarget\getNamespace
getNamespace()
Get the namespace index.
MediaWiki\Storage\RevisionRecord\getUser
getUser( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's author's user identity, if it's available to the specified audience.
Definition: RevisionRecord.php:321
MediaWiki\Tests\Storage
Definition: BlobStoreFactoryTest.php:3
MediaWiki\Tests\Storage\RevisionStoreDbTest\provideNewNullRevision
provideNewNullRevision()
Definition: RevisionStoreDbTest.php:398
MediaWiki\Storage\RevisionRecord\getSlotRoles
getSlotRoles()
Returns the slot names (roles) of all slots present in this revision.
Definition: RevisionRecord.php:216
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRcIdIfUnpatrolled_returnsRecentChangesId
testGetRcIdIfUnpatrolled_returnsRecentChangesId()
\MediaWiki\Storage\RevisionStore::getRcIdIfUnpatrolled
Definition: RevisionStoreDbTest.php:461
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:115
MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_anonEdit
testNewRevisionFromRow_anonEdit()
\MediaWiki\Storage\RevisionStore::newRevisionFromRow \MediaWiki\Storage\RevisionStore::newRevisionFro...
Definition: RevisionStoreDbTest.php:661
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2812
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:678
MediaWikiTestCase
Definition: MediaWikiTestCase.php:17
MediaWiki\Storage\RevisionRecord\getSha1
getSha1()
Returns the base36 sha1 of this revision.
MediaWiki\Tests\Storage\RevisionStoreDbTest\setUp
setUp()
Definition: RevisionStoreDbTest.php:37
MediaWiki\Storage\SlotRecord\newUnsaved
static newUnsaved( $role, Content $content)
Constructs a new Slot from a Content object for a new revision.
Definition: SlotRecord.php:124
MediaWiki\Tests\Storage\RevisionStoreDbTest\revisionToRow
revisionToRow(Revision $rev)
Definition: RevisionStoreDbTest.php:599
MediaWiki\Tests\Storage\RevisionStoreDbTest\testUserWasLastToEdit_true
testUserWasLastToEdit_true()
\MediaWiki\Storage\RevisionStore::userWasLastToEdit
Definition: RevisionStoreDbTest.php:1066
MediaWiki\Storage\SlotRecord\newInherited
static newInherited(SlotRecord $slot)
Constructs a new SlotRecord for a new revision, inheriting the content of the given SlotRecord of a p...
Definition: SlotRecord.php:98
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
MediaWiki\Storage\BlobStoreFactory
Service for instantiating BlobStores.
Definition: BlobStoreFactory.php:35
MediaWiki\Storage\SlotRecord\getRole
getRole()
Returns the role of the slot.
Definition: SlotRecord.php:449
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRevisionById
testGetRevisionById()
\MediaWiki\Storage\RevisionStore::getRevisionById
Definition: RevisionStoreDbTest.php:523
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
wfTimestampNow
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Definition: GlobalFunctions.php:2009
MediaWiki\Tests\Storage\RevisionStoreDbTest\testInsertRevisionOn_successes
testInsertRevisionOn_successes(Title $title, array $revDetails=[])
provideInsertRevisionOn_successes \MediaWiki\Storage\RevisionStore::insertRevisionOn
Definition: RevisionStoreDbTest.php:278
MediaWiki\Storage\RevisionRecord\getParentId
getParentId()
Get parent revision ID (the original previous page revision).
Definition: RevisionRecord.php:245
DB_MASTER
const DB_MASTER
Definition: defines.php:26
WikitextContent
Content object for wiki text pages.
Definition: WikitextContent.php:33
MediaWiki\Tests\Storage\RevisionStoreDbTest\provideInsertRevisionOn_successes
provideInsertRevisionOn_successes()
Definition: RevisionStoreDbTest.php:248
MediaWiki\Storage\RevisionRecord
Page revision base class.
Definition: RevisionRecord.php:44
MediaWiki\Tests\Storage\RevisionStoreDbTest\getLoadBalancerMock
getLoadBalancerMock(array $server)
Definition: RevisionStoreDbTest.php:48
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetTimestampFromId_found
testGetTimestampFromId_found()
\MediaWiki\Storage\RevisionStore::getTimestampFromId
Definition: RevisionStoreDbTest.php:966
Wikimedia\Rdbms\LoadBalancer
Database connection, tracking, load balancing, and transaction manager for a cluster.
Definition: LoadBalancer.php:41
MediaWiki\Storage\RevisionRecord\getPageAsLinkTarget
getPageAsLinkTarget()
Returns the title of the page this revision is associated with as a LinkTarget object.
Definition: RevisionRecord.php:301
Revision\getTitle
getTitle()
Returns the title of the page associated with this entry.
Definition: Revision.php:734
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
Definition: MediaWikiServices.php:109
MediaWiki\Tests\Storage\RevisionStoreDbTest\provideNewMutableRevisionFromArray
provideNewMutableRevisionFromArray()
Definition: RevisionStoreDbTest.php:1111
MediaWiki\Storage\SlotRecord\hasRevision
hasRevision()
Whether this slot has revision ID associated.
Definition: SlotRecord.php:440
MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionCompleteness
assertRevisionCompleteness(RevisionRecord $r)
Definition: RevisionStoreDbTest.php:198
MediaWiki\Tests\Storage\RevisionStoreDbTest\getDatabaseMock
getDatabaseMock(array $params)
Definition: RevisionStoreDbTest.php:66
MediaWiki\Storage\RevisionRecord\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: RevisionRecord.php:50
WANObjectCache
Multi-datacenter aware caching interface.
Definition: WANObjectCache.php:87
MediaWiki\Linker\LinkTarget\getDBkey
getDBkey()
Get the main part with underscores.
MediaWikiTestCase\getTestSysop
static getTestSysop()
Convenience method for getting an immutable admin test user.
Definition: MediaWikiTestCase.php:177
MediaWiki\Linker\LinkTarget\getFragment
getFragment()
Get the link fragment (i.e.
$status
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action or null $user:User who performed the tagging when the tagging is subsequent to the action or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
Definition: hooks.txt:1255
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRevisionByTitle
testGetRevisionByTitle()
\MediaWiki\Storage\RevisionStore::getRevisionByTitle
Definition: RevisionStoreDbTest.php:541
MediaWiki\Storage\RevisionRecord\DELETED_COMMENT
const DELETED_COMMENT
Definition: RevisionRecord.php:48
MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewMutableRevisionFromArray_legacyEncoding
testNewMutableRevisionFromArray_legacyEncoding(array $array)
provideNewMutableRevisionFromArray \MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray
Definition: RevisionStoreDbTest.php:1260
MediaWiki\Tests\Storage\RevisionStoreDbTest\assertSlotRecordsEqual
assertSlotRecordsEqual(SlotRecord $s1, SlotRecord $s2)
Definition: RevisionStoreDbTest.php:186
MediaWiki\Storage\RevisionRecord\getSize
getSize()
Returns the nominal size of this revision, in bogo-bytes.
$rev
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1777
MediaWiki\Tests\Storage\RevisionStoreDbTest\getRevisionRecordFromDetailsArray
getRevisionRecordFromDetailsArray( $title, $details=[])
Definition: RevisionStoreDbTest.php:214
Title
Represents a title within MediaWiki.
Definition: Title.php:39
MediaWiki\Storage\MutableRevisionRecord
Mutable RevisionRecord implementation, for building new revision entries programmatically.
Definition: MutableRevisionRecord.php:39
MediaWiki\Tests\Storage\RevisionStoreDbTest\assertLinkTargetsEqual
assertLinkTargetsEqual(LinkTarget $l1, LinkTarget $l2)
Definition: RevisionStoreDbTest.php:151
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetPreviousRevision
testGetPreviousRevision()
\MediaWiki\Storage\RevisionStore::getPreviousRevision
Definition: RevisionStoreDbTest.php:918
$cache
$cache
Definition: mcc.php:33
MediaWiki\Tests\Storage\RevisionStoreDbTest\testCountRevisionsByPageId
testCountRevisionsByPageId()
\MediaWiki\Storage\RevisionStore::countRevisionsByPageId
Definition: RevisionStoreDbTest.php:1002
MediaWiki\Storage\IncompleteRevisionException
Exception throw when trying to access undefined fields on an incomplete RevisionRecord.
Definition: IncompleteRevisionException.php:30
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetTimestampFromId_notFound
testGetTimestampFromId_notFound()
\MediaWiki\Storage\RevisionStore::getTimestampFromId
Definition: RevisionStoreDbTest.php:984
MediaWiki\Storage\SlotRecord
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:38
MediaWiki\Storage\RevisionRecord\DELETED_USER
const DELETED_USER
Definition: RevisionRecord.php:49
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:22
MediaWiki\Storage\RevisionRecord\getTimestamp
getTimestamp()
MCR migration note: this replaces Revision::getTimestamp.
Definition: RevisionRecord.php:392
MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewMutableRevisionFromArray
testNewMutableRevisionFromArray(array $array)
provideNewMutableRevisionFromArray \MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray
Definition: RevisionStoreDbTest.php:1219
MediaWiki\Storage\RevisionRecord\DELETED_TEXT
const DELETED_TEXT
Definition: RevisionRecord.php:47
MediaWiki\Storage\SlotRecord\getSize
getSize()
Returns the content size.
Definition: SlotRecord.php:479
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRcIdIfUnpatrolled_returnsZeroIfPatrolled
testGetRcIdIfUnpatrolled_returnsZeroIfPatrolled()
\MediaWiki\Storage\RevisionStore::getRcIdIfUnpatrolled
Definition: RevisionStoreDbTest.php:481
MediaWiki\Tests\Storage\RevisionStoreDbTest\testLoadRevisionFromId
testLoadRevisionFromId()
\MediaWiki\Storage\RevisionStore::loadRevisionFromId
Definition: RevisionStoreDbTest.php:800
MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewNullRevision
testNewNullRevision(Title $title, $comment, $minor)
provideNewNullRevision \MediaWiki\Storage\RevisionStore::newNullRevision
Definition: RevisionStoreDbTest.php:415
MediaWiki\Tests\Storage\RevisionStoreDbTest\testLoadRevisionFromTitle
testLoadRevisionFromTitle()
\MediaWiki\Storage\RevisionStore::loadRevisionFromTitle
Definition: RevisionStoreDbTest.php:830
MediaWiki\Storage\RevisionRecord\isDeleted
isDeleted( $field)
MCR migration note: this replaces Revision::isDeleted.
Definition: RevisionRecord.php:370
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:183
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:56
TestUserRegistry\getMutableTestUser
static getMutableTestUser( $testName, $groups=[])
Get a TestUser object that the caller may modify.
Definition: TestUserRegistry.php:34
MediaWiki\Storage\RevisionRecord\getId
getId()
Get revision ID.
Definition: RevisionRecord.php:229
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:25
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
Wikimedia\Rdbms\TransactionProfiler
Helper class that detects high-contention DB queries via profiling calls.
Definition: TransactionProfiler.php:38
MediaWiki\Tests\Storage\RevisionStoreDbTest\assertRevisionRecordsEqual
assertRevisionRecordsEqual(RevisionRecord $r1, RevisionRecord $r2)
Definition: RevisionStoreDbTest.php:158
MediaWikiTestCase\setService
setService( $name, $object)
Sets a service, maintaining a stashed version of the previous service to be restored in tearDown.
Definition: MediaWikiTestCase.php:628
MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewNullRevision_nonExistingTitle
testNewNullRevision_nonExistingTitle()
\MediaWiki\Storage\RevisionStore::newNullRevision
Definition: RevisionStoreDbTest.php:446
MediaWiki\Storage\RevisionRecord\getContent
getContent( $role, $audience=self::FOR_PUBLIC, User $user=null)
Returns the Content of the given slot of this revision.
Definition: RevisionRecord.php:165
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRevisionByTimestamp
testGetRevisionByTimestamp()
\MediaWiki\Storage\RevisionStore::getRevisionByTimestamp
Definition: RevisionStoreDbTest.php:577
MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromRow_anonEdit_legacyEncoding
testNewRevisionFromRow_anonEdit_legacyEncoding()
\MediaWiki\Storage\RevisionStore::newRevisionFromRow \MediaWiki\Storage\RevisionStore::newRevisionFro...
Definition: RevisionStoreDbTest.php:687
CommentStoreComment
CommentStoreComment represents a comment stored by CommentStore.
Definition: CommentStoreComment.php:28
MediaWiki\Tests\Storage\RevisionStoreDbTest\testNewRevisionFromArchiveRow_legacyEncoding
testNewRevisionFromArchiveRow_legacyEncoding()
\MediaWiki\Storage\RevisionStore::newRevisionFromArchiveRow
Definition: RevisionStoreDbTest.php:769
Language
Internationalisation code.
Definition: Language.php:35
MediaWiki\Tests\Storage\RevisionStoreDbTest\provideInsertRevisionOn_failures
provideInsertRevisionOn_failures()
Definition: RevisionStoreDbTest.php:329
MediaWiki\Storage\RevisionRecord\isMinor
isMinor()
MCR migration note: this replaces Revision::isMinor.
Definition: RevisionRecord.php:359
MediaWiki\Tests\Storage\RevisionStoreDbTest\testLoadRevisionFromPageId
testLoadRevisionFromPageId()
\MediaWiki\Storage\RevisionStore::loadRevisionFromPageId
Definition: RevisionStoreDbTest.php:815
MediaWikiTestCase\$db
Database $db
Primary database.
Definition: MediaWikiTestCase.php:57
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetParentLengths
testGetParentLengths()
\MediaWiki\Storage\RevisionStore::listRevisionSizes
Definition: RevisionStoreDbTest.php:882
MediaWiki\Storage\RevisionRecord\getPageId
getPageId()
Get the page ID.
Definition: RevisionRecord.php:281
MediaWiki\Tests\Storage\RevisionStoreDbTest\testGetRecentChange
testGetRecentChange()
\MediaWiki\Storage\RevisionStore::getRecentChange
Definition: RevisionStoreDbTest.php:505