Merge "RollbackAction: Implement AJAX interface and require POST"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 23 May 2016 21:02:50 +0000 (21:02 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 23 May 2016 21:02:50 +0000 (21:02 +0000)
1  2 
RELEASE-NOTES-1.28
includes/Linker.php
languages/i18n/en.json
languages/i18n/qqq.json
resources/src/mediawiki/page/patrol.ajax.js

diff --combined RELEASE-NOTES-1.28
@@@ -13,7 -13,7 +13,7 @@@ production
  === New features in 1.28 ===
  * User::isBot() method for checking if an account is a bot role account.
  * Added a new hook, 'UserIsBot', to aid in determining if a user is a bot.
+ * (T88044) Implemented one-click rollback handling via AJAX.
  
  === External library changes in 1.28 ===
  
@@@ -41,7 -41,7 +41,7 @@@ MediaWiki supports over 350 languages. 
  regularly. Below only new and removed languages are listed, as well as
  changes to languages because of Phabricator reports.
  
 -=== Other changes in 1.27 ===
 +=== Other changes in 1.28 ===
  
  
  == Compatibility ==
diff --combined includes/Linker.php
@@@ -1084,16 -1084,7 +1084,16 @@@ class Linker 
                if ( !$title ) {
                        $title = $wgTitle;
                }
 -              $attribs['rel'] = Parser::getExternalLinkRel( $url, $title );
 +              $newRel = Parser::getExternalLinkRel( $url, $title );
 +              if ( !isset( $attribs['rel'] ) || $attribs['rel'] === '' ) {
 +                      $attribs['rel'] = $newRel;
 +              } elseif ( $newRel !== '' ) {
 +                      // Merge the rel attributes.
 +                      $newRels = explode( ' ', $newRel );
 +                      $oldRels = explode( ' ', $attribs['rel'] );
 +                      $combined = array_unique( array_merge( $newRels, $oldRels ) );
 +                      $attribs['rel'] = implode( ' ', $combined );
 +              }
                $link = '';
                $success = Hooks::run( 'LinkerMakeExternalLink',
                        [ &$url, &$text, &$link, &$attribs, $linktype ] );
         * work if $wgShowRollbackEditCount is disabled, so this can only function
         * as an additional check.
         *
-        * If the option noBrackets is set the rollback link wont be enclosed in []
+        * If the option noBrackets is set the rollback link wont be enclosed in "[]".
+        *
+        * See the "mediawiki.page.rollback" module for the client-side handling of this link.
         *
         * @since 1.16.3. $context added in 1.20. $options added in 1.21
         *
                        $inner = $context->msg( 'brackets' )->rawParams( $inner )->escaped();
                }
  
+               $context->getOutput()->addModules( 'mediawiki.page.rollback' );
                return '<span class="mw-rollback-link">' . $inner . '</span>';
        }
  
                $query = [
                        'action' => 'rollback',
                        'from' => $rev->getUserText(),
-                       'token' => $context->getUser()->getEditToken( [
-                               $title->getPrefixedText(),
-                               $rev->getUserText()
-                       ] ),
                ];
+               $attrs = [
+                       'data-mw' => 'interface',
+                       'title' => $context->msg( 'tooltip-rollback' )->text(),
+               ];
+               $options = [ 'known', 'noclasses' ];
                if ( $context->getRequest()->getBool( 'bot' ) ) {
                        $query['bot'] = '1';
                        $query['hidediff'] = '1'; // bug 15999
                        }
  
                        if ( $editCount > $wgShowRollbackEditCount ) {
-                               $editCount_output = $context->msg( 'rollbacklinkcount-morethan' )
+                               $html = $context->msg( 'rollbacklinkcount-morethan' )
                                        ->numParams( $wgShowRollbackEditCount )->parse();
                        } else {
-                               $editCount_output = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
+                               $html = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
                        }
  
-                       return self::link(
-                               $title,
-                               $editCount_output,
-                               [ 'title' => $context->msg( 'tooltip-rollback' )->text() ],
-                               $query,
-                               [ 'known', 'noclasses' ]
-                       );
+                       return self::link( $title, $html, $attrs, $query, $options );
                } else {
-                       return self::link(
-                               $title,
-                               $context->msg( 'rollbacklink' )->escaped(),
-                               [ 'title' => $context->msg( 'tooltip-rollback' )->text() ],
-                               $query,
-                               [ 'known', 'noclasses' ]
-                       );
+                       $html = $context->msg( 'rollbacklink' )->escaped();
+                       return self::link( $title, $html, $attrs, $query, $options );
                }
        }
  
diff --combined languages/i18n/en.json
        "trackingcategories-msg": "Tracking category",
        "trackingcategories-name": "Message name",
        "trackingcategories-desc": "Category inclusion criteria",
 +      "restricted-displaytitle-ignored": "Pages with ignored display titles",
 +      "restricted-displaytitle-ignored-desc": "The page has an ignored <code><nowiki>{{DISPLAYTITLE}}</nowiki></code> because it is not equivalent to the page's actual title.",
        "noindex-category-desc": "The page is not indexed by robots because it has the magic word <code><nowiki>__NOINDEX__</nowiki></code> on it and is in a namespace where that flag is allowed.",
        "index-category-desc": "The page has a <code><nowiki>__INDEX__</nowiki></code> on it (and is in a namespace where that flag is allowed), and hence is indexed by robots where it normally wouldn't be.",
        "post-expand-template-inclusion-category-desc": "The page size is bigger than <code>$wgMaxArticleSize</code> after expanding all the templates, so some templates were not expanded.",
        "rollbacklinkcount": "rollback $1 {{PLURAL:$1|edit|edits}}",
        "rollbacklinkcount-morethan": "rollback more than $1 {{PLURAL:$1|edit|edits}}",
        "rollbackfailed": "Rollback failed",
+       "rollback-missingparam": "Missing required parameters on request.",
        "cantrollback": "Cannot revert edit;\nlast contributor is only author of this page.",
        "alreadyrolled": "Cannot rollback last edit of [[:$1]] by [[User:$2|$2]] ([[User talk:$2|talk]]{{int:pipe-separator}}[[Special:Contributions/$2|{{int:contribslink}}]]);\nsomeone else has edited or rolled back the page already.\n\nThe last edit to the page was by [[User:$3|$3]] ([[User talk:$3|talk]]{{int:pipe-separator}}[[Special:Contributions/$3|{{int:contribslink}}]]).",
        "editcomment": "The edit summary was: <em>$1</em>.",
        "revertpage": "Reverted edits by [[Special:Contributions/$2|$2]] ([[User talk:$2|talk]]) to last revision by [[User:$1|$1]]",
        "revertpage-nouser": "Reverted edits by a hidden user to last revision by {{GENDER:$1|[[User:$1|$1]]}}",
        "rollback-success": "Reverted edits by $1;\nchanged back to last revision by $2.",
+       "rollback-success-notify": "Reverted edits by $1;\nchanged back to last revision by $2. [$3 Show changes]",
        "sessionfailure-title": "Session failure",
        "sessionfailure": "There seems to be a problem with your login session;\nthis action has been canceled as a precaution against session hijacking.\nGo back to the previous page, reload that page and then try again.",
        "changecontentmodel" : "Change content model of a page",
        "confirm-watch-top": "Add this page to your watchlist?",
        "confirm-unwatch-button": "OK",
        "confirm-unwatch-top": "Remove this page from your watchlist?",
+       "confirm-rollback-button": "OK",
+       "confirm-rollback-top": "Revert edits to this page?",
        "semicolon-separator": ";&#32;",
        "comma-separator": ",&#32;",
        "colon-separator": ":&#32;",
diff --combined languages/i18n/qqq.json
                        "Conquistador",
                        "Frigory",
                        "Psychoslave",
 -                      "Guycn2"
 +                      "Guycn2",
 +                      "2axterix2",
 +                      "Ата"
                ]
        },
        "sidebar": "{{notranslate}}",
        "columns": "Used on [[Special:Preferences]], \"Editing\" section in the \"Size of editing window\" fieldset.\n{{Identical|Column}}",
        "searchresultshead": "Replaced by {{msg-mw|prefs-searchoptions}}, though may still be used in some extensions. DEPRECATED.\n\n{{Identical|Search}}",
        "stub-threshold": "Used in [[Special:Preferences]], \"Advanced options\" section. The setting allows the user to select a threshold value, in bytes, from a predefined list of options. Any links that lead to pages smaller than the threshold (\"stub links\") will be styled differently.\n\nParameters:\n* $1: the text of {{msg-mw|stub-threshold-sample-link}}, styled as a stub link",
 -      "stub-threshold-sample-link": "Passed as a parameter to the {{msg-mw|stub-threshold}} message.",
 +      "stub-threshold-sample-link": "Passed as a parameter to the {{msg-mw|stub-threshold}} message.\n{{Identical|Sample}}",
        "stub-threshold-disabled": "Used in [[Special:Preferences]].\n{{Identical|Disabled}}",
        "recentchangesdays": "Used in [[Special:Preferences]], tab \"Recent changes\".",
        "recentchangesdays-max": "Shown as hint in [[Special:Preferences]], tab \"Recent changes\". Parameters:\n* $1 - number of days\nSee also:\n* {{msg-mw|Prefs-watchlist-days-max}}",
        "grant-group-customization": "{{Related|Grant-group}}",
        "grant-group-administration": "{{Related|Grant-group}}",
        "grant-group-other": "{{Related|Grant-group}}",
 -      "grant-blockusers": "Name for grant \"blockusers\".\n{{Related|grant}}",
 +      "grant-blockusers": "Name for grant \"blockusers\".\n{{Related|Grant}}",
        "grant-createaccount": "Name for grant \"createaccount\".\n{{Related|grant}}",
        "grant-createeditmovepage": "Name for grant \"createeditmovepage\".\n{{Related|grant}}",
        "grant-delete": "Name for grant \"delete\".\n{{Related|grant}}",
        "trackingcategories-msg": "Header for the message column of the table on [[Special:TrackingCategories]]. This column lists the mediawiki message that controls the tracking category in question.\n{{Identical|Tracking category}}",
        "trackingcategories-name": "Header for the message column of the table on [[Special:TrackingCategories]]. This column lists the name of the tracking category in the content language.",
        "trackingcategories-desc": "Header for the message column of the table on [[Special:TrackingCategories]]. This column lists the inclusion criteria for the category.",
 +      "restricted-displaytitle-ignored": "This message is used as a category name for a [[mw:Special:MyLanguage/Help:Tracking categories|tracking category]] where pages are placed automatically if a page has an ignored display title.\n\nSee also:\n* {{msg-mw|restricted-displaytitle-ignored-desc}}\n*{{msg-mw|restricted-displaytitle}}",
 +      "restricted-displaytitle-ignored-desc": "Pages with ignored display titles category description. Shown on [[Special:TrackingCategories]].\n\nSee also:\n* {{msg-mw|restricted-displaytitle-ignored}}",
        "noindex-category-desc": "No-index category-description. Shown on [[Special:TrackingCategories]].\n\nSee also:\n* {{msg-mw|Noindex-category}}",
        "index-category-desc": "Index category-description. Shown on [[Special:TrackingCategories]].\n\nSee also:\n* {{msg-mw|Index-category}}",
        "post-expand-template-inclusion-category-desc": "Post expand template inclusion category description. Shown on [[Special:TrackingCategories]].\n\nSee also:\n* {{msg-mw|Post-expand-template-inclusion-category}}",
        "rollbacklinkcount": "{{doc-actionlink}}\nText of the rollback link showing the number of edits to be rolled back. See also {{msg-mw|rollbacklink}}.\n\nParameters:\n* $1 - the number of edits that will be rolled back. If $1 is over the value of <code>$wgShowRollbackEditCount</code> (default: 10) {{msg-mw|rollbacklinkcount-morethan}} is used.\n\nThe rollback link is displayed with a tooltip {{msg-mw|Tooltip-rollback}}",
        "rollbacklinkcount-morethan": "{{doc-actionlink}}\nText of the rollback link when a greater number of edits is to be rolled back. See also {{msg-mw|rollbacklink}}.\n\nWhen the number of edits rolled back is smaller than [[mw:Special:MyLanguage/Manual:$wgShowRollbackEditCount|$wgShowRollbackEditCount]], {{msg-mw|rollbacklinkcount}} is used instead.\n\nParameters:\n* $1 - number of edits",
        "rollbackfailed": "{{Identical|Rollback}}",
