20 public function __construct( $name =
null, array $data = [], $dataName =
'' ) {
21 parent::__construct( $name, $data, $dataName );
23 $this->tablesUsed = array_merge( $this->tablesUsed,
55 12313 =>
'Dummy_talk',
60 'wgNamespaceContentModels',
76 MWNamespace::clearCaches();
80 if ( !$this->testPage ) {
85 $this->testPage = $this->
createPage( __CLASS__, __CLASS__ );
94 MWNamespace::clearCaches();
102 if ( $props ===
null ) {
106 if ( !isset( $props[
'content'] ) && !isset( $props[
'text'] ) ) {
107 $props[
'text'] =
'Lorem Ipsum';
110 if ( !isset( $props[
'user_text'] ) ) {
112 $props[
'user_text'] = $user->getName();
113 $props[
'user'] = $user->getId();
116 if ( !isset( $props[
'user'] ) ) {
120 if ( !isset( $props[
'comment'] ) ) {
121 $props[
'comment'] =
'just a test';
124 if ( !isset( $props[
'page'] ) ) {
125 $props[
'page'] = $this->testPage->getId();
128 if ( !isset( $props[
'content_model'] ) ) {
135 $rev->insertOn( $dbw );
147 private function createPage( $titleString, $text, $model =
null ) {
148 if ( !preg_match(
'/:/', $titleString ) &&
152 $titleString = MWNamespace::getCanonicalName( $ns ) .
':' . $titleString;
155 $title = Title::newFromText( $titleString );
159 if ( $wikipage->exists() ) {
160 $wikipage->doDeleteArticle(
"done" );
163 $content = ContentHandler::makeContent( $text, $title, $model );
164 $wikipage->doEditContent( $content, __METHOD__,
EDIT_NEW );
170 $this->assertNotNull(
$rev,
'missing revision' );
172 $this->assertEquals( $orig->
getId(),
$rev->getId() );
173 $this->assertEquals( $orig->
getPage(),
$rev->getPage() );
175 $this->assertEquals( $orig->
getUser(),
$rev->getUser() );
178 $this->assertEquals( $orig->
getSha1(),
$rev->getSha1() );
185 $rev = $this->testPage->getRevision();
186 $recentChange =
$rev->getRecentChange();
189 $this->assertEquals(
$rev->getTimestamp(), $recentChange->getAttribute(
'rc_timestamp' ) );
191 $rev->getTitle()->getNamespace(),
192 $recentChange->getAttribute(
'rc_namespace' )
195 $rev->getTitle()->getDBkey(),
196 $recentChange->getAttribute(
'rc_title' )
198 $this->assertEquals(
$rev->getUser(), $recentChange->getAttribute(
'rc_user' ) );
199 $this->assertEquals(
$rev->getUserText(), $recentChange->getAttribute(
'rc_user_text' ) );
200 $this->assertEquals(
$rev->getComment(), $recentChange->getAttribute(
'rc_comment' ) );
201 $this->assertEquals(
$rev->getPage(), $recentChange->getAttribute(
'rc_cur_id' ) );
202 $this->assertEquals(
$rev->getId(), $recentChange->getAttribute(
'rc_this_oldid' ) );
209 $parentId = $this->testPage->getLatest();
215 'page' => $this->testPage->getId(),
216 'title' => $this->testPage->getTitle(),
217 'text' =>
'Revision Text',
218 'comment' =>
'Revision comment',
223 $this->assertInternalType(
'integer', $revId );
224 $this->assertSame( $revId,
$rev->getId() );
227 $this->assertInternalType(
'integer',
$rev->getTextId() );
229 $mainSlot =
$rev->getRevisionRecord()->getSlot(
'main', RevisionRecord::RAW );
232 $textId = MediaWikiServices::getInstance()
234 ->getTextIdFromAddress( $mainSlot->getAddress() );
238 [
'old_id',
'old_text' ],
240 [ [ strval( $textId ),
'Revision Text' ] ]
254 "rev_id = {$rev->getId()}",
256 strval(
$rev->getId() ),
257 strval( $this->testPage->getId() ),
263 's0ngbdoxagreuf2vjtuxzwdz64n29xm',
274 $this->setExpectedException(
275 IncompleteRevisionException::class,
276 "rev_page field must not be 0!"
279 $title = Title::newFromText(
'Nonexistant-' . __METHOD__ );
289 $latestRevId = $this->testPage->getLatest();
291 $rev = Revision::newFromTitle( $this->testPage->getTitle() );
293 $this->assertTrue( $this->testPage->getTitle()->equals(
$rev->getTitle() ) );
294 $this->assertEquals( $latestRevId,
$rev->getId() );
301 $latestRevId = $this->testPage->getLatest();
303 $rev = Revision::newFromTitle( $this->testPage->getTitle(), $latestRevId );
305 $this->assertTrue( $this->testPage->getTitle()->equals(
$rev->getTitle() ) );
306 $this->assertEquals( $latestRevId,
$rev->getId() );
313 $latestRevId = $this->testPage->getLatest();
315 $rev = Revision::newFromTitle( $this->testPage->getTitle(), $latestRevId + 1 );
317 $this->assertNull(
$rev );
330 $this->assertTrue( is_object(
$res ),
'query failed' );
332 $row =
$res->fetchObject();
335 $rev = Revision::newFromRow( $row );
348 return $f + [
'ar_namespace',
'ar_title' ];
353 unset( $f[
'ar_text_id'] );
359 unset( $f[
'ar_page_id'] );
365 unset( $f[
'ar_parent_id'] );
371 unset( $f[
'ar_rev_id'] );
377 unset( $f[
'ar_sha1'] );
388 $services = MediaWikiServices::getInstance();
392 $services->getService(
'_SqlBlobStore' ),
402 'RevisionStorageTest_testNewFromArchiveRow',
406 $orig = $page->getRevision();
407 $page->doDeleteArticle(
'test Revision::newFromArchiveRow' );
410 $arQuery = Revision::getArchiveQueryInfo();
411 $arQuery[
'fields'] = $selectModifier( $arQuery[
'fields'] );
413 $arQuery[
'tables'], $arQuery[
'fields'], [
'ar_rev_id' => $orig->getId() ],
414 __METHOD__, [], $arQuery[
'joins']
416 $this->assertTrue( is_object(
$res ),
'query failed' );
418 $row =
$res->fetchObject();
423 $rev = Revision::newFromArchiveRow( $row );
433 'RevisionStorageTest_testNewFromArchiveRow',
437 $orig = $page->getRevision();
438 $page->doDeleteArticle(
'test Revision::newFromArchiveRow' );
441 $arQuery = Revision::getArchiveQueryInfo();
443 $arQuery[
'tables'], $arQuery[
'fields'], [
'ar_rev_id' => $orig->getId() ],
444 __METHOD__, [], $arQuery[
'joins']
446 $this->assertTrue( is_object(
$res ),
'query failed' );
448 $row =
$res->fetchObject();
451 $rev = Revision::newFromArchiveRow( $row, [
'comment_text' =>
'SOMEOVERRIDE' ] );
453 $this->assertNotEquals( $orig->getComment(),
$rev->getComment() );
454 $this->assertEquals(
'SOMEOVERRIDE',
$rev->getComment() );
461 $orig = $this->testPage->getRevision();
462 $rev = Revision::newFromId( $orig->getId() );
470 $rev = Revision::newFromPageId( $this->testPage->getId() );
472 $this->testPage->getRevision(),
481 $rev = Revision::newFromPageId(
482 $this->testPage->getId(),
483 $this->testPage->getLatest()
486 $this->testPage->getRevision(),
496 $this->testPage->doEditContent( $content, __METHOD__ );
497 $rev = Revision::newFromPageId(
498 $this->testPage->getId(),
499 $this->testPage->getRevision()->getPrevious()->getId()
502 $this->testPage->getRevision()->getPrevious(),
512 $this->testPage->getRevision()->getId();
514 $this->testPage->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ );
515 $id = $this->testPage->getRevision()->getId();
518 $res = Revision::fetchRevision( $this->testPage->getTitle() );
520 # note: order is unspecified
522 while ( ( $row =
$res->fetchObject() ) ) {
523 $rows[$row->rev_id] = $row;
526 $this->assertEmpty(
$rows,
'expected empty set' );
536 $rev = Revision::newFromId( $orig->getId() );
538 $this->assertEquals( $page->getId(),
$rev->getPage() );
545 $rev1 = $this->testPage->getRevision();
547 # @todo find out if this should be true
548 # $this->assertTrue( $rev1->isCurrent() );
550 $rev1x = Revision::newFromId( $rev1->getId() );
551 $this->assertTrue( $rev1x->isCurrent() );
553 $this->testPage->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ );
554 $rev2 = $this->testPage->getRevision();
556 # @todo find out if this should be true
557 # $this->assertTrue( $rev2->isCurrent() );
559 $rev1x = Revision::newFromId( $rev1->getId() );
560 $this->assertFalse( $rev1x->isCurrent() );
562 $rev2x = Revision::newFromId( $rev2->getId() );
563 $this->assertTrue( $rev2x->isCurrent() );
570 $oldestRevision = $this->testPage->getOldestRevision();
571 $latestRevision = $this->testPage->getLatest();
573 $this->assertNull( $oldestRevision->getPrevious() );
575 $this->testPage->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ );
576 $newRevision = $this->testPage->getRevision();
578 $this->assertNotNull( $newRevision->getPrevious() );
579 $this->assertEquals( $latestRevision, $newRevision->getPrevious()->getId() );
586 $rev1 = $this->testPage->getRevision();
588 $this->assertNull( $rev1->getNext() );
590 $this->testPage->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ );
591 $rev2 = $this->testPage->getRevision();
593 $this->assertNotNull( $rev1->getNext() );
594 $this->assertEquals( $rev2->getId(), $rev1->getNext()->getId() );
601 $this->testPage->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ );
602 $orig = $this->testPage->getRevision();
605 $rev = Revision::newNullRevision( $dbw, $this->testPage->getId(),
'a null revision',
false );
607 $this->assertNotEquals( $orig->getId(),
$rev->getId(),
608 'new null revision should have a different id from the original revision' );
609 $this->assertEquals( $orig->getTextId(),
$rev->getTextId(),
610 'new null revision should have the same text id as the original revision' );
611 $this->assertEquals( $orig->getSha1(),
$rev->getSha1(),
612 'new null revision should have the same SHA1 as the original revision' );
613 $this->assertTrue( $orig->getRevisionRecord()->hasSameContent(
$rev->getRevisionRecord() ),
614 'new null revision should have the same content as the original revision' );
615 $this->assertEquals( __METHOD__,
$rev->getContent()->getNativeData() );
623 $rev = Revision::newNullRevision( $dbw, -1,
'a null revision',
false );
625 $this->assertNull(
$rev );
632 $ip =
'2600:387:ed7:947e:8c16:a1ad:dd34:1dd7';
640 $res =
$dbr->select(
'ip_changes',
'*', [
'ipc_rev_id' => $orig->getId() ] );
641 $row =
$res->fetchObject();
643 $this->assertEquals( IP::toHex( $ip ), $row->ipc_hex );
645 $orig->getTimestamp(),
651 yield
'actually the last edit' => [ 3,
true ];
652 yield
'not the current edit, but still by this user' => [ 2,
true ];
653 yield
'edit by another user' => [ 1,
false ];
654 yield
'first edit, by this user, but another user edited in the mean time' => [ 0,
false ];
665 if ( $userA->getId() === 0 ) {
669 if ( $userB->getId() === 0 ) {
679 $page = WikiPage::factory( Title::newFromText(
680 'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
681 $page->insertOn( $dbw );
684 'page' => $page->getId(),
686 'title' => $page->getTitle(),
687 'timestamp' =>
'20120101000000',
688 'user' => $userA->getId(),
691 'comment' =>
'edit zero'
693 $revisions[0]->insertOn( $dbw );
696 'page' => $page->getId(),
698 'title' => $page->getTitle(),
699 'timestamp' =>
'20120101000100',
700 'user' => $userA->getId(),
703 'comment' =>
'edit one'
705 $revisions[1]->insertOn( $dbw );
708 'page' => $page->getId(),
709 'title' => $page->getTitle(),
710 'timestamp' =>
'20120101000200',
711 'user' => $userB->getId(),
714 'comment' =>
'edit two'
716 $revisions[2]->insertOn( $dbw );
719 'page' => $page->getId(),
720 'title' => $page->getTitle(),
721 'timestamp' =>
'20120101000300',
722 'user' => $userA->getId(),
725 'comment' =>
'edit three'
727 $revisions[3]->insertOn( $dbw );
730 'page' => $page->getId(),
731 'title' => $page->getTitle(),
732 'timestamp' =>
'20120101000200',
733 'user' => $userA->getId(),
736 'comment' =>
'edit four'
738 $revisions[4]->insertOn( $dbw );
741 $since = $revisions[$sinceIdx]->getTimestamp();
744 $allRows = iterator_to_array( $dbw->select(
746 [
'rev_id',
'rev_timestamp',
'rev_user' =>
$revQuery[
'fields'][
'rev_user'] ],
748 'rev_page' => $page->getId(),
752 [
'ORDER BY' =>
'rev_timestamp ASC',
'LIMIT' => 50 ],
756 $wasLast = Revision::userWasLastToEdit( $dbw, $page->getId(), $userA->getId(), $since );
758 $this->assertEquals( $expectedLast, $wasLast );
772 if ( is_string( $title ) ) {
773 $title = Title::newFromText( $title );
776 $content = ContentHandler::makeContent( $text, $title, $model, $format );
784 'content' => $content,
785 'length' => $content->getSize(),
786 'comment' =>
"testing",
787 'minor_edit' =>
false,
789 'content_format' => $format,
812 $this->assertEquals( $expectedModel,
$rev->getContentModel() );
832 $this->assertEquals( $expectedFormat,
$rev->getContentFormat() );
838 [
'hello world',
'Help:Hello',
null,
null, WikitextContentHandler::class ],
839 [
'hello world',
'User:hello/there.css',
null,
null, CssContentHandler::class ],
840 [
serialize(
'hello world' ),
'Dummy:Hello',
null,
null, DummyContentHandlerForTesting::class ],
851 $this->assertEquals( $expectedClass, get_class(
$rev->getContentHandler() ) );
857 [
'hello world',
'Help:Hello',
null,
null, Revision::FOR_PUBLIC,
'hello world' ],
863 Revision::FOR_PUBLIC,
871 Revision::FOR_PUBLIC,
882 $audience, $expectedSerialization
885 $content =
$rev->getContent( $audience );
888 $expectedSerialization,
889 is_null( $content ) ?
null : $content->serialize( $format )
898 'page' => $this->testPage->getId(),
899 'content_model' => $this->testPage->getContentModel(),
900 'text_id' => 123456789,
903 Wikimedia\suppressWarnings();
905 $this->assertNull(
$rev->getContent(),
906 "getContent() should return null if the revision's text blob could not be loaded." );
909 $this->assertNull(
$rev->getContent(),
910 "getContent() should return null if the revision's text blob could not be loaded." );
912 Wikimedia\restoreWarnings();
928 $this->assertEquals( $expected_size,
$rev->getSize() );
937 Revision::base36Sha1(
serialize(
"hello world." ) )
948 $this->assertEquals( $expected_hash,
$rev->getSha1() );
963 'title' => Title::newFromText(
"testGetContentClone_dummy" ),
965 'content' => $content,
966 'length' => $content->getSize(),
967 'comment' =>
"testing",
968 'minor_edit' =>
false,
973 $content =
$rev->getContent( Revision::RAW );
974 $content->setText(
"bar" );
977 $content2 =
$rev->getContent( Revision::RAW );
979 $this->assertNotSame( $content, $content2,
"expected a clone" );
981 $this->assertEquals(
"foo", $content2->getText() );
983 $content2->setText(
"bla bla" );
985 $this->assertEquals(
"bar", $content->getText() );
994 $content =
$rev->getContent( Revision::RAW );
995 $content2 =
$rev->getContent( Revision::RAW );
998 $this->assertSame( $content, $content2 );
1005 $rev = $this->testPage->getRevision();
1018 $this->testPage->getRevision(),
1028 $this->testPage->getRevision(),
1029 Revision::loadFromPageId(
1031 $this->testPage->getId(),
1032 $this->testPage->getLatest()
1041 $this->testPage->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ );
1043 $this->testPage->getRevision()->getPrevious(),
1044 Revision::loadFromPageId(
1046 $this->testPage->getId(),
1047 $this->testPage->getRevision()->getPrevious()->getId()
1057 $this->testPage->getRevision(),
1058 Revision::loadFromTitle(
wfGetDB(
DB_MASTER ), $this->testPage->getTitle() )
1067 $this->testPage->getRevision(),
1068 Revision::loadFromTitle(
1070 $this->testPage->getTitle(),
1071 $this->testPage->getLatest()
1080 $this->testPage->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ );
1082 $this->testPage->getRevision()->getPrevious(),
1083 Revision::loadFromTitle(
1085 $this->testPage->getTitle(),
1086 $this->testPage->getRevision()->getPrevious()->getId()
1096 $this->testPage->getRevision(),
1097 Revision::loadFromTimestamp(
1099 $this->testPage->getTitle(),
1100 $this->testPage->getRevision()->getTimestamp()
1111 Revision::getParentLengths(
1122 $text =
'831jr091jr0921kr21kr0921kjr0921j09rj1';
1123 $textLength = strlen( $text );
1125 $this->testPage->doEditContent(
new WikitextContent( $text ), __METHOD__ );
1126 $rev[1] = $this->testPage->getLatest();
1129 [
$rev[1] => $textLength ],
1130 Revision::getParentLengths(
1141 $textOne =
'831jr091jr0921kr21kr0921kjr0921j09rj1';
1142 $textOneLength = strlen( $textOne );
1143 $textTwo =
'831jr091jr092121j09rj1';
1144 $textTwoLength = strlen( $textTwo );
1146 $this->testPage->doEditContent(
new WikitextContent( $textOne ), __METHOD__ );
1147 $rev[1] = $this->testPage->getLatest();
1148 $this->testPage->doEditContent(
new WikitextContent( $textTwo ), __METHOD__ );
1149 $rev[2] = $this->testPage->getLatest();
1152 [
$rev[1] => $textOneLength,
$rev[2] => $textTwoLength ],
1153 Revision::getParentLengths(
1165 $this->testPage->getTitle()->equals(
1166 $this->testPage->getRevision()->getTitle()
1175 $rev =
new Revision( [
'id' => $this->testPage->getLatest() ] );
1177 $this->testPage->getTitle()->equals(
1190 $this->testPage->doEditContent(
1197 $rev = $this->testPage->getRevision();
1199 $this->assertSame(
true,
$rev->isMinor() );
1206 $this->testPage->doEditContent(
1211 $rev = $this->testPage->getRevision();
1213 $this->assertSame(
false,
$rev->isMinor() );
1222 $this->testPage->doEditContent(
1226 $rev = $this->testPage->getRevision();
1228 $this->assertInternalType(
'string',
$rev->getTimestamp() );
1229 $this->assertTrue( strlen(
$rev->getTimestamp() ) == strlen(
'YYYYMMDDHHMMSS' ) );
1230 $this->assertContains( substr( $testTimestamp, 0, 10 ),
$rev->getTimestamp() );
1240 $this->testPage->doEditContent(
1247 $rev = $this->testPage->getRevision();
1249 $this->assertSame( $sysop->getId(),
$rev->getUser() );
1250 $this->assertSame( $sysop->getName(),
$rev->getUserText() );
1257 $rev = $this->testPage->getRevision();
1259 $this->assertSame(
false,
$rev->isDeleted( Revision::DELETED_TEXT ) );
1260 $this->assertSame(
false,
$rev->isDeleted( Revision::DELETED_COMMENT ) );
1261 $this->assertSame(
false,
$rev->isDeleted( Revision::DELETED_RESTRICTED ) );
1262 $this->assertSame(
false,
$rev->isDeleted( Revision::DELETED_USER ) );
1269 $rev = $this->testPage->getRevision();
1271 $this->assertSame( 0,
$rev->getVisibility() );
1278 $expectedSummary =
'goatlicious summary';
1280 $this->testPage->doEditContent(
1284 $rev = $this->testPage->getRevision();
1286 $this->assertSame( $expectedSummary,
$rev->getComment() );
1293 $this->testPage->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ );
1294 $rev = $this->testPage->getRevision();
1296 $this->assertGreaterThan( 0,
$rev->isUnpatrolled() );
1297 $this->assertSame(
$rev->getRecentChange()->getAttribute(
'rc_id' ),
$rev->isUnpatrolled() );
1306 $this->testPage->doEditContent(
1313 $rev = $this->testPage->getRevision();
1315 $this->assertSame( 0,
$rev->isUnpatrolled() );
1328 $expectedText =
'testSimpleContentGetters in Revision. Goats love MCR...';
1329 $expectedSummary =
'goatlicious testSimpleContentGetters summary';
1331 $this->testPage->doEditContent(
1335 $rev = $this->testPage->getRevision();
1337 $this->assertSame( $expectedText,
$rev->getContent()->getNativeData() );
1338 $this->assertSame( $expectedText,
$rev->getSerializedData() );
1339 $this->assertSame( $this->testPage->getContentModel(),
$rev->getContentModel() );
1340 $this->assertSame( $this->testPage->getContent()->getDefaultFormat(),
$rev->getContentFormat() );
1341 $this->assertSame( $this->testPage->getContentHandler(),
$rev->getContentHandler() );
1354 $this->testPage->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ );
1355 $rev = $this->testPage->getRevision();
1358 $key =
$cache->makeGlobalKey(
'revision-row-1.29',
1363 $cache->delete( $key, WANObjectCache::HOLDOFF_NONE );
1364 $this->assertFalse(
$cache->get( $key ) );
1367 $newRev = Revision::newKnownCurrent(
$db,
$rev->getPage(),
$rev->getId() );
1370 $cachedRow =
$cache->get( $key );
1371 $this->assertNotFalse( $cachedRow );
1372 $this->assertEquals(
$rev->getId(), $cachedRow->rev_id );
1378 $this->testPage->doEditContent(
new WikitextContent( __METHOD__ ), __METHOD__ );
1379 $rev = $this->testPage->getRevision();
1381 $pageId = $this->testPage->getId();
1383 $newRev = Revision::newKnownCurrent(
$db, $pageId,
$rev->getId() );
1390 $this->assertFalse( Revision::newKnownCurrent(
$db, 0 ) );
1394 yield [ 0, 0, [],
null,
true ];
1396 yield [ Revision::DELETED_TEXT, Revision::DELETED_TEXT, [],
null,
false ];
1397 yield [ Revision::DELETED_COMMENT, Revision::DELETED_COMMENT, [],
null,
false ];
1398 yield [ Revision::DELETED_USER, Revision::DELETED_USER, [],
null,
false ];
1399 yield [ Revision::DELETED_RESTRICTED, Revision::DELETED_RESTRICTED, [],
null,
false ];
1401 yield [ Revision::DELETED_TEXT, Revision::DELETED_TEXT, [
'sysop' ],
null,
true ];
1402 yield [ Revision::DELETED_COMMENT, Revision::DELETED_COMMENT, [
'sysop' ],
null,
true ];
1403 yield [ Revision::DELETED_USER, Revision::DELETED_USER, [
'sysop' ],
null,
true ];
1405 yield [ Revision::DELETED_RESTRICTED, Revision::DELETED_RESTRICTED, [
'sysop' ],
null,
false ];
1407 yield [ Revision::DELETED_RESTRICTED, Revision::DELETED_RESTRICTED, [
'oversight' ],
null,
true ];
1410 Revision::DELETED_TEXT,
1411 Revision::DELETED_TEXT,
1413 Title::newFromText( __METHOD__ ),
1417 Revision::DELETED_TEXT,
1418 Revision::DELETED_TEXT,
1420 Title::newFromText( __METHOD__ ),
1431 'wgGroupPermissions',
1434 'deletedtext' =>
true,
1435 'deletedhistory' =>
true,
1438 'viewsuppressed' =>
true,
1439 'suppressrevision' =>
true,
1443 $user = $this->
getTestUser( $userGroups )->getUser();
1447 Revision::userCanBitfield( $bitField, $field, $user, $title )
1457 Revision::userCanBitfield( $bitField, $field,
null, $title )
1462 yield [ 0, 0, [],
true ];
1464 yield [ Revision::DELETED_TEXT, Revision::DELETED_TEXT, [],
false ];
1465 yield [ Revision::DELETED_COMMENT, Revision::DELETED_COMMENT, [],
false ];
1466 yield [ Revision::DELETED_USER, Revision::DELETED_USER, [],
false ];
1467 yield [ Revision::DELETED_RESTRICTED, Revision::DELETED_RESTRICTED, [],
false ];
1469 yield [ Revision::DELETED_TEXT, Revision::DELETED_TEXT, [
'sysop' ],
true ];
1470 yield [ Revision::DELETED_COMMENT, Revision::DELETED_COMMENT, [
'sysop' ],
true ];
1471 yield [ Revision::DELETED_USER, Revision::DELETED_USER, [
'sysop' ],
true ];
1473 yield [ Revision::DELETED_RESTRICTED, Revision::DELETED_RESTRICTED, [
'sysop' ],
false ];
1475 yield [ Revision::DELETED_RESTRICTED, Revision::DELETED_RESTRICTED, [
'oversight' ],
true ];
1482 public function testUserCan( $bitField, $field, $userGroups, $expected ) {
1484 'wgGroupPermissions',
1487 'deletedtext' =>
true,
1488 'deletedhistory' =>
true,
1491 'viewsuppressed' =>
true,
1492 'suppressrevision' =>
true,
1496 $user = $this->
getTestUser( $userGroups )->getUser();
1497 $revision =
new Revision( [
'deleted' => $bitField ], 0, $this->testPage->getTitle() );
1501 $revision->userCan( $field, $user )
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Simple store for keeping values in an associative array for the current process.
RevisionDbTestBase contains test cases for the Revision class that have Database interactions.
testLoadFromTitle()
Revision::loadFromTitle.
testNewNullRevision()
Revision::newNullRevision.
testNewKnownCurrent()
Revision::newKnownCurrent.
provideNewFromArchiveRow()
testLoadFromTitleWithNotLatestRevId()
Revision::loadFromTitle.
testUserCan( $bitField, $field, $userGroups, $expected)
provideUserCan Revision::userCan
testNewFromArchiveRowOverrides()
Revision::newFromArchiveRow.
testLoadFromPageIdWithNotLatestRevId()
Revision::loadFromPageId.
testGetContentHandler( $text, $title, $model, $format, $expectedClass)
provideGetContentHandler Revision::getContentHandler
testGetParentLengths_noRevIds()
Revision::getParentLengths.
testInsertOn_success()
Revision::insertOn.
assertRevEquals(Revision $orig, Revision $rev=null)
testGetComment_notDeleted()
Revision::getComment.
testNewKnownCurrent_withPageId()
provideGetContentHandler()
testGetVisibility_nothingDeleted()
Revision::getVisibility.
testGetContent_failure()
Revision::getContent.
testGetParentLengths_multipleRevIds()
Revision::getParentLengths.
testLoadFromId()
Revision::loadFromId.
testLoadFromPageId()
Revision::loadFromPageId.
testInsertOn_exceptionOnNoPage()
Revision::insertOn.
testGetTitle_fromExistingRevision()
Revision::getTitle.
testNewFromTitle_withBadId()
Revision::newFromTitle.
testGetSize( $text, $model, $expected_size)
Revision::getSize provideGetSize.
createPage( $titleString, $text, $model=null)
testGetContentModel( $text, $title, $model, $format, $expectedModel)
provideGetContentModel Revision::getContentModel
testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization)
provideGetContent Revision::getContent
testInsertOn()
Revision::insertOn.
testGetTimestamp()
Revision::getTimestamp.
testNewFromPageId()
Revision::newFromPageId.
testFetchRevision()
Revision::fetchRevision.
testGetUserAndText()
Revision::getUser Revision::getUserText.
testLoadFromTitleWithLatestRevId()
Revision::loadFromTitle.
testGetRecentChange()
Revision::getRecentChange.
testGetSha1( $text, $model, $expected_hash)
Revision::getSha1 provideGetSha1.
testGetTitle_fromRevisionWhichWillLoadTheTitle()
Revision::getTitle.
testNewFromArchiveRow( $selectModifier)
provideNewFromArchiveRow Revision::newFromArchiveRow
testGetContentFormat( $text, $title, $model, $format, $expectedFormat)
provideGetContentFormat Revision::getContentFormat
makeRevisionWithProps( $props=null)
testGetContentClone()
Tests whether $rev->getContent() returns a clone when needed.
testLoadFromTimestamp()
Revision::loadFromTimestamp()
testNewFromRow()
Revision::newFromRow.
testIsUnpatrolled_returnsRecentChangesId()
Revision::isUnpatrolled.
testNewNullRevision_badPage()
Revision::newNullRevision.
testIsDeleted_nothingDeleted()
Revision::isDeleted.
testNewFromTitle_withId()
Revision::newFromTitle.
static provideUserWasLastToEdit()
testIsMinor_false()
Revision::isMinor.
testLoadFromPageIdWithLatestRevId()
Revision::loadFromPageId.
testNewFromId()
Revision::newFromId.
testNewFromTitle_withoutId()
Revision::newFromTitle.
testUserCanBitfield( $bitField, $field, $userGroups, $title, $expected)
provideUserCanBitfield Revision::userCanBitfield
testNewFromPageIdWithLatestId()
Revision::newFromPageId.
testGetContentUncloned()
Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
testIsCurrent()
Revision::isCurrent.
testGetPrevious()
Revision::getPrevious.
testGetParentLengths_oneRevId()
Revision::getParentLengths.
provideGetContentFormat()
testSimpleContentGetters()
This is a simple blanket test for all simple content getters and is methods to provide some coverage ...
testNewFromPageIdWithNotLatestId()
Revision::newFromPageId.
testIsMinor_true()
Revision::isMinor.
testNewKnownCurrent_returnsFalseWhenTitleDoesntExist()
testIsUnpatrolled_returnsZeroIfPatrolled()
Revision::isUnpatrolled.
testGetNext()
Revision::getNext.
__construct( $name=null, array $data=[], $dataName='')
testUserWasLastToEdit( $sinceIdx, $expectedLast)
Revision::userWasLastToEdit provideUserWasLastToEdit.
newTestRevision( $text, $title="Test", $model=CONTENT_MODEL_WIKITEXT, $format=null)
testGetPage()
Revision::getPage.
getContentFormat()
Returns the content format for the main slot of this revision.
getPage()
Get the page ID.
getContentModel()
Returns the content model for the main slot of this revision.
getUser( $audience=self::FOR_PUBLIC, User $user=null)
Fetch revision's user id if it's available to the specified audience.
getSha1()
Returns the base36 sha1 of the content in this revision, or null if unknown.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
static createNew( $name, $params=[])
Add a user to the database, return the user object.
Multi-datacenter aware caching interface.
Class representing a MediaWiki article and history.
Content object for wiki text pages.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction $rows
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
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
processing should stop and the error should be shown to the user * false
const CONTENT_MODEL_WIKITEXT
const CONTENT_FORMAT_WIKITEXT