Update Target.php

This commit is contained in:
paladox
2023-12-27 23:52:36 +00:00
committed by GitHub
parent 0bbad64680
commit 39ad6aa3a2

View File

@ -191,7 +191,7 @@ class Target {
*/ */
public function getContent() { public function getContent() {
if ( $this->content === null ) { if ( $this->content === null ) {
$this->content = static::getPage(); $this->content = static::getPageContents( $this->title );
}; };
return $this->content; return $this->content;
} }
@ -248,14 +248,15 @@ class Target {
/** /**
* Obtain a page's content. * Obtain a page's content.
* Workaround for MediaWiki 1.36+ which deprecated Wikipage::factory. * Workaround for MediaWiki 1.36+ which deprecated Wikipage::factory.
* @param \Title $title
* @return Content content object of the page * @return Content content object of the page
*/ */
private static function getPage() { private static function getPageContents( $title ) {
if ( method_exists( MediaWikiServices::class, 'getWikiPageFactory' ) ) { if ( method_exists( MediaWikiServices::class, 'getWikiPageFactory' ) ) {
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory(); $wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
$page = $wikiPageFactory->newFromTitle( $this->title ); $page = $wikiPageFactory->newFromTitle( $title );
} else { } else {
$page = \WikiPage::factory( $this->title ); $page = \WikiPage::factory( $title );
} }
return $page->getContent(); return $page->getContent();
} }