Refactor watchlist token handling
authorMatmaRex <matma.rex@gmail.com>
Fri, 14 Jun 2013 16:59:59 +0000 (18:59 +0200)
committerMatmaRex <matma.rex@gmail.com>
Wed, 24 Jul 2013 20:06:15 +0000 (22:06 +0200)
commited7979a9703f8524044b4f9b477736b8c8b91dac
tree30c56b81007752da16ad630f848654eee5af9ca4
parent9406040657bce8e283b89b86f9de0bedd6154106
Refactor watchlist token handling

Do not allow the user to change it directly; instead create a form
where they can reset it. (The token can still be changed via the API.)
The token is autogenerated whenever it is shown or otherwise used.

This really should have never used the preferences; however, trying to
change that now would be lots of work for very little gain, so this
keeps using that mechanism, adding a little abstraction over it.

It's not unconceivable that similar tokens could be used for other
pieces of data, like Echo's notifications; this enables that with one
new hook.

----

Things done here:

* Add getTokenFromOption() and resetTokenFromOption() methods to User,
  abstracting out the get-and-generate-if-empty process of handling
  tokens. Respect $wgHiddenPrefs (Watchlist didn't do that
  previously).

* Create Special:ResetTokens, inspired by Special:Preferences and
  Special:ChangeEmail, presenting the token resetting interface
  (HTMLForm-based with CSRF protection).

* Create a new hook, SpecialResetTokensTokens, allowing extensions to
  register tokens to be shown in the resetting form. Each token needs
  information about the preference it corresponds to and a short
  description (used for checkbox label).

* Hide the preference on Special:Preferences (use type=api to achieve
  this), display a link to aforementioned special page instead. Move
  info blurb to its own section at the bottom.

Bug: 21912
Change-Id: I0bdd2469972c4af81bfb480e9dde58cdd14c67a8
12 files changed:
RELEASE-NOTES-1.22
docs/hooks.txt
includes/AutoLoader.php
includes/Preferences.php
includes/SpecialPageFactory.php
includes/User.php
includes/specials/SpecialResetTokens.php [new file with mode: 0644]
includes/specials/SpecialWatchlist.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messageTypes.inc
maintenance/language/messages.inc