diff --git a/extension.json b/extension.json index 4cd25ef8..acad2b43 100644 --- a/extension.json +++ b/extension.json @@ -43,7 +43,12 @@ "thanks": true }, "LogActionsHandlers": { - "thanks/*": "MediaWiki\\Extension\\Thanks\\ThanksLogFormatter" + "thanks/*": { + "class": "MediaWiki\\Extension\\Thanks\\ThanksLogFormatter", + "services": [ + "NamespaceInfo" + ] + } }, "APIModules": { "thank": { diff --git a/includes/ThanksLogFormatter.php b/includes/ThanksLogFormatter.php index 2e7c8440..48f49a61 100644 --- a/includes/ThanksLogFormatter.php +++ b/includes/ThanksLogFormatter.php @@ -2,15 +2,26 @@ namespace MediaWiki\Extension\Thanks; +use LogEntry; use LogFormatter; use MediaWiki\Message\Message; -use MediaWiki\Title\Title; +use MediaWiki\Title\NamespaceInfo; use MediaWiki\User\User; /** * This class formats log entries for thanks */ class ThanksLogFormatter extends LogFormatter { + private NamespaceInfo $namespaceInfo; + + public function __construct( + LogEntry $entry, + NamespaceInfo $namespaceInfo + ) { + parent::__construct( $entry ); + $this->namespaceInfo = $namespaceInfo; + } + /** * @inheritDoc */ @@ -26,6 +37,6 @@ class ThanksLogFormatter extends LogFormatter { public function getPreloadTitles() { // Add the recipient's user talk page to LinkBatch - return [ Title::makeTitle( NS_USER_TALK, $this->entry->getTarget()->getText() ) ]; + return [ $this->namespaceInfo->getTalkPage( $this->entry->getTarget() ) ]; } }