From 71eacf3fad2c6c256ef545696251e2891e3f4bf3 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 23 May 2016 12:22:41 -0700 Subject: [PATCH] Add diff link to page-linked notification Will only show for new instances, because the information will be unavailable for old ones. Bug: T135959 Depends-On: I3d894acaf3d85b790e5034c7d9f76bf94672f445 Change-Id: I04620678dd0ebffb3b1a92a9a0587cb7557d77f4 --- Hooks.php | 3 +++ .../formatters/PageLinkedPresentationModel.php | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Hooks.php b/Hooks.php index 2d9dd8577..640778150 100644 --- a/Hooks.php +++ b/Hooks.php @@ -684,6 +684,8 @@ class EchoHooks { $user = $wgUser; } + $revid = $linksUpdate->getRevision() ? $linksUpdate->getRevision()->getId() : null; + // link notification is boundless as you can include infinite number of links in a page // db insert is expensive, limit it to a reasonable amount, we can increase this limit // once the storage is on Redis @@ -703,6 +705,7 @@ class EchoHooks { 'agent' => $user, 'extra' => array( 'link-from-page-id' => $linksUpdate->mTitle->getArticleId(), + 'revid' => $revid, ) ) ); $max--; diff --git a/includes/formatters/PageLinkedPresentationModel.php b/includes/formatters/PageLinkedPresentationModel.php index 6d7567112..bc3404275 100644 --- a/includes/formatters/PageLinkedPresentationModel.php +++ b/includes/formatters/PageLinkedPresentationModel.php @@ -34,7 +34,20 @@ class EchoPageLinkedPresentationModel extends EchoEventPresentationModel { 'icon' => 'linked', 'prioritized' => true ); - return array( $whatLinksHereLink ); + + $revid = $this->event->getExtraParam( 'revid' ); + $diffLink = null; + if ( $revid !== null ) { + $diffLink = array( + 'url' => $this->event->getTitle()->getFullURL( array( 'diff' => $revid, 'oldid' => 'prev' ) ), + 'label' => $this->msg( 'notification-link-text-view-changes' )->text(), + 'description' => '', + 'icon' => 'changes', + 'prioritized' => true + ); + } + + return array( $whatLinksHereLink, $diffLink ); } protected function getHeaderMessageKey() {