MarkAHershberger has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/318207

Change subject: Use the proper page on the target of a redirect
......................................................................

Use the proper page on the target of a redirect

When it is used outside of the main wikitext, {{FULLPAGENAMEE}} points
to the url that started the pageview, we need to resolve the redirects
and use that instead.

Bug: T149250
Change-Id: I3ee1952f9662b48390b8d0fbee9f5feef7a396f4
---
M WhoIsWatching_body.php
M i18n/en.json
2 files changed, 6 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WhoIsWatching 
refs/changes/07/318207/1

diff --git a/WhoIsWatching_body.php b/WhoIsWatching_body.php
index a87e585..d579725 100644
--- a/WhoIsWatching_body.php
+++ b/WhoIsWatching_body.php
@@ -221,6 +221,10 @@
                ) {
                        $dbr = wfGetDB( DB_SLAVE );
                        $title = $template->getTitle();
+                       if ( $title->isRedirect() ) {
+                               $article = Article::newFromID( 
$title->getArticleID() );
+                               $title = $article->getRedirectTarget();
+                       }
                        $res = $dbr->select( 'watchlist', 'COUNT(*) as count', [
                                                                 'wl_namespace' 
=> $title->getNamespace(),
                                                                 'wl_title' => 
$title->getDBkey(),
@@ -228,7 +232,7 @@
                        $watch = $dbr->fetchObject( $res );
                        if ( $watch->count > 0 || $showIfZero ) {
                                $msg = wfMessage( 
'whoiswatching_users_pageview',
-                                       
RequestContext::getMain()->getLanguage()->formatNum( $watch->count )
+                                       
RequestContext::getMain()->getLanguage()->formatNum( $watch->count ), $title
                                )->parse();
                                $tpl->set( 'numberofwatchingusers', $msg );
                        }
diff --git a/i18n/en.json b/i18n/en.json
index 7e51951..f554ddb 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -12,7 +12,7 @@
        "specialwhoiswatchingusage": "This special page cannot be used on its 
own.",
        "specialwhoiswatchingaddusers": "Add users to watch the page",
        "specialwhoiswatchingaddbtn": "Add selected users",
-       "whoiswatching_users_pageview": 
"[{{fullurl:Special:WhoIsWatching/{{FULLPAGENAMEE}}}} $1] watching 
{{PLURAL:$1|user|users}}",
+       "whoiswatching_users_pageview": "[{{fullurl:Special:WhoIsWatching/$2}} 
$1] watching {{PLURAL:$1|user|users}}",
        "whoiswatching-not-possible-title": "Impossible page to watch",
        "whoiswatching-not-possible": "It is not possible to watch the [[$1]] 
page.",
        "whoiswatching-usage-title": "How to use this page",

-- 
To view, visit https://gerrit.wikimedia.org/r/318207
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ee1952f9662b48390b8d0fbee9f5feef7a396f4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WhoIsWatching
Gerrit-Branch: master
Gerrit-Owner: MarkAHershberger <m...@nichework.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to