}
$updater->saveRevision( CommentStoreComment::newUnsavedComment( "testing" ) );
+ if ( !$updater->wasSuccessful() ) {
+ $this->fail( $updater->getStatus()->getWikiText() );
+ }
return $page;
}
);
$logId = $status->getValue();
$actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+ $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
$this->assertSelect(
- [ 'logging' ] + $actorQuery['tables'], /* table */
+ [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
[
'log_type',
'log_action',
- 'log_comment',
+ 'log_comment' => $commentQuery['fields']['log_comment_text'],
'log_user' => $actorQuery['fields']['log_user'],
'log_user_text' => $actorQuery['fields']['log_user_text'],
'log_namespace',
$page->getTitle()->getDBkey(),
] ],
[],
- $actorQuery['joins']
+ $actorQuery['joins'] + $commentQuery['joins']
);
}
);
$logId = $status->getValue();
$actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+ $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
$this->assertSelect(
- [ 'logging' ] + $actorQuery['tables'], /* table */
+ [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
[
'log_type',
'log_action',
- 'log_comment',
+ 'log_comment' => $commentQuery['fields']['log_comment_text'],
'log_user' => $actorQuery['fields']['log_user'],
'log_user_text' => $actorQuery['fields']['log_user_text'],
'log_namespace',
$page->getTitle()->getDBkey(),
] ],
[],
- $actorQuery['joins']
+ $actorQuery['joins'] + $commentQuery['joins']
);
}
);
$logId = $status->getValue();
$actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+ $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
$this->assertSelect(
- [ 'logging' ] + $actorQuery['tables'], /* table */
+ [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'], /* table */
[
'log_type',
'log_action',
- 'log_comment',
+ 'log_comment' => $commentQuery['fields']['log_comment_text'],
'log_user' => $actorQuery['fields']['log_user'],
'log_user_text' => $actorQuery['fields']['log_user_text'],
'log_namespace',
$page->getTitle()->getDBkey(),
] ],
[],
- $actorQuery['joins']
+ $actorQuery['joins'] + $commentQuery['joins']
);
$this->assertNull(
$this->assertTrue( $page->wasLoadedFrom( IDBAccessObject::READ_EXCLUSIVE ) );
}
- /**
- * @dataProvider provideCommentMigrationOnDeletion
- *
- * @param int $writeStage
- * @param int $readStage
- */
- public function testCommentMigrationOnDeletion( $writeStage, $readStage ) {
- $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', $writeStage );
- $this->overrideMwServices();
-
- $dbr = wfGetDB( DB_REPLICA );
-
- $page = $this->createPage(
- __METHOD__,
- "foo",
- CONTENT_MODEL_WIKITEXT
- );
- $revid = $page->getLatest();
- if ( $writeStage > MIGRATION_OLD ) {
- $comment_id = $dbr->selectField(
- 'revision_comment_temp',
- 'revcomment_comment_id',
- [ 'revcomment_rev' => $revid ],
- __METHOD__
- );
- }
-
- $this->setMwGlobals( 'wgCommentTableSchemaMigrationStage', $readStage );
- $this->overrideMwServices();
-
- $page->doDeleteArticle( "testing deletion" );
-
- if ( $readStage > MIGRATION_OLD ) {
- // Didn't leave behind any 'revision_comment_temp' rows
- $n = $dbr->selectField(
- 'revision_comment_temp', 'COUNT(*)', [ 'revcomment_rev' => $revid ], __METHOD__
- );
- $this->assertEquals( 0, $n, 'no entry in revision_comment_temp after deletion' );
-
- // Copied or upgraded the comment_id, as applicable
- $ar_comment_id = $dbr->selectField(
- 'archive',
- 'ar_comment_id',
- [ 'ar_rev_id' => $revid ],
- __METHOD__
- );
- if ( $writeStage > MIGRATION_OLD ) {
- $this->assertSame( $comment_id, $ar_comment_id );
- } else {
- $this->assertNotEquals( 0, $ar_comment_id );
- }
- }
-
- // Copied rev_comment, if applicable
- if ( $readStage <= MIGRATION_WRITE_BOTH && $writeStage <= MIGRATION_WRITE_BOTH ) {
- $ar_comment = $dbr->selectField(
- 'archive',
- 'ar_comment',
- [ 'ar_rev_id' => $revid ],
- __METHOD__
- );
- $this->assertSame( 'testing', $ar_comment );
- }
- }
-
- public function provideCommentMigrationOnDeletion() {
- return [
- [ MIGRATION_OLD, MIGRATION_OLD ],
- [ MIGRATION_OLD, MIGRATION_WRITE_BOTH ],
- [ MIGRATION_OLD, MIGRATION_WRITE_NEW ],
- [ MIGRATION_WRITE_BOTH, MIGRATION_OLD ],
- [ MIGRATION_WRITE_BOTH, MIGRATION_WRITE_BOTH ],
- [ MIGRATION_WRITE_BOTH, MIGRATION_WRITE_NEW ],
- [ MIGRATION_WRITE_BOTH, MIGRATION_NEW ],
- [ MIGRATION_WRITE_NEW, MIGRATION_WRITE_BOTH ],
- [ MIGRATION_WRITE_NEW, MIGRATION_WRITE_NEW ],
- [ MIGRATION_WRITE_NEW, MIGRATION_NEW ],
- [ MIGRATION_NEW, MIGRATION_WRITE_BOTH ],
- [ MIGRATION_NEW, MIGRATION_WRITE_NEW ],
- [ MIGRATION_NEW, MIGRATION_NEW ],
- ];
- }
-
/**
* @covers WikiPage::updateCategoryCounts
*/
wfTimestamp( TS_UNIX, $initialRevision->getTimestamp() ) - 1
);
- $olderRevison = new Revision(
+ $olderRevision = new Revision(
[
'id' => 9989,
'page' => $page->getId(),
]
);
- $result = $page->updateIfNewerOn( $this->db, $olderRevison );
+ $result = $page->updateIfNewerOn( $this->db, $olderRevision );
$this->assertFalse( $result );
}
// Make sure the log entry looks good
// log_params is not checked here
$actorQuery = ActorMigration::newMigration()->getJoin( 'log_user' );
+ $commentQuery = MediaWikiServices::getInstance()->getCommentStore()->getJoin( 'log_comment' );
$this->assertSelect(
- [ 'logging' ] + $actorQuery['tables'],
+ [ 'logging' ] + $actorQuery['tables'] + $commentQuery['tables'],
[
- 'log_comment',
+ 'log_comment' => $commentQuery['fields']['log_comment_text'],
'log_user' => $actorQuery['fields']['log_user'],
'log_user_text' => $actorQuery['fields']['log_user_text'],
'log_namespace',
$page->getTitle()->getDBkey(),
] ],
[],
- $actorQuery['joins']
+ $actorQuery['joins'] + $commentQuery['joins']
);
}