Fix "Call to undefined method WikiPage::factory()"

This commit is contained in:
paladox
2023-11-29 13:34:10 -05:00
committed by GitHub
parent c88c33007d
commit db42a48c07

View File

@ -24,6 +24,8 @@
*/ */
namespace LinkTitles; namespace LinkTitles;
use MediaWiki\MediaWikiServices;
/** /**
* Represents a page that is a potential link target. * Represents a page that is a potential link target.
*/ */
@ -189,7 +191,13 @@ class Target {
*/ */
public function getContent() { public function getContent() {
if ( $this->content === null ) { if ( $this->content === null ) {
$this->content = \WikiPage::factory( $this->title )->getContent(); // 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 );
}
}; };
return $this->content; return $this->content;
} }