mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
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:
parent
a5f5710aff
commit
c81dad3efc
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use MediaWiki\MediaWikiServices;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements EchoContainmentList interface for sourcing a list of items from a wiki
|
* Implements EchoContainmentList interface for sourcing a list of items from a wiki
|
||||||
* page. Uses the pages latest revision ID as cache key.
|
* page. Uses the pages latest revision ID as cache key.
|
||||||
|
@ -30,8 +32,8 @@ class EchoOnWikiList implements EchoContainmentList {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$article = WikiPage::newFromID( $this->title->getArticleID() );
|
$article = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( $this->title );
|
||||||
if ( $article === null || !$article->exists() ) {
|
if ( !$article->exists() ) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ class GenerateSampleNotifications extends Maintenance {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addToPageContent( Title $title, User $agent, $contentText ) {
|
private function addToPageContent( Title $title, User $agent, $contentText ) {
|
||||||
$page = WikiPage::factory( $title );
|
$page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( $title );
|
||||||
$previousContent = "";
|
$previousContent = "";
|
||||||
$page->loadPageData( WikiPage::READ_LATEST );
|
$page->loadPageData( WikiPage::READ_LATEST );
|
||||||
$revision = $page->getRevisionRecord();
|
$revision = $page->getRevisionRecord();
|
||||||
|
@ -271,7 +271,7 @@ class GenerateSampleNotifications extends Maintenance {
|
||||||
|
|
||||||
// revert (undo)
|
// revert (undo)
|
||||||
$moai = Title::newFromText( 'Moai' );
|
$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->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, $agent, "\ncreating a good revision here\n" );
|
||||||
$this->addToPageContent( $moai, $user, "\nadding a line here\n" );
|
$this->addToPageContent( $moai, $user, "\nadding a line here\n" );
|
||||||
|
|
|
@ -948,8 +948,9 @@ TEXT
|
||||||
$pages += [ $title => '' ];
|
$pages += [ $title => '' ];
|
||||||
|
|
||||||
$user = $this->getTestUser()->getUser();
|
$user = $this->getTestUser()->getUser();
|
||||||
|
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
|
||||||
foreach ( $pages as $pageTitle => $pageText ) {
|
foreach ( $pages as $pageTitle => $pageText ) {
|
||||||
$template = WikiPage::factory( Title::newFromText( $pageTitle ) );
|
$template = $wikiPageFactory->newFromTitle( Title::newFromText( $pageTitle ) );
|
||||||
$template->doUserEditContent( new WikitextContent( $pageText ), $user, '' );
|
$template->doUserEditContent( new WikitextContent( $pageText ), $user, '' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ class MWEchoThankYouEditTest extends MediaWikiIntegrationTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function edit( Title $title, User $user, $text ) {
|
private function edit( Title $title, User $user, $text ) {
|
||||||
$page = WikiPage::factory( $title );
|
$page = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
|
||||||
$content = ContentHandler::makeContent( $text, $title );
|
$content = ContentHandler::makeContent( $text, $title );
|
||||||
$page->doUserEditContent( $content, $user, 'test' );
|
$page->doUserEditContent( $content, $user, 'test' );
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ class EchoUserLocatorTest extends MediaWikiIntegrationTestCase {
|
||||||
*/
|
*/
|
||||||
public function testLocateArticleCreator( $message, $initialize ) {
|
public function testLocateArticleCreator( $message, $initialize ) {
|
||||||
list( $expect, $title, $user ) = $initialize();
|
list( $expect, $title, $user ) = $initialize();
|
||||||
WikiPage::factory( $title )->doUserEditContent(
|
$this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title )->doUserEditContent(
|
||||||
/* $content = */ ContentHandler::makeContent( 'content', $title ),
|
/* $content = */ ContentHandler::makeContent( 'content', $title ),
|
||||||
/* $user = */ $user,
|
/* $user = */ $user,
|
||||||
/* $summary = */ 'summary'
|
/* $summary = */ 'summary'
|
||||||
|
|
Loading…
Reference in a new issue