From 788341419753a3c2895afbb615e970f706a3b28d Mon Sep 17 00:00:00 2001 From: lens0021 Date: Wed, 12 Aug 2020 16:23:24 +0900 Subject: [PATCH] Replace deprecated onHistoryRevisionTools hook --- extension.json | 2 +- includes/SanctionsHooks.php | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/extension.json b/extension.json index ba7339f..88f3822 100644 --- a/extension.json +++ b/extension.json @@ -101,7 +101,7 @@ "ResourceLoaderGetConfigVars": "SanctionsHooks::onResourceLoaderGetConfigVars", "UserToolLinksEdit": "SanctionsHooks::onUserToolLinksEdit", "DiffTools": "SanctionsHooks::onDiffTools", - "HistoryRevisionTools": "SanctionsHooks::onHistoryRevisionTools", + "HistoryTools": "SanctionsHooks::onHistoryTools", "SidebarBeforeOutput": "SanctionsHooks::onSidebarBeforeOutput", "ContributionsToolLinks": "SanctionsHooks::onContributionsToolLinks", "FlowAddModules": "SanctionsHooks::onFlowAddModules" diff --git a/includes/SanctionsHooks.php b/includes/SanctionsHooks.php index 000a153..40aaad7 100644 --- a/includes/SanctionsHooks.php +++ b/includes/SanctionsHooks.php @@ -230,17 +230,19 @@ public static function onDiffTools( $newRevRecord, &$links, $oldRevRecord, $user } /** - * @param Revision $rev Revision object - * @param array &$links Array of HTML links - * @return bool + * @param RevisionRecord $revRecord + * @param string[] &$links Array of HTML links + * @param RevisionRecord|null $prevRevRecord RevisionRecord object, next in line + * in page history, or null + * @param UserIdentity $userIdentity Current user + * @return bool|void True or no return value to continue or false to abort */ - public static function onHistoryRevisionTools( $rev, &$links ) { - $user = RequestContext::getMain()->getUser(); - if ( $user == null || !SanctionsUtils::hasVoteRight( $user ) ) { + public static function onHistoryTools( $revRecord, &$links, $prevRevRecord, $userIdentity ) { + if ( $userIdentity == null || !SanctionsUtils::hasVoteRight( $userIdentity ) ) { return true; } - $titleText = $rev->getUserText() . '/' . $rev->getId(); + $titleText = $revRecord->getUser()->getName() . '/' . $revRecord->getId(); $links[] = Linker::link( SpecialPage::getTitleFor( 'Sanctions', $titleText ), wfMessage( 'sanctions-link-on-history' )->text()