jenkins-bot has submitted this change and it was merged.

Change subject: Add tracking categories when magic links are used
......................................................................


Add tracking categories when magic links are used

This adds 3 tracking categories, one for each type of magic link (ISBN,
RFC, PMID). This will allow wikis to gauge usage and identify pages that
need migrating.

These will only show up if the respective magic links are enabled via
$wgEnableMagicLinks.

Change-Id: Ic483f0c493112bf6373e1b37961e1241c20c3582
(cherry picked from commit 0ca156364425e959e8447ee00f9abd555c9904ae)
---
M includes/parser/Parser.php
M includes/specials/SpecialTrackingCategories.php
M languages/i18n/en.json
M languages/i18n/qqq.json
4 files changed, 29 insertions(+), 0 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 669e9fc1..c681779 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -1446,6 +1446,7 @@
                                $keyword = 'RFC';
                                $urlmsg = 'rfcurl';
                                $cssClass = 'mw-magiclink-rfc';
+                               $trackingCat = 'magiclink-tracking-rfc';
                                $id = $m[5];
                        } elseif ( substr( $m[0], 0, 4 ) === 'PMID' ) {
                                if ( !$this->mOptions->getMagicPMIDLinks() ) {
@@ -1454,12 +1455,14 @@
                                $keyword = 'PMID';
                                $urlmsg = 'pubmedurl';
                                $cssClass = 'mw-magiclink-pmid';
+                               $trackingCat = 'magiclink-tracking-pmid';
                                $id = $m[5];
                        } else {
                                throw new MWException( __METHOD__ . ': 
unrecognised match type "' .
                                        substr( $m[0], 0, 20 ) . '"' );
                        }
                        $url = wfMessage( $urlmsg, $id 
)->inContentLanguage()->text();
+                       $this->addTrackingCategory( $trackingCat );
                        return Linker::makeExternalLink( $url, "{$keyword} 
{$id}", true, $cssClass, [], $this->mTitle );
                } elseif ( isset( $m[6] ) && $m[6] !== ''
                        && $this->mOptions->getMagicISBNLinks()
@@ -1473,6 +1476,7 @@
                                ' ' => '',
                                'x' => 'X',
                        ] );
+                       $this->addTrackingCategory( 'magiclink-tracking-isbn' );
                        return $this->getLinkRenderer()->makeKnownLink(
                                SpecialPage::getTitleFor( 'Booksources', $num ),
                                "ISBN $isbn",
diff --git a/includes/specials/SpecialTrackingCategories.php 
b/includes/specials/SpecialTrackingCategories.php
index 4c892b2..3b502f8 100644
--- a/includes/specials/SpecialTrackingCategories.php
+++ b/includes/specials/SpecialTrackingCategories.php
@@ -145,6 +145,19 @@
                        ExtensionRegistry::getInstance()->getAttribute( 
'TrackingCategories' ),
                        $this->getConfig()->get( 'TrackingCategories' ) // 
deprecated
                );
+
+               // Only show magic link tracking categories if they are enabled
+               $enableMagicLinks = $this->getConfig()->get( 'EnableMagicLinks' 
);
+               if ( $enableMagicLinks['ISBN'] ) {
+                       $categories[] = 'magiclink-tracking-isbn';
+               }
+               if ( $enableMagicLinks['RFC'] ) {
+                       $categories[] = 'magiclink-tracking-rfc';
+               }
+               if ( $enableMagicLinks['PMID'] ) {
+                       $categories[] = 'magiclink-tracking-pmid';
+               }
+
                $trackingCategories = [];
                foreach ( $categories as $catMsg ) {
                        /*
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 3d272a3..6e1aec4 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -1934,6 +1934,12 @@
        "booksources-search": "Search",
        "booksources-text": "Below is a list of links to other sites that sell 
new and used books, and may also have further information about books you are 
looking for:",
        "booksources-invalid-isbn": "The given ISBN does not appear to be 
valid; check for errors copying from the original source.",
+       "magiclink-tracking-rfc": "Pages using RFC magic links",
+       "magiclink-tracking-rfc-desc": "This page uses RFC magic links. See 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Magic_links 
mediawiki.org] on how to migrate.",
+       "magiclink-tracking-pmid": "Pages using PMID magic links",
+       "magiclink-tracking-pmid-desc": "This page uses PMID magic links. See 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Magic_links 
mediawiki.org] on how to migrate.",
+       "magiclink-tracking-isbn": "Pages using ISBN magic links",
+       "magiclink-tracking-isbn-desc": "This page uses ISBN magic links. See 
[https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Magic_links 
mediawiki.org] on how to migrate.",
        "rfcurl": "//tools.ietf.org/html/rfc$1",
        "pubmedurl": "//www.ncbi.nlm.nih.gov/pubmed/$1?dopt=Abstract",
        "specialloguserlabel": "Performer:",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index cde2575..7c70351 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -2118,6 +2118,12 @@
        "booksources-search": "Search button in 
[[Special:BookSources]]\n\n{{Identical|Search}}",
        "booksources-text": "Used in [[Special:BookSources/1]].\n\nThis message 
is followed by a list of links to other sites.\n\nSee also:\n* 
{{msg-mw|Booksources|title}}\n* {{msg-mw|Booksources-text|text}}",
        "booksources-invalid-isbn": "This message is displayed after an invalid 
ISBN is entered on [[Special:Booksources]].",
+       "magiclink-tracking-rfc": "Name of the 
[[mw:Special:MyLanguage/Help:Tracking categories|tracking category]] where 
pages that use RFC magic links will be added.",
+       "magiclink-tracking-rfc-desc": "Description of the tracking category 
{{mw-msg|magiclink-tracking-rfc}}",
+       "magiclink-tracking-pmid": "Name of the 
[[mw:Special:MyLanguage/Help:Tracking categories|tracking category]] where 
pages that use PMID magic links will be added.",
+       "magiclink-tracking-pmid-desc": "Description of the tracking category 
{{mw-msg|magiclink-tracking-pmid}}",
+       "magiclink-tracking-isbn": "Name of the 
[[mw:Special:MyLanguage/Help:Tracking categories|tracking category]] where 
pages that use ISBN magic links will be added.",
+       "magiclink-tracking-isbn-desc": "Description of the tracking category 
{{mw-msg|magiclink-tracking-isbn}}",
        "rfcurl": "{{notranslate}}\nParameters:\n* $1 - RFC number\nSee 
also:\n* {{msg-mw|Pubmedurl}}",
        "pubmedurl": "{{notranslate}}\nParameters:\n* $1 - Pubmed number\nSee 
also:\n* {{msg-mw|Rfcurl}}",
        "specialloguserlabel": "Used in [[Special:Log]] as a label for an input 
field with which the log can be filtered for entries describing actions 
''performed'' by the specified user.  \"Carried out\" and \"done\" are possible 
alternatives for \"performed\".",

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic483f0c493112bf6373e1b37961e1241c20c3582
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_28
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: C. Scott Ananian <canan...@wikimedia.org>
Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to