From db42a48c079d9721bd0540e8823d5682e9ac1770 Mon Sep 17 00:00:00 2001 From: paladox Date: Wed, 29 Nov 2023 13:34:10 -0500 Subject: [PATCH] Fix "Call to undefined method WikiPage::factory()" --- includes/Target.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/Target.php b/includes/Target.php index 8fa99b5..a6bfe45 100644 --- a/includes/Target.php +++ b/includes/Target.php @@ -24,6 +24,8 @@ */ namespace LinkTitles; +use MediaWiki\MediaWikiServices; + /** * Represents a page that is a potential link target. */ @@ -189,7 +191,13 @@ class Target { */ public function getContent() { 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; }