From c81dad3efc88a90fa4dd756049132e2c62a5d22b Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Fri, 3 Jun 2022 23:00:26 +0200 Subject: [PATCH] Replace deprecated WikiPage::factory/newFromID Replaced WikiPage::newFromID with newFromTitle, because a Title object exists and could be reused Bug: T297688 Change-Id: Ide30f259477ed8e0b48df31f5a23cafeb38d7316 --- includes/EchoOnWikiList.php | 6 ++++-- maintenance/generateSampleNotifications.php | 4 ++-- tests/phpunit/DiscussionParserTest.php | 3 ++- tests/phpunit/ThankYouEditTest.php | 2 +- tests/phpunit/UserLocatorTest.php | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/includes/EchoOnWikiList.php b/includes/EchoOnWikiList.php index 19dee29f7..adfbb8f2b 100644 --- a/includes/EchoOnWikiList.php +++ b/includes/EchoOnWikiList.php @@ -1,5 +1,7 @@ title->getArticleID() ); - if ( $article === null || !$article->exists() ) { + $article = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( $this->title ); + if ( !$article->exists() ) { return []; } diff --git a/maintenance/generateSampleNotifications.php b/maintenance/generateSampleNotifications.php index 7f52ae263..f9dbbac7c 100644 --- a/maintenance/generateSampleNotifications.php +++ b/maintenance/generateSampleNotifications.php @@ -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" ); diff --git a/tests/phpunit/DiscussionParserTest.php b/tests/phpunit/DiscussionParserTest.php index a2076ee93..c5a3474ce 100644 --- a/tests/phpunit/DiscussionParserTest.php +++ b/tests/phpunit/DiscussionParserTest.php @@ -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, '' ); } diff --git a/tests/phpunit/ThankYouEditTest.php b/tests/phpunit/ThankYouEditTest.php index 3c2448dd8..a1bb01091 100644 --- a/tests/phpunit/ThankYouEditTest.php +++ b/tests/phpunit/ThankYouEditTest.php @@ -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' ); } diff --git a/tests/phpunit/UserLocatorTest.php b/tests/phpunit/UserLocatorTest.php index 04b9e21d0..4e2fa584b 100644 --- a/tests/phpunit/UserLocatorTest.php +++ b/tests/phpunit/UserLocatorTest.php @@ -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'