Replace deprecated WikiPage::factory/newFromID

Replaced WikiPage::newFromID with newFromTitle,
because a Title object exists and could be reused

Bug: T297688
Change-Id: Ide30f259477ed8e0b48df31f5a23cafeb38d7316
This commit is contained in:
Umherirrender 2022-06-03 23:00:26 +02:00
parent a5f5710aff
commit c81dad3efc
5 changed files with 10 additions and 7 deletions

View file

@ -1,5 +1,7 @@
<?php
use MediaWiki\MediaWikiServices;
/**
* Implements EchoContainmentList interface for sourcing a list of items from a wiki
* page. Uses the pages latest revision ID as cache key.
@ -30,8 +32,8 @@ class EchoOnWikiList implements EchoContainmentList {
return [];
}
$article = WikiPage::newFromID( $this->title->getArticleID() );
if ( $article === null || !$article->exists() ) {
$article = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( $this->title );
if ( !$article->exists() ) {
return [];
}

View file

@ -213,7 +213,7 @@ class GenerateSampleNotifications extends Maintenance {
}
private function addToPageContent( Title $title, User $agent, $contentText ) {
$page = WikiPage::factory( $title );
$page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( $title );
$previousContent = "";
$page->loadPageData( WikiPage::READ_LATEST );
$revision = $page->getRevisionRecord();
@ -271,7 +271,7 @@ class GenerateSampleNotifications extends Maintenance {
// revert (undo)
$moai = Title::newFromText( 'Moai' );
$page = WikiPage::factory( $moai );
$page = $services->getWikiPageFactory()->newFromTitle( $moai );
$this->output( "{$agent->getName()} is reverting {$user->getName()}'s edit on {$moai->getPrefixedText()}\n" );
$this->addToPageContent( $moai, $agent, "\ncreating a good revision here\n" );
$this->addToPageContent( $moai, $user, "\nadding a line here\n" );

View file

@ -948,8 +948,9 @@ TEXT
$pages += [ $title => '' ];
$user = $this->getTestUser()->getUser();
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
foreach ( $pages as $pageTitle => $pageText ) {
$template = WikiPage::factory( Title::newFromText( $pageTitle ) );
$template = $wikiPageFactory->newFromTitle( Title::newFromText( $pageTitle ) );
$template->doUserEditContent( new WikitextContent( $pageText ), $user, '' );
}

View file

@ -70,7 +70,7 @@ class MWEchoThankYouEditTest extends MediaWikiIntegrationTestCase {
}
private function edit( Title $title, User $user, $text ) {
$page = WikiPage::factory( $title );
$page = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
$content = ContentHandler::makeContent( $text, $title );
$page->doUserEditContent( $content, $user, 'test' );
}

View file

@ -108,7 +108,7 @@ class EchoUserLocatorTest extends MediaWikiIntegrationTestCase {
*/
public function testLocateArticleCreator( $message, $initialize ) {
list( $expect, $title, $user ) = $initialize();
WikiPage::factory( $title )->doUserEditContent(
$this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title )->doUserEditContent(
/* $content = */ ContentHandler::makeContent( 'content', $title ),
/* $user = */ $user,
/* $summary = */ 'summary'