Use PageUpdater's fluent interface as in some parts of our codebase
Some methods in the PageUpdater's class implements the fluent interface design pattern. Use the fluent interface where need be. Change-Id: If76a4b8c5070c20ed40038a4ee78e2d677de5180
This commit is contained in:
parent
7a545309c7
commit
2432cc2bb4
8 changed files with 39 additions and 42 deletions
|
|
@ -2078,8 +2078,8 @@ class EditPage implements IEditObject {
|
|||
$result['sectionanchor'] = $anchor;
|
||||
}
|
||||
|
||||
$pageUpdater = $this->page->newPageUpdater( $user );
|
||||
$pageUpdater->setContent( SlotRecord::MAIN, $content );
|
||||
$pageUpdater = $this->page->newPageUpdater( $user )
|
||||
->setContent( SlotRecord::MAIN, $content );
|
||||
$pageUpdater->prepareUpdate( $flags );
|
||||
|
||||
// BEGINNING OF MIGRATION TO EDITCONSTRAINT SYSTEM (see T157658)
|
||||
|
|
@ -2240,8 +2240,8 @@ class EditPage implements IEditObject {
|
|||
return Status::newGood( self::AS_CONFLICT_DETECTED )->setOK( false );
|
||||
}
|
||||
|
||||
$pageUpdater = $this->page->newPageUpdater( $user );
|
||||
$pageUpdater->setContent( SlotRecord::MAIN, $content );
|
||||
$pageUpdater = $this->page->newPageUpdater( $user )
|
||||
->setContent( SlotRecord::MAIN, $content );
|
||||
$pageUpdater->prepareUpdate( $flags );
|
||||
|
||||
// BEGINNING OF MIGRATION TO EDITCONSTRAINT SYSTEM (see T157658)
|
||||
|
|
|
|||
|
|
@ -2074,8 +2074,8 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
|
|||
*/
|
||||
private function createRevisionStoreCacheRecord( $page, $store ) {
|
||||
$user = MediaWikiIntegrationTestCase::getMutableTestUser()->getUser();
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
$updater->setContent( SlotRecord::MAIN, new WikitextContent( __METHOD__ ) );
|
||||
$updater = $page->newPageUpdater( $user )
|
||||
->setContent( SlotRecord::MAIN, new WikitextContent( __METHOD__ ) );
|
||||
$summary = CommentStoreComment::newUnsavedComment( __METHOD__ );
|
||||
$rev = $updater->saveRevision( $summary, EDIT_NEW );
|
||||
return $store->getKnownCurrentRevision( $page->getTitle(), $rev->getId() );
|
||||
|
|
|
|||
|
|
@ -170,8 +170,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertSame( $oldStats->ss_total_edits + 1, (int)$stats->ss_total_edits );
|
||||
|
||||
// re-edit with same content - should be a "null-edit"
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
$updater->setContent( SlotRecord::MAIN, $content );
|
||||
$updater = $page->newPageUpdater( $user )
|
||||
->setContent( SlotRecord::MAIN, $content );
|
||||
|
||||
$summary = CommentStoreComment::newUnsavedComment( 'to to re-edit' );
|
||||
$rev = $updater->saveRevision( $summary );
|
||||
|
|
@ -266,8 +266,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
$this->assertNotNull( $rc, 'RecentChange' );
|
||||
|
||||
// re-edit
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
$updater->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
|
||||
$updater = $page->newPageUpdater( $user )
|
||||
->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
|
||||
|
||||
$summary = CommentStoreComment::newUnsavedComment( 're-edit' );
|
||||
$updater->saveRevision( $summary );
|
||||
|
|
@ -278,8 +278,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
$topRevisionId = $updater->getNewRevision()->getId();
|
||||
|
||||
// perform a null edit
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
$updater->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
|
||||
$updater = $page->newPageUpdater( $user )
|
||||
->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
|
||||
$summary = CommentStoreComment::newUnsavedComment( 'null edit' );
|
||||
$updater->saveRevision( $summary );
|
||||
|
||||
|
|
@ -310,21 +310,21 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
$user = $this->getTestUser()->getUser();
|
||||
|
||||
$summary = CommentStoreComment::newUnsavedComment( '1' );
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
$updater->setContent( SlotRecord::MAIN, new TextContent( '1' ) );
|
||||
$updater = $page->newPageUpdater( $user )
|
||||
->setContent( SlotRecord::MAIN, new TextContent( '1' ) );
|
||||
$updater->saveRevision( $summary );
|
||||
$revId1 = $updater->getNewRevision()->getId();
|
||||
|
||||
$summary = CommentStoreComment::newUnsavedComment( '2' );
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
$updater->setContent( SlotRecord::MAIN, new TextContent( '2' ) );
|
||||
$updater = $page->newPageUpdater( $user )
|
||||
->setContent( SlotRecord::MAIN, new TextContent( '2' ) );
|
||||
$updater->saveRevision( $summary );
|
||||
$revId2 = $updater->getNewRevision()->getId();
|
||||
|
||||
// Perform a rollback
|
||||
$updater = $page->newPageUpdater( $this->getTestSysop()->getUser() );
|
||||
$updater->setContent( SlotRecord::MAIN, new TextContent( '1' ) );
|
||||
$updater->markAsRevert( EditResult::REVERT_ROLLBACK, $revId2, $revId1 );
|
||||
$updater = $page->newPageUpdater( $this->getTestSysop()->getUser() )
|
||||
->setContent( SlotRecord::MAIN, new TextContent( '1' ) )
|
||||
->markAsRevert( EditResult::REVERT_ROLLBACK, $revId2, $revId1 );
|
||||
$summary = CommentStoreComment::newUnsavedComment( 'revert' );
|
||||
$updater->saveRevision( $summary );
|
||||
|
||||
|
|
@ -465,8 +465,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
// start editing non-existing page
|
||||
$page = WikiPage::factory( $title );
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
$updater->setContent( SlotRecord::MAIN, new TextContent( 'Lorem Ipsum' ) );
|
||||
$updater = $page->newPageUpdater( $user )
|
||||
->setContent( SlotRecord::MAIN, new TextContent( 'Lorem Ipsum' ) );
|
||||
|
||||
$summary = CommentStoreComment::newUnsavedComment( 'Just a test' );
|
||||
|
||||
|
|
@ -570,8 +570,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
// update with EDIT_NEW flag should fail
|
||||
$summary = CommentStoreComment::newUnsavedComment( 'create?!' );
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
$updater->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
|
||||
$updater = $page->newPageUpdater( $user )
|
||||
->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
|
||||
$updater->saveRevision( $summary, EDIT_NEW );
|
||||
$status = $updater->getStatus();
|
||||
|
||||
|
|
@ -591,11 +591,11 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
// start editing non-existing page
|
||||
$page = WikiPage::factory( $title );
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
|
||||
// plain text content should fail in aux slot (the main slot doesn't care)
|
||||
$updater->setContent( 'main', new TextContent( 'Main Content' ) );
|
||||
$updater->setContent( 'aux', new TextContent( 'Aux Content' ) );
|
||||
$updater = $page->newPageUpdater( $user )
|
||||
->setContent( 'main', new TextContent( 'Main Content' ) )
|
||||
->setContent( 'aux', new TextContent( 'Aux Content' ) );
|
||||
|
||||
$summary = CommentStoreComment::newUnsavedComment( 'udpate?!' );
|
||||
$updater->saveRevision( $summary, EDIT_UPDATE );
|
||||
|
|
@ -648,8 +648,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
// Create page
|
||||
$page = WikiPage::factory( $title );
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
$updater->setContent( 'main', new TextContent( 'Content 1' ) );
|
||||
$updater = $page->newPageUpdater( $user )
|
||||
->setContent( 'main', new TextContent( 'Content 1' ) );
|
||||
$updater->saveRevision( $summary, EDIT_NEW );
|
||||
$this->assertTrue( $updater->wasSuccessful(), 'wasSuccessful()' );
|
||||
|
||||
|
|
|
|||
|
|
@ -74,11 +74,8 @@ class MessageCacheTest extends MediaWikiLangTestCase {
|
|||
$wikiPage = new WikiPage( $title );
|
||||
$content = ContentHandler::makeContent( $content, $title );
|
||||
|
||||
$updater = $wikiPage->newPageUpdater( $this->getTestSysop()->getUser() );
|
||||
$updater->setContent(
|
||||
SlotRecord::MAIN,
|
||||
$content
|
||||
);
|
||||
$updater = $wikiPage->newPageUpdater( $this->getTestSysop()->getUser() )
|
||||
->setContent( SlotRecord::MAIN, $content );
|
||||
$summary = CommentStoreComment::newUnsavedComment( "$lang translation test case" );
|
||||
$inserted = $updater->saveRevision( $summary );
|
||||
|
||||
|
|
|
|||
|
|
@ -50,8 +50,7 @@ class ArticleViewTest extends MediaWikiIntegrationTestCase {
|
|||
$cont = new WikitextContent( $cont );
|
||||
}
|
||||
|
||||
$u = $page->newPageUpdater( $user );
|
||||
$u->setContent( SlotRecord::MAIN, $cont );
|
||||
$u = $page->newPageUpdater( $user )->setContent( SlotRecord::MAIN, $cont );
|
||||
$rev = $u->saveRevision( CommentStoreComment::newUnsavedComment( 'Rev ' . $key ) );
|
||||
|
||||
$revisions[ $key ] = $rev;
|
||||
|
|
|
|||
|
|
@ -2057,8 +2057,8 @@ more stuff
|
|||
$slotsUpdate = new revisionSlotsUpdate();
|
||||
$slotsUpdate->modifyContent( SlotRecord::MAIN, $content );
|
||||
|
||||
$updater = $page->newPageUpdater( $user, $slotsUpdate );
|
||||
$updater->setContent( SlotRecord::MAIN, $content );
|
||||
$updater = $page->newPageUpdater( $user, $slotsUpdate )
|
||||
->setContent( SlotRecord::MAIN, $content );
|
||||
$revision = $updater->saveRevision(
|
||||
CommentStoreComment::newUnsavedComment( 'test' ),
|
||||
EDIT_NEW
|
||||
|
|
|
|||
|
|
@ -59,10 +59,11 @@ class PoolWorkArticleViewTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
private function makeRevision( WikiPage $page, $text ) {
|
||||
$user = $this->getTestUser()->getUser();
|
||||
$updater = $page->newPageUpdater( $user );
|
||||
$updater = $page->newPageUpdater( $user )
|
||||
->setContent( SlotRecord::MAIN, new WikitextContent( $text ) )
|
||||
->saveRevision( CommentStoreComment::newUnsavedComment( 'testing' ) );
|
||||
|
||||
$updater->setContent( SlotRecord::MAIN, new WikitextContent( $text ) );
|
||||
return $updater->saveRevision( CommentStoreComment::newUnsavedComment( 'testing' ) );
|
||||
return $updater;
|
||||
}
|
||||
|
||||
public function testDoWorkLoadRevision() {
|
||||
|
|
|
|||
|
|
@ -62,8 +62,8 @@ class DeletePageTest extends MediaWikiIntegrationTestCase {
|
|||
|
||||
$content = ContentHandler::makeContent( $content, $page->getTitle(), CONTENT_MODEL_WIKITEXT );
|
||||
|
||||
$updater = $page->newPageUpdater( $performer );
|
||||
$updater->setContent( 'main', $content );
|
||||
$updater = $page->newPageUpdater( $performer )
|
||||
->setContent( 'main', $content );
|
||||
|
||||
$updater->saveRevision( CommentStoreComment::newUnsavedComment( "testing" ) );
|
||||
if ( !$updater->wasSuccessful() ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue