Add a tracking category for duplicate arguments
authorJackmcbarn <jackmcbarn@gmail.com>
Thu, 29 May 2014 16:55:40 +0000 (12:55 -0400)
committerLegoktm <legoktm.wikipedia@gmail.com>
Thu, 16 Oct 2014 04:38:14 +0000 (04:38 +0000)
If a page accidentally duplicates an argument, such as
{{foo|bar=1|bar=2}} or {{foo|bar|1=baz}}, add it to a tracking category.

Bug: 69964
Change-Id: I3b6eeff8b51859bc7af0ea985f6f7528c2e9d220

includes/DefaultSettings.php
includes/parser/Preprocessor_DOM.php
includes/parser/Preprocessor_Hash.php
languages/i18n/en.json
languages/i18n/qqq.json

index de29f0d..57859ec 100644 (file)
@@ -3797,6 +3797,7 @@ $wgNamespacesWithSubpages = array(
 $wgTrackingCategories = array(
        'index-category',
        'noindex-category',
+       'duplicate-args-category',
        'expensive-parserfunction-category',
        'post-expand-template-argument-category',
        'post-expand-template-inclusion-category',
index 2edb79a..2cce574 100644 (file)
@@ -1043,11 +1043,17 @@ class PPFrame_DOM implements PPFrame {
                                        // Numbered parameter
                                        $index = $nameNodes->item( 0 )->attributes->getNamedItem( 'index' )->textContent;
                                        $index = $index - $indexOffset;
+                                       if ( isset( $namedArgs[$index] ) || isset( $numberedArgs[$index] ) ) {
+                                               $this->parser->addTrackingCategory( 'duplicate-args-category' );
+                                       }
                                        $numberedArgs[$index] = $value->item( 0 );
                                        unset( $namedArgs[$index] );
                                } else {
                                        // Named parameter
                                        $name = trim( $this->expand( $nameNodes->item( 0 ), PPFrame::STRIP_COMMENTS ) );
+                                       if ( isset( $namedArgs[$name] ) || isset( $numberedArgs[$name] ) ) {
+                                               $this->parser->addTrackingCategory( 'duplicate-args-category' );
+                                       }
                                        $namedArgs[$name] = $value->item( 0 );
                                        unset( $numberedArgs[$name] );
                                }
index 6376396..b4b14dc 100644 (file)
@@ -985,11 +985,17 @@ class PPFrame_Hash implements PPFrame {
                                if ( $bits['index'] !== '' ) {
                                        // Numbered parameter
                                        $index = $bits['index'] - $indexOffset;
+                                       if ( isset( $namedArgs[$index] ) || isset( $numberedArgs[$index] ) ) {
+                                               $this->parser->addTrackingCategory( 'duplicate-args-category' );
+                                       }
                                        $numberedArgs[$index] = $bits['value'];
                                        unset( $namedArgs[$index] );
                                } else {
                                        // Named parameter
                                        $name = trim( $this->expand( $bits['name'], PPFrame::STRIP_COMMENTS ) );
+                                       if ( isset( $namedArgs[$name] ) || isset( $numberedArgs[$name] ) ) {
+                                               $this->parser->addTrackingCategory( 'duplicate-args-category' );
+                                       }
                                        $namedArgs[$name] = $bits['value'];
                                        unset( $numberedArgs[$name] );
                                }
index 99554e7..9aa05f3 100644 (file)
        "content-model-text": "plain text",
        "content-model-javascript": "JavaScript",
        "content-model-css": "CSS",
+       "duplicate-args-category": "Pages using duplicate arguments in template calls",
+       "duplicate-args-category-desc": "The page contains template calls that use duplicates of arguments, such as <code><nowiki>{{foo|bar=1|bar=2}}</nowiki></code> or <code><nowiki>{{foo|bar|1=baz}}</nowiki></code>.",
        "expensive-parserfunction-warning": "<strong>Warning:</strong> This page contains too many expensive parser function calls.\n\nIt should have less than $2 {{PLURAL:$2|call|calls}}, there {{PLURAL:$1|is now $1 call|are now $1 calls}}.",
        "expensive-parserfunction-category": "Pages with too many expensive parser function calls",
        "post-expand-template-inclusion-warning": "<strong>Warning:</strong> Template include size is too large.\nSome templates will not be included.",
index 99aecb0..55945e9 100644 (file)
        "content-model-text": "Name for the plain text content model, used when decribing what type of content a page contains.\n\nThis message is substituted in:\n*{{msg-mw|Bad-target-model}}\n*{{msg-mw|Content-not-allowed-here}}\n{{Identical|Plain text}}",
        "content-model-javascript": "Name for the JavaScript content model, used when decribing what type of content a page contains.\n\nThis message is substituted in:\n*{{msg-mw|Bad-target-model}}\n*{{msg-mw|Content-not-allowed-here}}",
        "content-model-css": "Name for the CSS content model, used when decribing what type of content a page contains.\n\nThis message is substituted in:\n*{{msg-mw|Bad-target-model}}\n*{{msg-mw|Content-not-allowed-here}}",
+       "duplicate-args-category": "This message is used as a category name for a [[mw:Special:MyLanguage/Help:Tracking categories|tracking category]] where pages are placed automatically if they contain template calls that use duplicates of arguments, such as <code><nowiki>{{foo|bar=1|bar=2}}</nowiki></code> or <code><nowiki>{{foo|bar|1=baz}}</nowiki></code>.",
+       "duplicate-args-category-desc": "Duplicate arguments category description. Shown on [[Special:TrackingCategories]].\n\nSee also:\n* {{msg-mw|Duplicate-args-category}}",
        "expensive-parserfunction-warning": "On some (expensive) [[MetaWikipedia:Help:ParserFunctions|parser functions]] (e.g. <code><nowiki>{{#ifexist:}}</nowiki></code>) there is a limit of how many times it may be used. This is an error message shown when the limit is exceeded.\n\nParameters:\n* $1 - the current number of parser function calls\n* $2 - the allowed number of parser function calls\nSee also [[:mw:Manual:$wgExpensiveParserFunctionLimit|$wgExpensiveParserFunctionLimit in the MediaWiki manual]].\n\nSee also:\n* {{msg-mw|Expensive-parserfunction-category}}",
        "expensive-parserfunction-category": "This message is used as a category name for a [[mw:Special:MyLanguage/Help:Tracking categories|tracking category]] where pages are placed automatically if they contain too many calls to expensive parser functions.\n\nSee also:\n* {{msg-mw|Expensive-parserfunction-category-desc}}\n* {{msg-mw|Expensive-parserfunction-warning}}",
        "post-expand-template-inclusion-warning": "When templates are expanded, there is a size limit for the number of bytes yielded. Usually that occurs from excessively nested templates, recursive templates, or ones having x-zillion of #if #case or similar contructs in them. When the wikicode parser detects this, it outputs a red warning message to the page.\n\n\nSee also:\n* {{msg-mw|Post-expand-template-inclusion-category}}",