Use LinkTarget in LogFormatter::getPreloadTitles override

Change-Id: I4748927e8656346f7912deec05ba5acaafa44ce9
This commit is contained in:
Umherirrender 2024-07-14 22:55:48 +02:00
parent 94ec2c77b6
commit b26c899229
2 changed files with 19 additions and 3 deletions

View file

@ -43,7 +43,12 @@
"thanks": true
},
"LogActionsHandlers": {
"thanks/*": "MediaWiki\\Extension\\Thanks\\ThanksLogFormatter"
"thanks/*": {
"class": "MediaWiki\\Extension\\Thanks\\ThanksLogFormatter",
"services": [
"NamespaceInfo"
]
}
},
"APIModules": {
"thank": {

View file

@ -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() ) ];
}
}