-       "cantrollback": "Used as error message when rolling back.\n\nSee also:\n* {{msg-mw|Notvisiblerev}}\n{{Identical|Revert}}\n{{Identical|Rollback}}",
+       "rollback-missingparam": "Used as error message rollback is accessed without the required parameters\n\nSee also:\n* {{msg-mw|Rollbackfailed}}\n.",
+       "cantrollback": "Used as error message when rollback fails due to there not being a valid revision to revert back to.\n\nSee also:\n* {{msg-mw|Notvisiblerev}}\n{{Identical|Revert}}\n{{Identical|Rollback}}",
        "alreadyrolled": "Appear when there's rollback and/or edit collision.\n\nRefers to:\n* {{msg-mw|Pipe-separator}}\n* {{msg-mw|Contribslink}}\nParameters:\n* $1 - the page to be rolled back\n* $2 - the editor to be rolled-back of that page\n* $3 - the editor that cause collision\n{{Identical|Rollback}}",
        "editcomment": "Only shown if there is an edit {{msg-mw|Summary}}. Parameters:\n* $1 - the edit summary",
        "revertpage": "Parameters:\n* $1 - username 1\n* $2 - username 2\n* $3 - (Optional) revision ID of the revision reverted to\n* $4 - (Optional) timestamp of the revision reverted to\n* $5 - (Optional) revision ID of the revision reverted from\n* $6 - (Optional) timestamp of the revision reverted from\nSee also:\n* {{msg-mw|Revertpage-nouser}}\n{{Identical|Revert}}",
        "revertpage-nouser": "This is a confirmation message a user sees after reverting, when the username of the version is hidden with RevisionDelete.\n\nIn other cases the message {{msg-mw|Revertpage}} is used.\n\nParameters:\n* $1 - username 1, can be used for GENDER\n* $2 - (Optional) username 2\n* $3 - (Optional) revision ID of the revision reverted to\n* $4 - (Optional) timestamp of the revision reverted to\n* $5 - (Optional) revision ID of the revision reverted from\n* $6 - (Optional) timestamp of the revision reverted from",
        "rollback-success": "This message shows up on screen after successful revert (generally visible only to admins). $1 describes user whose changes have been reverted, $2 describes user which produced version, which replaces reverted version.\n{{Identical|Revert}}\n{{Identical|Rollback}}",
+       "rollback-success-notify": "Notification shown after a successful revert.\n* $1 - User whose changes have been reverted\n* $2 - User that made the edit that was restored\n* $3 - Url to the diff of the rollback\nSee also:\n*{{mw-msg|showdiff}}\n{{Identical|rollback-success}}\n{{Format|jquerymsg}}",
        "sessionfailure-title": "Used as title of the error message {{msg-mw|Sessionfailure}}.",
        "sessionfailure": "Used as error message.\n\nThe title for this error message is {{msg-mw|Sessionfailure-title}}.",
        "changecontentmodel": "Title of the change content model special page",
        "whatlinkshere-prev": "This is part of the navigation message on the top and bottom of Whatlinkshere pages, where it is used as the first argument of {{msg-mw|Viewprevnext}}.\n\nParameters:\n* $1 - the number of items shown per page. It is not used when $1 is zero; not sure what happens when $1 is one.\nSpecial pages use {{msg-mw|Prevn}} instead (still as an argument to {{msg-mw|Viewprevnext}}).\n\nSee also:\n* {{msg-mw|Whatlinkshere-next}}\n{{Identical|Previous}}",
        "whatlinkshere-next": "This is part of the navigation message on the top and bottom of Whatlinkshere pages, where it is used as the second argument of {{msg-mw|Viewprevnext}}.\n\nParameters:\n* $1 - the number of items shown per page. It is not used when $1 is zero; not sure what happens when $1 is one.\nSpecial pages use {{msg-mw|Nextn}} instead (still as an argument to {{msg-mw|Viewprevnext}}).\n\nSee also:\n* {{msg-mw|Whatlinkshere-prev}}\n{{Identical|Next}}",
        "whatlinkshere-links": "Used on [[Special:WhatLinksHere]]. It is a link to the WhatLinksHere page of that page.\n\nExample line:\n* [[Main Page]] ([[Special:WhatLinksHere/Main Page|{{int:whatlinkshere-links}}]])\n{{Identical|Link}}",
 -      "whatlinkshere-hideredirs": "Filter option in [[Special:WhatLinksHere]]. Parameters:\n* $1 is the {{msg-mw|hide}} or {{msg-mw|show}}",
 +      "whatlinkshere-hideredirs": "Filter option in [[Special:WhatLinksHere]].\n\nParameters:\n* $1 - {{msg-mw|hide}}/{{msg-mw|show}}",
        "whatlinkshere-hidetrans": "First filter option in [[Special:WhatLinksHere]]. Parameters:\n* $1 is the {{msg-mw|hide}} or {{msg-mw|show}}",
 -      "whatlinkshere-hidelinks": "Filter option in [[Special:WhatLinksHere]]. Parameters:\n* $1 is the {{msg-mw|hide}} or {{msg-mw|show}}",
 -      "whatlinkshere-hideimages": "Filter option in [[Special:WhatLinksHere]]. Parameters:\n* $1 - the {{msg-mw|Hide}} or {{msg-mw|Show}}\n\nSee also:\n*{{msg-mw|Isimage}}\n*{{msg-mw|Media tip}}",
 +      "whatlinkshere-hidelinks": "Filter option in [[Special:WhatLinksHere]].",
 +      "whatlinkshere-hideimages": "Filter option in [[Special:WhatLinksHere]].\n\nSee also:\n*{{msg-mw|Isimage}}\n*{{msg-mw|Media tip}}",
        "whatlinkshere-filters": "{{Identical|Filter}}",
        "whatlinkshere-submit": "Label for submit button in [[Special:WhatLinksHere]]\n{{Identical|Go}}",
        "autoblockid": "Used as name of autoblock, instead of autoblocked IPs. Parameters:\n* $1 - autoblock ID",
        "confirm-watch-top": "Used as confirmation message.",
        "confirm-unwatch-button": "Used as Submit button text.\n{{Identical|OK}}",
        "confirm-unwatch-top": "Used as confirmation message.",
