From b5e4e0758cd9634eee5a48c7330a1d5358b4b7c0 Mon Sep 17 00:00:00 2001 From: paladox Date: Wed, 27 Dec 2023 23:44:13 +0000 Subject: [PATCH 1/4] Fix duplicate getPage functions in Source Causing a fatal. --- includes/Source.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Source.php b/includes/Source.php index a119cae..ba3b435 100644 --- a/includes/Source.php +++ b/includes/Source.php @@ -238,7 +238,7 @@ class Source { if ( $this->page === null ) { // Access the property directly to avoid an infinite loop. if ( $this->title != null) { - $this->page = static::getPage(); + $this->page = static::getPageObject(); } else { throw new Exception( 'Unable to create Page for this Source because Title is null.' ); } @@ -251,7 +251,7 @@ class Source { * Workaround for MediaWiki 1.36+ which deprecated Wikipage::factory. * @return WikiPage object */ - private static function getPage() { + private static function getPageObject() { if ( method_exists( MediaWikiServices::class, 'getWikiPageFactory' ) ) { $wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory(); return $wikiPageFactory->newFromTitle( $this->title ); From 0bbad64680a716654bf23acbc987fe3689dc8e12 Mon Sep 17 00:00:00 2001 From: paladox Date: Wed, 27 Dec 2023 23:51:01 +0000 Subject: [PATCH 2/4] Update Source.php --- includes/Source.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/Source.php b/includes/Source.php index ba3b435..9be3f6b 100644 --- a/includes/Source.php +++ b/includes/Source.php @@ -238,7 +238,7 @@ class Source { if ( $this->page === null ) { // Access the property directly to avoid an infinite loop. if ( $this->title != null) { - $this->page = static::getPageObject(); + $this->page = static::getPageObject( $this->title ); } else { throw new Exception( 'Unable to create Page for this Source because Title is null.' ); } @@ -249,14 +249,15 @@ class Source { /** * Obtain a WikiPage object. * Workaround for MediaWiki 1.36+ which deprecated Wikipage::factory. + * @param \Title $title * @return WikiPage object */ - private static function getPageObject() { + private static function getPageObject( $title ) { if ( method_exists( MediaWikiServices::class, 'getWikiPageFactory' ) ) { $wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory(); - return $wikiPageFactory->newFromTitle( $this->title ); + return $wikiPageFactory->newFromTitle( $title ); } - return \WikiPage::factory( $this->title ); + return \WikiPage::factory( $title ); } } From 39ad6aa3a29801c7261e4927c0d2dd3039d40f25 Mon Sep 17 00:00:00 2001 From: paladox Date: Wed, 27 Dec 2023 23:52:36 +0000 Subject: [PATCH 3/4] Update Target.php --- includes/Target.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/Target.php b/includes/Target.php index f9afcd5..a76fcc3 100644 --- a/includes/Target.php +++ b/includes/Target.php @@ -191,7 +191,7 @@ class Target { */ public function getContent() { if ( $this->content === null ) { - $this->content = static::getPage(); + $this->content = static::getPageContents( $this->title ); }; return $this->content; } @@ -248,14 +248,15 @@ class Target { /** * Obtain a page's content. * Workaround for MediaWiki 1.36+ which deprecated Wikipage::factory. + * @param \Title $title * @return Content content object of the page */ - private static function getPage() { + private static function getPageContents( $title ) { if ( method_exists( MediaWikiServices::class, 'getWikiPageFactory' ) ) { $wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory(); - $page = $wikiPageFactory->newFromTitle( $this->title ); + $page = $wikiPageFactory->newFromTitle( $title ); } else { - $page = \WikiPage::factory( $this->title ); + $page = \WikiPage::factory( $title ); } return $page->getContent(); } From 71713f6f2356a90a4672c609d90bc6ad030f86c2 Mon Sep 17 00:00:00 2001 From: paladox Date: Wed, 27 Dec 2023 23:59:32 +0000 Subject: [PATCH 4/4] Update Target.php --- includes/Target.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/Target.php b/includes/Target.php index a76fcc3..e203959 100644 --- a/includes/Target.php +++ b/includes/Target.php @@ -240,7 +240,11 @@ class Target { */ public function redirectsTo( $source ) { if ( $this->getContent() ) { - $redirectTitle = $this->getContent()->getUltimateRedirectTarget(); + if ( version_compare( MW_VERSION, '1.38', '>=' ) ) { + $redirectTitle = $this->getContent()->getRedirectTarget(); + } else { + $redirectTitle = $this->getContent()->getUltimateRedirectTarget(); + } return $redirectTitle && $redirectTitle->equals( $source->getTitle() ); } }