3 use MediaWiki\MediaWikiServices
;
4 use MediaWiki\Revision\MutableRevisionRecord
;
5 use MediaWiki\Revision\RevisionStore
;
6 use MediaWiki\Revision\IncompleteRevisionException
;
7 use MediaWiki\Revision\RevisionRecord
;
8 use MediaWiki\Revision\SlotRecord
;
11 * RevisionDbTestBase contains test cases for the Revision class that have Database interactions.
16 abstract class RevisionDbTestBase
extends MediaWikiTestCase
{
19 * @var WikiPage $testPage
23 public function __construct( $name = null, array $data = [], $dataName = '' ) {
24 parent
::__construct( $name, $data, $dataName );
26 $this->tablesUsed
= array_merge( $this->tablesUsed
,
50 protected function addCoreDBData() {
51 // Blank out. This would fail with a modified schema, and we don't need it.
57 abstract protected function getMcrMigrationStage();
62 abstract protected function getMcrTablesToReset();
64 protected function setUp() {
65 $this->tablesUsed +
= $this->getMcrTablesToReset();
69 $this->mergeMwGlobalArrayValue(
73 12313 => 'Dummy_talk',
77 $this->mergeMwGlobalArrayValue(
78 'wgNamespaceContentModels',
80 12312 => DummyContentForTesting
::MODEL_ID
,
84 $this->mergeMwGlobalArrayValue(
87 DummyContentForTesting
::MODEL_ID
=> 'DummyContentHandlerForTesting',
88 RevisionTestModifyableContent
::MODEL_ID
=> 'RevisionTestModifyableContentHandler',
92 $this->setMwGlobals( [
93 'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(),
94 'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(),
95 'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW
,
98 if ( !$this->testPage
) {
100 * We have to create a new page for each subclass as the page creation may result
101 * in different DB fields being filled based on configuration.
103 $this->testPage
= $this->createPage( __CLASS__
, __CLASS__
);
108 * @param string $model
111 protected function getMockTitle() {
112 $mock = $this->getMockBuilder( Title
::class )
113 ->disableOriginalConstructor()
115 $mock->expects( $this->any() )
116 ->method( 'getNamespace' )
117 ->will( $this->returnValue( $this->getDefaultWikitextNS() ) );
118 $mock->expects( $this->any() )
119 ->method( 'getPrefixedText' )
120 ->will( $this->returnValue( __CLASS__
) );
121 $mock->expects( $this->any() )
122 ->method( 'getDBkey' )
123 ->will( $this->returnValue( __CLASS__
) );
124 $mock->expects( $this->any() )
125 ->method( 'getArticleID' )
126 ->will( $this->returnValue( 23 ) );
131 abstract protected function getContentHandlerUseDB();
133 private function makeRevisionWithProps( $props = null ) {
134 if ( $props === null ) {
138 if ( !isset( $props['content'] ) && !isset( $props['text'] ) ) {
139 $props['text'] = 'Lorem Ipsum';
142 if ( !isset( $props['user_text'] ) ) {
143 $user = $this->getTestUser()->getUser();
144 $props['user_text'] = $user->getName();
145 $props['user'] = $user->getId();
148 if ( !isset( $props['user'] ) ) {
152 if ( !isset( $props['comment'] ) ) {
153 $props['comment'] = 'just a test';
156 if ( !isset( $props['page'] ) ) {
157 $props['page'] = $this->testPage
->getId();
160 if ( !isset( $props['content_model'] ) ) {
161 $props['content_model'] = CONTENT_MODEL_WIKITEXT
;
164 $rev = new Revision( $props );
166 $dbw = wfGetDB( DB_MASTER
);
167 $rev->insertOn( $dbw );
173 * @param string $titleString
174 * @param string $text
175 * @param string|null $model
179 private function createPage( $titleString, $text, $model = null ) {
180 if ( !preg_match( '/:/', $titleString ) &&
181 ( $model === null ||
$model === CONTENT_MODEL_WIKITEXT
)
183 $ns = $this->getDefaultWikitextNS();
184 $titleString = MediaWikiServices
::getInstance()->getNamespaceInfo()->
185 getCanonicalName( $ns ) . ':' . $titleString;
188 $title = Title
::newFromText( $titleString );
189 $wikipage = new WikiPage( $title );
191 // Delete the article if it already exists
192 if ( $wikipage->exists() ) {
193 $wikipage->doDeleteArticle( "done" );
196 $content = ContentHandler
::makeContent( $text, $title, $model );
197 $wikipage->doEditContent( $content, __METHOD__
, EDIT_NEW
);
202 private function assertRevEquals( Revision
$orig, Revision
$rev = null ) {
203 $this->assertNotNull( $rev, 'missing revision' );
205 $this->assertEquals( $orig->getId(), $rev->getId() );
206 $this->assertEquals( $orig->getPage(), $rev->getPage() );
207 $this->assertEquals( $orig->getTimestamp(), $rev->getTimestamp() );
208 $this->assertEquals( $orig->getUser(), $rev->getUser() );
209 $this->assertEquals( $orig->getContentModel(), $rev->getContentModel() );
210 $this->assertEquals( $orig->getContentFormat(), $rev->getContentFormat() );
211 $this->assertEquals( $orig->getSha1(), $rev->getSha1() );
215 * @covers Revision::getRecentChange
217 public function testGetRecentChange() {
218 $rev = $this->testPage
->getRevision();
219 $recentChange = $rev->getRecentChange();
221 // Make sure various attributes look right / the correct entry has been retrieved.
222 $this->assertEquals( $rev->getTimestamp(), $recentChange->getAttribute( 'rc_timestamp' ) );
224 $rev->getTitle()->getNamespace(),
225 $recentChange->getAttribute( 'rc_namespace' )
228 $rev->getTitle()->getDBkey(),
229 $recentChange->getAttribute( 'rc_title' )
231 $this->assertEquals( $rev->getUser(), $recentChange->getAttribute( 'rc_user' ) );
232 $this->assertEquals( $rev->getUserText(), $recentChange->getAttribute( 'rc_user_text' ) );
233 $this->assertEquals( $rev->getComment(), $recentChange->getAttribute( 'rc_comment' ) );
234 $this->assertEquals( $rev->getPage(), $recentChange->getAttribute( 'rc_cur_id' ) );
235 $this->assertEquals( $rev->getId(), $recentChange->getAttribute( 'rc_this_oldid' ) );
239 * @covers Revision::insertOn
241 public function testInsertOn_success() {
242 $parentId = $this->testPage
->getLatest();
244 // If an ExternalStore is set don't use it.
245 $this->setMwGlobals( 'wgDefaultExternalStore', false );
247 $rev = new Revision( [
248 'page' => $this->testPage
->getId(),
249 'title' => $this->testPage
->getTitle(),
250 'text' => 'Revision Text',
251 'comment' => 'Revision comment',
254 $revId = $rev->insertOn( wfGetDB( DB_MASTER
) );
256 $this->assertInternalType( 'integer', $revId );
257 $this->assertSame( $revId, $rev->getId() );
259 // getTextId() must be an int!
260 $this->assertInternalType( 'integer', $rev->getTextId() );
262 $mainSlot = $rev->getRevisionRecord()->getSlot( SlotRecord
::MAIN
, RevisionRecord
::RAW
);
264 // we currently only support storage in the text table
265 $textId = MediaWikiServices
::getInstance()
267 ->getTextIdFromAddress( $mainSlot->getAddress() );
271 [ 'old_id', 'old_text' ],
273 [ [ strval( $textId ), 'Revision Text' ] ]
286 "rev_id = {$rev->getId()}",
288 strval( $rev->getId() ),
289 strval( $this->testPage
->getId() ),
294 's0ngbdoxagreuf2vjtuxzwdz64n29xm',
299 public function provideInsertOn_exceptionOnIncomplete() {
300 $content = new TextContent( '' );
301 $user = User
::newFromName( 'Foo' );
303 yield
'no parent' => [
305 'content' => $content,
309 IncompleteRevisionException
::class,
310 "rev_page field must not be 0!"
313 yield
'no comment' => [
315 'content' => $content,
319 IncompleteRevisionException
::class,
320 "comment must not be NULL!"
323 yield
'no content' => [
329 IncompleteRevisionException
::class,
330 "Uninitialized field: content_address" // XXX: message may change
335 * @dataProvider provideInsertOn_exceptionOnIncomplete
336 * @covers Revision::insertOn
338 public function testInsertOn_exceptionOnIncomplete( $array, $expException, $expMessage ) {
339 // If an ExternalStore is set don't use it.
340 $this->setMwGlobals( 'wgDefaultExternalStore', false );
341 $this->setExpectedException( $expException, $expMessage );
343 $title = Title
::newFromText( 'Nonexistant-' . __METHOD__
);
344 $rev = new Revision( $array, 0, $title );
346 $rev->insertOn( wfGetDB( DB_MASTER
) );
350 * @covers Revision::newFromTitle
352 public function testNewFromTitle_withoutId() {
353 $latestRevId = $this->testPage
->getLatest();
355 $rev = Revision
::newFromTitle( $this->testPage
->getTitle() );
357 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
358 $this->assertEquals( $latestRevId, $rev->getId() );
362 * @covers Revision::newFromTitle
364 public function testNewFromTitle_withId() {
365 $latestRevId = $this->testPage
->getLatest();
367 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId );
369 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
370 $this->assertEquals( $latestRevId, $rev->getId() );
374 * @covers Revision::newFromTitle
376 public function testNewFromTitle_withBadId() {
377 $latestRevId = $this->testPage
->getLatest();
379 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId +
1 );
381 $this->assertNull( $rev );
385 * @covers Revision::newFromRow
387 public function testNewFromRow() {
388 $orig = $this->makeRevisionWithProps();
390 $dbr = wfGetDB( DB_REPLICA
);
391 $revQuery = Revision
::getQueryInfo();
392 $res = $dbr->select( $revQuery['tables'], $revQuery['fields'], [ 'rev_id' => $orig->getId() ],
393 __METHOD__
, [], $revQuery['joins'] );
394 $this->assertTrue( is_object( $res ), 'query failed' );
396 $row = $res->fetchObject();
399 $rev = Revision
::newFromRow( $row );
401 $this->assertRevEquals( $orig, $rev );
404 public function provideNewFromArchiveRow() {
412 return $f +
[ 'ar_namespace', 'ar_title' ];
417 unset( $f['ar_text_id'] );
423 unset( $f['ar_page_id'] );
429 unset( $f['ar_parent_id'] );
435 unset( $f['ar_rev_id'] );
441 unset( $f['ar_sha1'] );
448 * @dataProvider provideNewFromArchiveRow
449 * @covers Revision::newFromArchiveRow
451 public function testNewFromArchiveRow( $selectModifier ) {
452 $services = MediaWikiServices
::getInstance();
454 $store = new RevisionStore(
455 $services->getDBLoadBalancer(),
456 $services->getService( '_SqlBlobStore' ),
457 $services->getMainWANObjectCache(),
458 $services->getCommentStore(),
459 $services->getContentModelStore(),
460 $services->getSlotRoleStore(),
461 $services->getSlotRoleRegistry(),
462 $this->getMcrMigrationStage(),
463 $services->getActorMigration()
466 $store->setContentHandlerUseDB( $this->getContentHandlerUseDB() );
467 $this->setService( 'RevisionStore', $store );
469 $page = $this->createPage(
470 'RevisionStorageTest_testNewFromArchiveRow',
472 CONTENT_MODEL_WIKITEXT
474 $orig = $page->getRevision();
475 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
477 $dbr = wfGetDB( DB_REPLICA
);
478 $arQuery = Revision
::getArchiveQueryInfo();
479 $arQuery['fields'] = $selectModifier( $arQuery['fields'] );
481 $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
482 __METHOD__
, [], $arQuery['joins']
484 $this->assertTrue( is_object( $res ), 'query failed' );
486 $row = $res->fetchObject();
489 // MCR migration note: $row is now required to contain ar_title and ar_namespace.
490 // Alternatively, a Title object can be passed to RevisionStore::newRevisionFromArchiveRow
491 $rev = Revision
::newFromArchiveRow( $row );
493 $this->assertRevEquals( $orig, $rev );
497 * @covers Revision::newFromArchiveRow
499 public function testNewFromArchiveRowOverrides() {
500 $page = $this->createPage(
501 'RevisionStorageTest_testNewFromArchiveRow',
503 CONTENT_MODEL_WIKITEXT
505 $orig = $page->getRevision();
506 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
508 $dbr = wfGetDB( DB_REPLICA
);
509 $arQuery = Revision
::getArchiveQueryInfo();
511 $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
512 __METHOD__
, [], $arQuery['joins']
514 $this->assertTrue( is_object( $res ), 'query failed' );
516 $row = $res->fetchObject();
519 $rev = Revision
::newFromArchiveRow( $row, [ 'comment_text' => 'SOMEOVERRIDE' ] );
521 $this->assertNotEquals( $orig->getComment(), $rev->getComment() );
522 $this->assertEquals( 'SOMEOVERRIDE', $rev->getComment() );
526 * @covers Revision::newFromId
528 public function testNewFromId() {
529 $orig = $this->testPage
->getRevision();
530 $rev = Revision
::newFromId( $orig->getId() );
531 $this->assertRevEquals( $orig, $rev );
535 * @covers Revision::newFromPageId
537 public function testNewFromPageId() {
538 $rev = Revision
::newFromPageId( $this->testPage
->getId() );
539 $this->assertRevEquals(
540 $this->testPage
->getRevision(),
546 * @covers Revision::newFromPageId
548 public function testNewFromPageIdWithLatestId() {
549 $rev = Revision
::newFromPageId(
550 $this->testPage
->getId(),
551 $this->testPage
->getLatest()
553 $this->assertRevEquals(
554 $this->testPage
->getRevision(),
560 * @covers Revision::newFromPageId
562 public function testNewFromPageIdWithNotLatestId() {
563 $content = new WikitextContent( __METHOD__
);
564 $this->testPage
->doEditContent( $content, __METHOD__
);
565 $rev = Revision
::newFromPageId(
566 $this->testPage
->getId(),
567 $this->testPage
->getRevision()->getPrevious()->getId()
569 $this->assertRevEquals(
570 $this->testPage
->getRevision()->getPrevious(),
576 * @covers Revision::getPage
578 public function testGetPage() {
579 $page = $this->testPage
;
581 $orig = $this->makeRevisionWithProps( [ 'page' => $page->getId() ] );
582 $rev = Revision
::newFromId( $orig->getId() );
584 $this->assertEquals( $page->getId(), $rev->getPage() );
588 * @covers Revision::isCurrent
590 public function testIsCurrent() {
591 $rev1 = $this->testPage
->getRevision();
593 # @todo find out if this should be true
594 # $this->assertTrue( $rev1->isCurrent() );
596 $rev1x = Revision
::newFromId( $rev1->getId() );
597 $this->assertTrue( $rev1x->isCurrent() );
599 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
600 $rev2 = $this->testPage
->getRevision();
602 # @todo find out if this should be true
603 # $this->assertTrue( $rev2->isCurrent() );
605 $rev1x = Revision
::newFromId( $rev1->getId() );
606 $this->assertFalse( $rev1x->isCurrent() );
608 $rev2x = Revision
::newFromId( $rev2->getId() );
609 $this->assertTrue( $rev2x->isCurrent() );
613 * @covers Revision::getPrevious
615 public function testGetPrevious() {
616 $oldestRevision = $this->testPage
->getOldestRevision();
617 $latestRevision = $this->testPage
->getLatest();
619 $this->assertNull( $oldestRevision->getPrevious() );
621 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
622 $newRevision = $this->testPage
->getRevision();
624 $this->assertNotNull( $newRevision->getPrevious() );
625 $this->assertEquals( $latestRevision, $newRevision->getPrevious()->getId() );
629 * @covers Title::getPreviousRevisionID
630 * @covers Title::getRelativeRevisionID
631 * @covers MediaWiki\Revision\RevisionStore::getPreviousRevision
632 * @covers MediaWiki\Revision\RevisionStore::getRelativeRevision
634 public function testTitleGetPreviousRevisionID() {
635 $oldestId = $this->testPage
->getOldestRevision()->getId();
636 $latestId = $this->testPage
->getLatest();
638 $title = $this->testPage
->getTitle();
640 $this->assertFalse( $title->getPreviousRevisionID( $oldestId ) );
642 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
643 $newId = $this->testPage
->getRevision()->getId();
645 $this->assertEquals( $latestId, $title->getPreviousRevisionID( $newId ) );
649 * @covers Title::getPreviousRevisionID
650 * @covers Title::getRelativeRevisionID
652 public function testTitleGetPreviousRevisionID_invalid() {
653 $this->assertFalse( $this->testPage
->getTitle()->getPreviousRevisionID( 123456789 ) );
657 * @covers Revision::getNext
659 public function testGetNext() {
660 $rev1 = $this->testPage
->getRevision();
662 $this->assertNull( $rev1->getNext() );
664 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
665 $rev2 = $this->testPage
->getRevision();
667 $this->assertNotNull( $rev1->getNext() );
668 $this->assertEquals( $rev2->getId(), $rev1->getNext()->getId() );
672 * @covers Title::getNextRevisionID
673 * @covers Title::getRelativeRevisionID
674 * @covers MediaWiki\Revision\RevisionStore::getNextRevision
675 * @covers MediaWiki\Revision\RevisionStore::getRelativeRevision
677 public function testTitleGetNextRevisionID() {
678 $title = $this->testPage
->getTitle();
680 $origId = $this->testPage
->getLatest();
682 $this->assertFalse( $title->getNextRevisionID( $origId ) );
684 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
685 $newId = $this->testPage
->getLatest();
687 $this->assertSame( $this->testPage
->getLatest(), $title->getNextRevisionID( $origId ) );
691 * @covers Title::getNextRevisionID
692 * @covers Title::getRelativeRevisionID
694 public function testTitleGetNextRevisionID_invalid() {
695 $this->assertFalse( $this->testPage
->getTitle()->getNextRevisionID( 123456789 ) );
699 * @covers Revision::newNullRevision
701 public function testNewNullRevision() {
702 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
703 $orig = $this->testPage
->getRevision();
705 $dbw = wfGetDB( DB_MASTER
);
706 $rev = Revision
::newNullRevision( $dbw, $this->testPage
->getId(), 'a null revision', false );
708 $this->assertNotEquals( $orig->getId(), $rev->getId(),
709 'new null revision should have a different id from the original revision' );
710 $this->assertEquals( $orig->getTextId(), $rev->getTextId(),
711 'new null revision should have the same text id as the original revision' );
712 $this->assertEquals( $orig->getSha1(), $rev->getSha1(),
713 'new null revision should have the same SHA1 as the original revision' );
714 $this->assertTrue( $orig->getRevisionRecord()->hasSameContent( $rev->getRevisionRecord() ),
715 'new null revision should have the same content as the original revision' );
716 $this->assertEquals( __METHOD__
, $rev->getContent()->getText() );
720 * @covers Revision::newNullRevision
722 public function testNewNullRevision_badPage() {
723 $dbw = wfGetDB( DB_MASTER
);
724 $rev = Revision
::newNullRevision( $dbw, -1, 'a null revision', false );
726 $this->assertNull( $rev );
730 * @covers Revision::insertOn
732 public function testInsertOn() {
733 $ip = '2600:387:ed7:947e:8c16:a1ad:dd34:1dd7';
735 $orig = $this->makeRevisionWithProps( [
739 // Make sure the revision was copied to ip_changes
740 $dbr = wfGetDB( DB_REPLICA
);
741 $res = $dbr->select( 'ip_changes', '*', [ 'ipc_rev_id' => $orig->getId() ] );
742 $row = $res->fetchObject();
744 $this->assertEquals( IP
::toHex( $ip ), $row->ipc_hex
);
746 $orig->getTimestamp(),
747 wfTimestamp( TS_MW
, $row->ipc_rev_timestamp
)
751 public static function provideUserWasLastToEdit() {
752 yield
'actually the last edit' => [ 3, true ];
753 yield
'not the current edit, but still by this user' => [ 2, true ];
754 yield
'edit by another user' => [ 1, false ];
755 yield
'first edit, by this user, but another user edited in the mean time' => [ 0, false ];
759 * @covers Revision::userWasLastToEdit
760 * @dataProvider provideUserWasLastToEdit
762 public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
763 $userA = User
::newFromName( "RevisionStorageTest_userA" );
764 $userB = User
::newFromName( "RevisionStorageTest_userB" );
766 if ( $userA->getId() === 0 ) {
767 $userA = User
::createNew( $userA->getName() );
770 if ( $userB->getId() === 0 ) {
771 $userB = User
::createNew( $userB->getName() );
774 $ns = $this->getDefaultWikitextNS();
776 $dbw = wfGetDB( DB_MASTER
);
779 // create revisions -----------------------------
780 $page = WikiPage
::factory( Title
::newFromText(
781 'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
782 $page->insertOn( $dbw );
784 $revisions[0] = new Revision( [
785 'page' => $page->getId(),
786 // we need the title to determine the page's default content model
787 'title' => $page->getTitle(),
788 'timestamp' => '20120101000000',
789 'user' => $userA->getId(),
791 'content_model' => CONTENT_MODEL_WIKITEXT
,
792 'comment' => 'edit zero'
794 $revisions[0]->insertOn( $dbw );
796 $revisions[1] = new Revision( [
797 'page' => $page->getId(),
798 // still need the title, because $page->getId() is 0 (there's no entry in the page table)
799 'title' => $page->getTitle(),
800 'timestamp' => '20120101000100',
801 'user' => $userA->getId(),
803 'content_model' => CONTENT_MODEL_WIKITEXT
,
804 'comment' => 'edit one'
806 $revisions[1]->insertOn( $dbw );
808 $revisions[2] = new Revision( [
809 'page' => $page->getId(),
810 'title' => $page->getTitle(),
811 'timestamp' => '20120101000200',
812 'user' => $userB->getId(),
814 'content_model' => CONTENT_MODEL_WIKITEXT
,
815 'comment' => 'edit two'
817 $revisions[2]->insertOn( $dbw );
819 $revisions[3] = new Revision( [
820 'page' => $page->getId(),
821 'title' => $page->getTitle(),
822 'timestamp' => '20120101000300',
823 'user' => $userA->getId(),
825 'content_model' => CONTENT_MODEL_WIKITEXT
,
826 'comment' => 'edit three'
828 $revisions[3]->insertOn( $dbw );
830 $revisions[4] = new Revision( [
831 'page' => $page->getId(),
832 'title' => $page->getTitle(),
833 'timestamp' => '20120101000200',
834 'user' => $userA->getId(),
836 'content_model' => CONTENT_MODEL_WIKITEXT
,
837 'comment' => 'edit four'
839 $revisions[4]->insertOn( $dbw );
841 // test it ---------------------------------
842 $since = $revisions[$sinceIdx]->getTimestamp();
844 $revQuery = Revision
::getQueryInfo();
845 $allRows = iterator_to_array( $dbw->select(
847 [ 'rev_id', 'rev_timestamp', 'rev_user' => $revQuery['fields']['rev_user'] ],
849 'rev_page' => $page->getId(),
850 //'rev_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $since ) )
853 [ 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 50 ],
857 $wasLast = Revision
::userWasLastToEdit( $dbw, $page->getId(), $userA->getId(), $since );
859 $this->assertEquals( $expectedLast, $wasLast );
863 * @param string $text
864 * @param string $title
865 * @param string $model
866 * @param string $format
870 private function newTestRevision( $text, $title = "Test",
871 $model = CONTENT_MODEL_WIKITEXT
, $format = null
873 if ( is_string( $title ) ) {
874 $title = Title
::newFromText( $title );
877 $content = ContentHandler
::makeContent( $text, $title, $model, $format );
885 'content' => $content,
886 'length' => $content->getSize(),
887 'comment' => "testing",
888 'minor_edit' => false,
890 'content_format' => $format,
897 public function provideGetContentModel() {
898 // NOTE: we expect the help namespace to always contain wikitext
900 [ 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT
],
901 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS
],
902 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
907 * @dataProvider provideGetContentModel
908 * @covers Revision::getContentModel
910 public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
911 $rev = $this->newTestRevision( $text, $title, $model, $format );
913 $this->assertEquals( $expectedModel, $rev->getContentModel() );
916 public function provideGetContentFormat() {
917 // NOTE: we expect the help namespace to always contain wikitext
919 [ 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT
],
920 [ 'hello world', 'Help:Hello', CONTENT_MODEL_CSS
, null, CONTENT_FORMAT_CSS
],
921 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS
],
922 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
927 * @dataProvider provideGetContentFormat
928 * @covers Revision::getContentFormat
930 public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
931 $rev = $this->newTestRevision( $text, $title, $model, $format );
933 $this->assertEquals( $expectedFormat, $rev->getContentFormat() );
936 public function provideGetContentHandler() {
937 // NOTE: we expect the help namespace to always contain wikitext
939 [ 'hello world', 'Help:Hello', null, null, WikitextContentHandler
::class ],
940 [ 'hello world', 'User:hello/there.css', null, null, CssContentHandler
::class ],
941 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentHandlerForTesting
::class ],
946 * @dataProvider provideGetContentHandler
947 * @covers Revision::getContentHandler
949 public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
950 $rev = $this->newTestRevision( $text, $title, $model, $format );
952 $this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
955 public function provideGetContent() {
956 // NOTE: we expect the help namespace to always contain wikitext
958 [ 'hello world', 'Help:Hello', null, null, Revision
::FOR_PUBLIC
, 'hello world' ],
960 serialize( 'hello world' ),
962 DummyContentForTesting
::MODEL_ID
,
964 Revision
::FOR_PUBLIC
,
965 serialize( 'hello world' )
968 serialize( 'hello world' ),
972 Revision
::FOR_PUBLIC
,
973 serialize( 'hello world' )
979 * @dataProvider provideGetContent
980 * @covers Revision::getContent
982 public function testGetContent( $text, $title, $model, $format,
983 $audience, $expectedSerialization
985 $rev = $this->newTestRevision( $text, $title, $model, $format );
986 $content = $rev->getContent( $audience );
989 $expectedSerialization,
990 is_null( $content ) ?
null : $content->serialize( $format )
995 * @covers Revision::getContent
997 public function testGetContent_failure() {
998 $rev = new Revision( [
999 'page' => $this->testPage
->getId(),
1000 'content_model' => $this->testPage
->getContentModel(),
1001 'id' => 123456789, // not in the test DB
1004 Wikimedia\
suppressWarnings(); // bad text_id will trigger a warning.
1006 $this->assertNull( $rev->getContent(),
1007 "getContent() should return null if the revision's text blob could not be loaded." );
1009 // NOTE: check this twice, once for lazy initialization, and once with the cached value.
1010 $this->assertNull( $rev->getContent(),
1011 "getContent() should return null if the revision's text blob could not be loaded." );
1013 Wikimedia\restoreWarnings
();
1016 public function provideGetSize() {
1018 [ "hello world.", CONTENT_MODEL_WIKITEXT
, 12 ],
1019 [ serialize( "hello world." ), DummyContentForTesting
::MODEL_ID
, 12 ],
1024 * @covers Revision::getSize
1025 * @dataProvider provideGetSize
1027 public function testGetSize( $text, $model, $expected_size ) {
1028 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSize', $model );
1029 $this->assertEquals( $expected_size, $rev->getSize() );
1032 public function provideGetSha1() {
1034 [ "hello world.", CONTENT_MODEL_WIKITEXT
, Revision
::base36Sha1( "hello world." ) ],
1036 serialize( "hello world." ),
1037 DummyContentForTesting
::MODEL_ID
,
1038 Revision
::base36Sha1( serialize( "hello world." ) )
1044 * @covers Revision::getSha1
1045 * @dataProvider provideGetSha1
1047 public function testGetSha1( $text, $model, $expected_hash ) {
1048 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSha1', $model );
1049 $this->assertEquals( $expected_hash, $rev->getSha1() );
1053 * Tests whether $rev->getContent() returns a clone when needed.
1055 * @covers Revision::getContent
1057 public function testGetContentClone() {
1058 $content = new RevisionTestModifyableContent( "foo" );
1060 $rev = new Revision(
1064 'title' => Title
::newFromText( "testGetContentClone_dummy" ),
1066 'content' => $content,
1067 'length' => $content->getSize(),
1068 'comment' => "testing",
1069 'minor_edit' => false,
1073 /** @var RevisionTestModifyableContent $content */
1074 $content = $rev->getContent( Revision
::RAW
);
1075 $content->setText( "bar" );
1077 /** @var RevisionTestModifyableContent $content2 */
1078 $content2 = $rev->getContent( Revision
::RAW
);
1079 // content is mutable, expect clone
1080 $this->assertNotSame( $content, $content2, "expected a clone" );
1081 // clone should contain the original text
1082 $this->assertEquals( "foo", $content2->getText() );
1084 $content2->setText( "bla bla" );
1085 // clones should be independent
1086 $this->assertEquals( "bar", $content->getText() );
1090 * Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
1091 * @covers Revision::getContent
1093 public function testGetContentUncloned() {
1094 $rev = $this->newTestRevision( "hello", "testGetContentUncloned_dummy", CONTENT_MODEL_WIKITEXT
);
1095 $content = $rev->getContent( Revision
::RAW
);
1096 $content2 = $rev->getContent( Revision
::RAW
);
1098 // for immutable content like wikitext, this should be the same object
1099 $this->assertSame( $content, $content2 );
1103 * @covers Revision::loadFromId
1105 public function testLoadFromId() {
1106 $rev = $this->testPage
->getRevision();
1107 $this->hideDeprecated( 'Revision::loadFromId' );
1108 $this->assertRevEquals(
1110 Revision
::loadFromId( wfGetDB( DB_MASTER
), $rev->getId() )
1115 * @covers Revision::loadFromPageId
1117 public function testLoadFromPageId() {
1118 $this->assertRevEquals(
1119 $this->testPage
->getRevision(),
1120 Revision
::loadFromPageId( wfGetDB( DB_MASTER
), $this->testPage
->getId() )
1125 * @covers Revision::loadFromPageId
1127 public function testLoadFromPageIdWithLatestRevId() {
1128 $this->assertRevEquals(
1129 $this->testPage
->getRevision(),
1130 Revision
::loadFromPageId(
1131 wfGetDB( DB_MASTER
),
1132 $this->testPage
->getId(),
1133 $this->testPage
->getLatest()
1139 * @covers Revision::loadFromPageId
1141 public function testLoadFromPageIdWithNotLatestRevId() {
1142 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1143 $this->assertRevEquals(
1144 $this->testPage
->getRevision()->getPrevious(),
1145 Revision
::loadFromPageId(
1146 wfGetDB( DB_MASTER
),
1147 $this->testPage
->getId(),
1148 $this->testPage
->getRevision()->getPrevious()->getId()
1154 * @covers Revision::loadFromTitle
1156 public function testLoadFromTitle() {
1157 $this->assertRevEquals(
1158 $this->testPage
->getRevision(),
1159 Revision
::loadFromTitle( wfGetDB( DB_MASTER
), $this->testPage
->getTitle() )
1164 * @covers Revision::loadFromTitle
1166 public function testLoadFromTitleWithLatestRevId() {
1167 $this->assertRevEquals(
1168 $this->testPage
->getRevision(),
1169 Revision
::loadFromTitle(
1170 wfGetDB( DB_MASTER
),
1171 $this->testPage
->getTitle(),
1172 $this->testPage
->getLatest()
1178 * @covers Revision::loadFromTitle
1180 public function testLoadFromTitleWithNotLatestRevId() {
1181 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1182 $this->assertRevEquals(
1183 $this->testPage
->getRevision()->getPrevious(),
1184 Revision
::loadFromTitle(
1185 wfGetDB( DB_MASTER
),
1186 $this->testPage
->getTitle(),
1187 $this->testPage
->getRevision()->getPrevious()->getId()
1193 * @covers Revision::loadFromTimestamp()
1195 public function testLoadFromTimestamp() {
1196 $this->assertRevEquals(
1197 $this->testPage
->getRevision(),
1198 Revision
::loadFromTimestamp(
1199 wfGetDB( DB_MASTER
),
1200 $this->testPage
->getTitle(),
1201 $this->testPage
->getRevision()->getTimestamp()
1207 * @covers Revision::getParentLengths
1209 public function testGetParentLengths_noRevIds() {
1212 Revision
::getParentLengths(
1213 wfGetDB( DB_MASTER
),
1220 * @covers Revision::getParentLengths
1222 public function testGetParentLengths_oneRevId() {
1223 $text = '831jr091jr0921kr21kr0921kjr0921j09rj1';
1224 $textLength = strlen( $text );
1226 $this->testPage
->doEditContent( new WikitextContent( $text ), __METHOD__
);
1227 $rev[1] = $this->testPage
->getLatest();
1230 [ $rev[1] => $textLength ],
1231 Revision
::getParentLengths(
1232 wfGetDB( DB_MASTER
),
1239 * @covers Revision::getParentLengths
1241 public function testGetParentLengths_multipleRevIds() {
1242 $textOne = '831jr091jr0921kr21kr0921kjr0921j09rj1';
1243 $textOneLength = strlen( $textOne );
1244 $textTwo = '831jr091jr092121j09rj1';
1245 $textTwoLength = strlen( $textTwo );
1247 $this->testPage
->doEditContent( new WikitextContent( $textOne ), __METHOD__
);
1248 $rev[1] = $this->testPage
->getLatest();
1249 $this->testPage
->doEditContent( new WikitextContent( $textTwo ), __METHOD__
);
1250 $rev[2] = $this->testPage
->getLatest();
1253 [ $rev[1] => $textOneLength, $rev[2] => $textTwoLength ],
1254 Revision
::getParentLengths(
1255 wfGetDB( DB_MASTER
),
1256 [ $rev[1], $rev[2] ]
1262 * @covers Revision::getTitle
1264 public function testGetTitle_fromExistingRevision() {
1266 $this->testPage
->getTitle()->equals(
1267 $this->testPage
->getRevision()->getTitle()
1273 * @covers Revision::getTitle
1275 public function testGetTitle_fromRevisionWhichWillLoadTheTitle() {
1276 $rev = new Revision( [ 'id' => $this->testPage
->getLatest() ] );
1278 $this->testPage
->getTitle()->equals(
1285 * @covers Revision::isMinor
1287 public function testIsMinor_true() {
1288 // Use a sysop to ensure we can mark edits as minor
1289 $sysop = $this->getTestSysop()->getUser();
1291 $this->testPage
->doEditContent(
1292 new WikitextContent( __METHOD__
),
1298 $rev = $this->testPage
->getRevision();
1300 $this->assertSame( true, $rev->isMinor() );
1304 * @covers Revision::isMinor
1306 public function testIsMinor_false() {
1307 $this->testPage
->doEditContent(
1308 new WikitextContent( __METHOD__
),
1312 $rev = $this->testPage
->getRevision();
1314 $this->assertSame( false, $rev->isMinor() );
1318 * @covers Revision::getTimestamp
1320 public function testGetTimestamp() {
1321 $testTimestamp = wfTimestampNow();
1323 $this->testPage
->doEditContent(
1324 new WikitextContent( __METHOD__
),
1327 $rev = $this->testPage
->getRevision();
1329 $this->assertInternalType( 'string', $rev->getTimestamp() );
1330 $this->assertTrue( strlen( $rev->getTimestamp() ) == strlen( 'YYYYMMDDHHMMSS' ) );
1331 $this->assertContains( substr( $testTimestamp, 0, 10 ), $rev->getTimestamp() );
1335 * @covers Revision::getUser
1336 * @covers Revision::getUserText
1338 public function testGetUserAndText() {
1339 $sysop = $this->getTestSysop()->getUser();
1341 $this->testPage
->doEditContent(
1342 new WikitextContent( __METHOD__
),
1348 $rev = $this->testPage
->getRevision();
1350 $this->assertSame( $sysop->getId(), $rev->getUser() );
1351 $this->assertSame( $sysop->getName(), $rev->getUserText() );
1355 * @covers Revision::isDeleted
1357 public function testIsDeleted_nothingDeleted() {
1358 $rev = $this->testPage
->getRevision();
1360 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_TEXT
) );
1361 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_COMMENT
) );
1362 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_RESTRICTED
) );
1363 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_USER
) );
1367 * @covers Revision::getVisibility
1369 public function testGetVisibility_nothingDeleted() {
1370 $rev = $this->testPage
->getRevision();
1372 $this->assertSame( 0, $rev->getVisibility() );
1376 * @covers Revision::getComment
1378 public function testGetComment_notDeleted() {
1379 $expectedSummary = 'goatlicious summary';
1381 $this->testPage
->doEditContent(
1382 new WikitextContent( __METHOD__
),
1385 $rev = $this->testPage
->getRevision();
1387 $this->assertSame( $expectedSummary, $rev->getComment() );
1391 * @covers Revision::isUnpatrolled
1393 public function testIsUnpatrolled_returnsRecentChangesId() {
1394 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1395 $rev = $this->testPage
->getRevision();
1397 $this->assertGreaterThan( 0, $rev->isUnpatrolled() );
1398 $this->assertSame( $rev->getRecentChange()->getAttribute( 'rc_id' ), $rev->isUnpatrolled() );
1402 * @covers Revision::isUnpatrolled
1404 public function testIsUnpatrolled_returnsZeroIfPatrolled() {
1405 // This assumes that sysops are auto patrolled
1406 $sysop = $this->getTestSysop()->getUser();
1407 $this->testPage
->doEditContent(
1408 new WikitextContent( __METHOD__
),
1414 $rev = $this->testPage
->getRevision();
1416 $this->assertSame( 0, $rev->isUnpatrolled() );
1420 * This is a simple blanket test for all simple content getters and is methods to provide some
1421 * coverage before the split of Revision into multiple classes for MCR work.
1422 * @covers Revision::getContent
1423 * @covers Revision::getSerializedData
1424 * @covers Revision::getContentModel
1425 * @covers Revision::getContentFormat
1426 * @covers Revision::getContentHandler
1428 public function testSimpleContentGetters() {
1429 $expectedText = 'testSimpleContentGetters in Revision. Goats love MCR...';
1430 $expectedSummary = 'goatlicious testSimpleContentGetters summary';
1432 $this->testPage
->doEditContent(
1433 new WikitextContent( $expectedText ),
1436 $rev = $this->testPage
->getRevision();
1438 $this->assertSame( $expectedText, $rev->getContent()->getText() );
1439 $this->assertSame( $expectedText, $rev->getSerializedData() );
1440 $this->assertSame( $this->testPage
->getContentModel(), $rev->getContentModel() );
1441 $this->assertSame( $this->testPage
->getContent()->getDefaultFormat(), $rev->getContentFormat() );
1442 $this->assertSame( $this->testPage
->getContentHandler(), $rev->getContentHandler() );
1446 * @covers Revision::newKnownCurrent
1448 public function testNewKnownCurrent() {
1449 // Setup the services
1450 $this->overrideMwServices();
1451 $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
1452 $this->setService( 'MainWANObjectCache', $cache );
1453 $db = wfGetDB( DB_MASTER
);
1456 $cache->setMockTime( $now );
1458 // Get a fresh revision to use during testing
1459 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1460 $rev = $this->testPage
->getRevision();
1462 // Clear any previous cache for the revision during creation
1463 $key = $cache->makeGlobalKey(
1464 RevisionStore
::ROW_CACHE_KEY
,
1469 $cache->delete( $key, WANObjectCache
::HOLDOFF_TTL_NONE
);
1470 $this->assertFalse( $cache->get( $key ) );
1474 // Get the new revision and make sure it is in the cache and correct
1475 $newRev = Revision
::newKnownCurrent( $db, $rev->getPage(), $rev->getId() );
1476 $this->assertRevEquals( $rev, $newRev );
1478 $cachedRow = $cache->get( $key );
1479 $this->assertNotFalse( $cachedRow );
1480 $this->assertEquals( $rev->getId(), $cachedRow->rev_id
);
1483 public function testNewKnownCurrent_withPageId() {
1484 $db = wfGetDB( DB_MASTER
);
1486 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1487 $rev = $this->testPage
->getRevision();
1489 $pageId = $this->testPage
->getId();
1491 $newRev = Revision
::newKnownCurrent( $db, $pageId, $rev->getId() );
1492 $this->assertRevEquals( $rev, $newRev );
1495 public function testNewKnownCurrent_returnsFalseWhenTitleDoesntExist() {
1496 $db = wfGetDB( DB_MASTER
);
1498 $this->assertFalse( Revision
::newKnownCurrent( $db, 0 ) );
1501 public function provideUserCanBitfield() {
1502 yield
[ 0, 0, [], null, true ];
1503 // Bitfields match, user has no permissions
1504 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [], null, false ];
1505 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [], null, false ];
1506 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [], null, false ];
1507 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [], null, false ];
1508 // Bitfields match, user (admin) does have permissions
1509 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [ 'sysop' ], null, true ];
1510 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [ 'sysop' ], null, true ];
1511 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [ 'sysop' ], null, true ];
1512 // Bitfields match, user (admin) does not have permissions
1513 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'sysop' ], null, false ];
1514 // Bitfields match, user (oversight) does have permissions
1515 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'oversight' ], null, true ];
1516 // Check permissions using the title
1518 Revision
::DELETED_TEXT
,
1519 Revision
::DELETED_TEXT
,
1525 Revision
::DELETED_TEXT
,
1526 Revision
::DELETED_TEXT
,
1534 * @dataProvider provideUserCanBitfield
1535 * @covers Revision::userCanBitfield
1537 public function testUserCanBitfield( $bitField, $field, $userGroups, $title, $expected ) {
1538 $title = Title
::newFromText( $title );
1540 $this->setGroupPermissions(
1543 'deletedtext' => true,
1544 'deletedhistory' => true,
1547 'viewsuppressed' => true,
1548 'suppressrevision' => true,
1552 $user = $this->getTestUser( $userGroups )->getUser();
1556 Revision
::userCanBitfield( $bitField, $field, $user, $title )
1559 // Fallback to $wgUser
1560 $this->setMwGlobals(
1566 Revision
::userCanBitfield( $bitField, $field, null, $title )
1570 public function provideUserCan() {
1571 yield
[ 0, 0, [], true ];
1572 // Bitfields match, user has no permissions
1573 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [], false ];
1574 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [], false ];
1575 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [], false ];
1576 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [], false ];
1577 // Bitfields match, user (admin) does have permissions
1578 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [ 'sysop' ], true ];
1579 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [ 'sysop' ], true ];
1580 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [ 'sysop' ], true ];
1581 // Bitfields match, user (admin) does not have permissions
1582 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'sysop' ], false ];
1583 // Bitfields match, user (oversight) does have permissions
1584 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'oversight' ], true ];
1588 * @dataProvider provideUserCan
1589 * @covers Revision::userCan
1591 public function testUserCan( $bitField, $field, $userGroups, $expected ) {
1592 $this->setGroupPermissions(
1595 'deletedtext' => true,
1596 'deletedhistory' => true,
1599 'viewsuppressed' => true,
1600 'suppressrevision' => true,
1604 $user = $this->getTestUser( $userGroups )->getUser();
1605 $revision = new Revision( [ 'deleted' => $bitField ], 0, $this->testPage
->getTitle() );
1609 $revision->userCan( $field, $user )
1613 public function provideGetTextId() {
1616 $slot = new SlotRecord( (object)[
1617 'slot_revision_id' => 42,
1618 'slot_content_id' => 1,
1619 'content_address' => 'tt:789',
1620 'model_name' => CONTENT_MODEL_WIKITEXT
,
1621 'role_name' => SlotRecord
::MAIN
,
1623 ], new WikitextContent( 'Test' ) );
1625 $rec = new MutableRevisionRecord( $this->testPage
->getTitle() );
1627 $rec->setSlot( $slot );
1629 yield
[ $rec, 789 ];
1633 * @dataProvider provideGetTextId
1634 * @covers Revision::getTextId()
1636 public function testGetTextId( $spec, $expected ) {
1637 $rev = new Revision( $spec, 0, $this->testPage
->getTitle() );
1638 $this->assertSame( $expected, $rev->getTextId() );
1641 abstract public function provideGetRevisionText();
1644 * @dataProvider provideGetRevisionText
1645 * @covers Revision::getRevisionText
1647 public function testGetRevisionText( array $queryInfoOptions, array $queryInfoExtra = [] ) {
1648 $rev = $this->testPage
->getRevisionRecord();
1650 $queryInfo = Revision
::getQueryInfo( $queryInfoOptions );
1651 $queryInfo['tables'] = array_merge( $queryInfo['tables'], $queryInfoExtra['tables'] ??
[] );
1652 $queryInfo['fields'] = array_merge( $queryInfo['fields'], $queryInfoExtra['fields'] ??
[] );
1653 $queryInfo['joins'] = array_merge( $queryInfo['joins'], $queryInfoExtra['joins'] ??
[] );
1655 $conds = [ 'rev_id' => $rev->getId() ];
1656 $row = $this->db
->selectRow(
1657 $queryInfo['tables'],
1658 $queryInfo['fields'],
1665 $expected = $rev->getContent( SlotRecord
::MAIN
)->serialize();
1667 $this->hideDeprecated( 'Revision::getRevisionText (MCR without SCHEMA_COMPAT_WRITE_OLD)' );
1668 $this->assertSame( $expected, Revision
::getRevisionText( $row ) );