From 5a6e69daf6a1c60dc96ab158d1076e0979d27d9c Mon Sep 17 00:00:00 2001 From: Adrian Cornish Date: Sun, 29 Nov 2020 08:13:32 -0700 Subject: [PATCH] Fix change in magic words API Fix for mediawiki 1.35 Manually running the CLI script caused this error: Error from line 152 of extensions/LinkTitles/includes/Source.php: Call to undefined method MagicWord::get() It seems like an API change so I found this in another extension with the same error https://gerrit.wikimedia.org/r/c/mediawiki/extensions/MagicNoCache/+/574232/2/MagicNoCache.hooks.php --- includes/Source.php | 2 +- includes/Target.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Source.php b/includes/Source.php index b751004..95df48e 100644 --- a/includes/Source.php +++ b/includes/Source.php @@ -149,7 +149,7 @@ class Source { * @return boolean True if the page contains the __NOAUTOLINKS__ magic word. */ public function hasNoAutolinksMagicWord() { - return \MagicWord::get( 'MAG_LINKTITLES_NOAUTOLINKS' )->match( $this->getText() ); + return \MediaWiki\MediaWikiServices::getInstance()->getMagicWordFactory()->get( 'MAG_LINKTITLES_NOAUTOLINKS' )->match( $this->getText() ); } /** diff --git a/includes/Target.php b/includes/Target.php index 64d7d12..9ccd603 100644 --- a/includes/Target.php +++ b/includes/Target.php @@ -210,7 +210,7 @@ class Target { // page does indeed contain this magic word, return the page title // as-is (unlinked). if ( $this->config->enableNoTargetMagicWord ) { - if ( $this->getContent()->matchMagicWord( \MagicWord::get('MAG_LINKTITLES_NOTARGET') ) ) { + if ( $this->getContent()->matchMagicWord( \MediaWiki\MediaWikiServices::getInstance()->getMagicWordFactory()->get('MAG_LINKTITLES_NOTARGET') ) ) { return false; } };