diff --git a/extension.json b/extension.json index d9b35268b..c14c2c5c8 100644 --- a/extension.json +++ b/extension.json @@ -115,7 +115,12 @@ "abusefilter": "abusefilter-log-header" }, "LogActionsHandlers": { - "abusefilter/hit": "MediaWiki\\Extension\\AbuseFilter\\LogFormatter\\AbuseLogHitFormatter", + "abusefilter/hit": { + "class": "MediaWiki\\Extension\\AbuseFilter\\LogFormatter\\AbuseLogHitFormatter", + "services": [ + "AbuseFilterSpecsFormatter" + ] + }, "abusefilter/modify": "MediaWiki\\Extension\\AbuseFilter\\LogFormatter\\AbuseFilterModifyLogFormatter", "abusefilter/create": "MediaWiki\\Extension\\AbuseFilter\\LogFormatter\\AbuseFilterModifyLogFormatter", "abusefilterblockeddomainhit/*": "MediaWiki\\Extension\\AbuseFilter\\LogFormatter\\AbuseFilterBlockedDomainHitLogFormatter", diff --git a/includes/LogFormatter/AbuseLogHitFormatter.php b/includes/LogFormatter/AbuseLogHitFormatter.php index 01ce3c643..72eddf845 100644 --- a/includes/LogFormatter/AbuseLogHitFormatter.php +++ b/includes/LogFormatter/AbuseLogHitFormatter.php @@ -2,8 +2,9 @@ namespace MediaWiki\Extension\AbuseFilter\LogFormatter; +use LogEntry; use LogFormatter; -use MediaWiki\Extension\AbuseFilter\AbuseFilterServices; +use MediaWiki\Extension\AbuseFilter\SpecsFormatter; use MediaWiki\SpecialPage\SpecialPage; use Message; @@ -14,6 +15,16 @@ use Message; */ class AbuseLogHitFormatter extends LogFormatter { + private SpecsFormatter $specsFormatter; + + public function __construct( + LogEntry $entry, + SpecsFormatter $specsFormatter + ) { + parent::__construct( $entry ); + $this->specsFormatter = $specsFormatter; + } + /** * @return array */ @@ -52,10 +63,9 @@ class AbuseLogHitFormatter extends LogFormatter { $actions = explode( ',', $actions_takenRaw ); $displayActions = []; - $specsFormatter = AbuseFilterServices::getSpecsFormatter(); - $specsFormatter->setMessageLocalizer( $this->context ); + $this->specsFormatter->setMessageLocalizer( $this->context ); foreach ( $actions as $action ) { - $displayActions[] = $specsFormatter->getActionDisplay( $action ); + $displayActions[] = $this->specsFormatter->getActionDisplay( $action ); } $actions_taken = $this->context->getLanguage()->commaList( $displayActions ); }