+       "confirm-rollback-button": "Used as Submit button text.\n{{Identical|OK}}",
+       "confirm-rollback-top": "Used as confirmation message.",
        "semicolon-separator": "{{optional}}",
        "comma-separator": "{{optional}}\n\nWarning: languages have different usages of punctuation, and sometimes they are swapped (e.g. openining and closing quotation marks, or full stop and colon in Armenian), or change their form (the full stop in Chinese and Japanese, the prefered \"colon\" in Armenian used in fact as the regular full stop, the comma in Arabic, Armenian, and Chinese...)\n\nTheir spacing (before or after) may also vary across languages (for example French requires a non-breaking space, preferably narrow if the browser supports NNBSP, on the inner side of some punctuations like quotation/question/exclamation marks, colon, and semicolons).",
        "colon-separator": "{{optional}}\nChange it only if your language uses another character for ':' or it needs an extra space before the colon.",
        "timezone-local": "Label to indicate that a time is in the user's local timezone.\n{{Identical|Local}}",
        "duplicate-defaultsort": "See definition of [[w:Sorting|sort key]] on Wikipedia. Parameters:\n* $1 - old default sort key\n* $2 - new default sort key",
        "duplicate-displaytitle": "Warning shown when a page has its display title set multiple times. Parameters:\n* $1 - old display title\n* $2 - new display title",
 -      "restricted-displaytitle": "Warning shown a display title is ignored because it is not equivalent to its actual title. Parameters:\n* $1 - the ignored display title",
 +      "restricted-displaytitle": "Warning shown when a display title is ignored because it is not equivalent to its actual title. Parameters:\n* $1 - the ignored display title",
        "invalid-indicator-name": "Warning shown when the [https://www.mediawiki.org/wiki/Help:Page_status_indicators &lt;indicator name=\"''unique-identifier''\">''content''&lt;/indicator>] parser tag is used incorrectly.",
        "version": "{{doc-special|Version}}\n{{Identical|Version}}",
        "version-summary": "{{doc-specialpagesummary|version}}",
                return;
        }
        $( function () {
 -              var $patrolLinks = $( '.patrollink a' );
 +              var $patrolLinks = $( '.patrollink[data-mw="interface"] a' );
                $patrolLinks.on( 'click', function ( e ) {
                        var $spinner, rcid, apiRequest;
  
-                       // Start preloading the notification module (normally loaded by mw.notify())
+                       // Preload the notification module for mw.notify
                        mw.loader.load( 'mediawiki.notification' );
  
                        // Hide the link and create a spinner to show it inside the brackets.