diff --git a/includes/Target.php b/includes/Target.php index 1943317..f9afcd5 100644 --- a/includes/Target.php +++ b/includes/Target.php @@ -191,13 +191,7 @@ class Target { */ public function getContent() { if ( $this->content === null ) { - // MW 1.36+ - if ( method_exists( MediaWikiServices::class, 'getWikiPageFactory' ) ) { - $wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory(); - $this->content = $wikiPageFactory->newFromTitle( $this->title )->getContent(); - } else { - $this->content = \WikiPage::factory( $this->title )->getContent(); - } + $this->content = static::getPage(); }; return $this->content; } @@ -250,4 +244,19 @@ class Target { return $redirectTitle && $redirectTitle->equals( $source->getTitle() ); } } + + /** + * Obtain a page's content. + * Workaround for MediaWiki 1.36+ which deprecated Wikipage::factory. + * @return Content content object of the page + */ + private static function getPage() { + if ( method_exists( MediaWikiServices::class, 'getWikiPageFactory' ) ) { + $wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory(); + $page = $wikiPageFactory->newFromTitle( $this->title ); + } else { + $page = \WikiPage::factory( $this->title ); + } + return $page->getContent(); + } }