mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-12 17:29:30 +02:00
Update Target.php
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user