Merge "API: Overhaul token handling"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 26 Aug 2014 19:09:21 +0000 (19:09 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 26 Aug 2014 19:09:21 +0000 (19:09 +0000)
1  2 
RELEASE-NOTES-1.24
docs/hooks.txt
includes/AutoLoader.php

diff --combined RELEASE-NOTES-1.24
@@@ -63,8 -63,6 +63,8 @@@ production
  * The default thumb size ($wgDefaultUserOptions['thumbsize']) is now 300px, up from
    180px. If you have altered the number of entries in $wgThumbLimits for your wiki, you
    may need to adjust your default user settings to compensate for the index change.
 +* $wgDeferredUpdateList is now deprecated, you should use DeferredUpdates::addUpdate()
 +  instead.
  
  === New features in 1.24 ===
  * Added a new hook, "WhatLinksHereProps", to allow extensions to annotate
  * (bug 35045) Redirects to sections will now update the URL in browser's address
    bar using the HTML5 History API. When [[Dog]] redirects to [[Animals#Dog]],
    the user will now see "Animals#Dog" in their browser instead of "Dog#Dog".
+ * API token handling has been rewritten. Any API module using tokens will need
+   to be updated.
  
  === Bug fixes in 1.24 ===
  * (bug 50572) MediaWiki:Blockip should support gender
    automatically queries the list of submodule names from the ApiModuleManager.
  * The iwurl parameter to prop=iwlinks is deprecated in favor of iwprop=url, for
    parallelism with prop=langlinks.
+ * All tokens should be fetched from action=query&meta=tokens; all other methods
+   of fetching tokens are deprecated. The value needed for meta=tokens's 'type'
+   parameter for each module is documented in the action=help output and is
+   returned from action=paraminfo.
  
  === Languages updated in 1.24 ===
  
@@@ -306,7 -310,7 +312,7 @@@ changes to languages because of Bugzill
    set of hooks has been removed and replaced by a single new hook
    SpecialPageBeforeFormDisplay.
  * (bug 65781) Removed block warning on included {{Special:Contributions}}
 -* Removed Skin::makeGlobalVariablesScript. (deprecated since 1.19)
 +* Removed Skin::makeGlobalVariablesScript(). (deprecated since 1.19)
  * Removed MWNamespace::isMain(). (deprecated since 1.19)
  * Removed Preferences::loadOldSearchNs(). (deprecated since 1.19)
  * Removed OutputPage::getStatusMessage(). (deprecated since 1.18)
    setPreloadedText() from EditPage.php. (deprecated since 1.21)
  * Removed global functions wfArrayLookup(), wfArrayMerge(), wfDebugDieBacktrace()
    and wfTime(). (deprecated since 1.22)
 -* Microsoft Internet Explorer 6 is now a "grade C" browser, meaning that
 -  JavaScript is no longer executed in this browser. The IEFixes script, which
 -  existed purely to provide support for MSIE versions below 7 and which was
 -  conditionally loaded for those browsers, was also removed.
 +* Browser support for Internet Explorer 6 lowered from Grade A to Grade C,
 +  meaning that JavaScript is no longer executed in this browser.
 +* Browser support for Opera 11 lowered from Grade A to Grade C.
 +* Removed IEFixes module which existed purely to provide support for MSIE versions
 +  below 7 (conditionally loaded only for those browsers).
  * Action::checkCanExecute() no longer has a return value.
  * Removed cleanupForIRC(), loadFromCurRow(), newFromCurRow(), notifyRC2UDP()
    and sendToUDP() from RecentChange.php. (deprecated since 1.22)
  * Removed EnhancedChangesList::arrow(), sideArrow(), downArrow(), spacerArrow().
  * Removed Xml::namespaceSelector(). (deprecated since 1.19)
 -* Removed WikiPage::estimateRevisionCount. (deprecated since 1.19)
 +* Removed WikiPage::estimateRevisionCount(). (deprecated since 1.19)
 +* MYSQL: Enum item added to "major MIME type" columns.
 +  Running update.php on MySQL < v5.1 may result in heavy processing.
 +* RSS and Atom feeds generated by MediaWiki no longer include a fallback
 +  stylesheet. It was ignored by most browsers these days anyway.
  
  ==== Renamed classes ====
  * CLDRPluralRuleConverter_Expression to CLDRPluralRuleConverterExpression
diff --combined docs/hooks.txt
@@@ -402,36 -402,39 +402,39 @@@ an action=query submodule. Use this to 
  &$module: Module object
  &$resultPageSet: ApiPageSet object
  
- 'APIQueryInfoTokens': Use this hook to add custom tokens to prop=info. Every
- token has an action, which will be used in the intoken parameter and in the
- output (actiontoken="..."), and a callback function which should return the
- token, or false if the user isn't allowed to obtain it. The prototype of the
- callback function is func($pageid, $title), where $pageid is the page ID of the
- page the token is requested for and $title is the associated Title object. In
- the hook, just add your callback to the $tokenFunctions array and return true
- (returning false makes no sense).
+ 'APIQueryInfoTokens': DEPRECATED! Use ApiQueryTokensRegisterTypes instead.
+ Use this hook to add custom tokens to prop=info. Every token has an action,
+ which will be used in the intoken parameter and in the output
+ (actiontoken="..."), and a callback function which should return the token, or
+ false if the user isn't allowed to obtain it. The prototype of the callback
+ function is func($pageid, $title), where $pageid is the page ID of the page the
+ token is requested for and $title is the associated Title object. In the hook,
+ just add your callback to the $tokenFunctions array and return true (returning
+ false makes no sense).
  $tokenFunctions: array(action => callback)
  
- 'APIQueryRevisionsTokens': Use this hook to add custom tokens to prop=revisions.
- Every token has an action, which will be used in the rvtoken parameter and in
- the output (actiontoken="..."), and a callback function which should return the
- token, or false if the user isn't allowed to obtain it. The prototype of the
- callback function is func($pageid, $title, $rev), where $pageid is the page ID
- of the page associated to the revision the token is requested for, $title the
+ 'APIQueryRevisionsTokens': DEPRECATED! Use ApiQueryTokensRegisterTypes instead.
+ Use this hook to add custom tokens to prop=revisions. Every token has an
+ action, which will be used in the rvtoken parameter and in the output
+ (actiontoken="..."), and a callback function which should return the token, or
+ false if the user isn't allowed to obtain it. The prototype of the callback
+ function is func($pageid, $title, $rev), where $pageid is the page ID of the
+ page associated to the revision the token is requested for, $title the
  associated Title object and $rev the associated Revision object. In the hook,
  just add your callback to the $tokenFunctions array and return true (returning
  false makes no sense).
  $tokenFunctions: array(action => callback)
  
- 'APIQueryRecentChangesTokens': Use this hook to add custom tokens to
- list=recentchanges. Every token has an action, which will be used in the rctoken
- parameter and in the output (actiontoken="..."), and a callback function which
- should return the token, or false if the user isn't allowed to obtain it. The
- prototype of the callback function is func($pageid, $title, $rc), where $pageid
- is the page ID of the page associated to the revision the token is requested
- for, $title the associated Title object and $rc the associated RecentChange
- object. In the hook, just add your callback to the $tokenFunctions array and
- return true (returning false makes no sense).
+ 'APIQueryRecentChangesTokens': DEPRECATED! Use ApiQueryTokensRegisterTypes instead.
+ Use this hook to add custom tokens to list=recentchanges. Every token has an
+ action, which will be used in the rctoken parameter and in the output
+ (actiontoken="..."), and a callback function which should return the token, or
+ false if the user isn't allowed to obtain it. The prototype of the callback
+ function is func($pageid, $title, $rc), where $pageid is the page ID of the
+ page associated to the revision the token is requested for, $title the
+ associated Title object and $rc the associated RecentChange object. In the
+ hook, just add your callback to the $tokenFunctions array and return true
+ (returning false makes no sense).
  $tokenFunctions: array(action => callback)
  
  'APIQuerySiteInfoGeneralInfo': Use this hook to add extra information to the
@@@ -443,13 -446,19 +446,19 @@@ $module: the current ApiQuerySiteInfo m
  sites statistics information.
  &$results: array of results, add things here
  
- 'APIQueryUsersTokens': Use this hook to add custom token to list=users. Every
- token has an action, which will be used in the ustoken parameter and in the
- output (actiontoken="..."), and a callback function which should return the
- token, or false if the user isn't allowed to obtain it. The prototype of the
- callback function is func($user) where $user is the User object. In the hook,
- just add your callback to the $tokenFunctions array and return true (returning
- false makes no sense).
+ 'ApiQueryTokensRegisterTypes': Use this hook to add additional token types to
+ action=query&meta=tokens. Note that most modules will probably be able to use
+ the 'csrf' token instead of creating their own token types.
+ &$salts: array( type => salt to pass to User::getEditToken() )
+ 'APIQueryUsersTokens': DEPRECATED! Use ApiQueryTokensRegisterTypes instead.
+ Use this hook to add custom token to list=users. Every token has an action,
+ which will be used in the ustoken parameter and in the output
+ (actiontoken="..."), and a callback function which should return the token, or
+ false if the user isn't allowed to obtain it. The prototype of the callback
+ function is func($user) where $user is the User object. In the hook, just add
+ your callback to the $tokenFunctions array and return true (returning false
+ makes no sense).
  $tokenFunctions: array(action => callback)
  
  'ApiMain::onException': Called by ApiMain::executeActionWithErrorHandling() when
@@@ -463,8 -472,8 +472,8 @@@ key for the array that represents the s
  key-value-pair identified by the apiLink key is required.
  &$apis: array of services
  
- 'ApiTokensGetTokenTypes': Use this hook to extend action=tokens with new token
- types.
+ 'ApiTokensGetTokenTypes': DEPRECATED! Use ApiQueryTokensRegisterTypes instead.
Use this hook to extend action=tokens with new token types.
  &$tokenTypes: supported token types in format 'type' => callback function
  used to retrieve this type of tokens.
  
@@@ -1773,6 -1782,13 +1782,6 @@@ $db: The database object to be queried
  &$opts: Options for the query.
  &$join_conds: Join conditions for the query.
  
 -'MonoBookTemplateToolboxEnd': DEPRECATED. Called by Monobook skin after toolbox
 -links have been rendered (useful for adding more). Note: this is only run for
 -the Monobook skin. To add items to the toolbox you should use the
 -SkinTemplateToolboxEnd hook instead, which works for all "SkinTemplate"-type
 -skins.
 -$tools: array of tools
 -
  'BaseTemplateToolbox': Called by BaseTemplate when building the $toolbox array
  and returning it for the skin to output. You can add items to the toolbox while
  still letting the skin make final decisions on skin-specific markup conventions
diff --combined includes/AutoLoader.php
@@@ -31,6 -31,7 +31,6 @@@ $wgAutoloadLocalClasses = array
        # Includes
        'AjaxDispatcher' => 'includes/AjaxDispatcher.php',
        'AjaxResponse' => 'includes/AjaxResponse.php',
 -      'AlphabeticPager' => 'includes/Pager.php',
        'AtomFeed' => 'includes/Feed.php',
        'AuthPlugin' => 'includes/AuthPlugin.php',
        'AuthPluginUser' => 'includes/AuthPlugin.php',
        'IdentityCollation' => 'includes/Collation.php',
        'ImportStreamSource' => 'includes/Import.php',
        'ImportStringSource' => 'includes/Import.php',
 -      'IndexPager' => 'includes/Pager.php',
        'Interwiki' => 'includes/interwiki/Interwiki.php',
        'License' => 'includes/Licenses.php',
        'Licenses' => 'includes/Licenses.php',
        'MWHttpRequest' => 'includes/HttpFunctions.php',
        'MWNamespace' => 'includes/MWNamespace.php',
        'OutputPage' => 'includes/OutputPage.php',
 -      'Pager' => 'includes/Pager.php',
        'PathRouter' => 'includes/PathRouter.php',
        'PathRouterPatternReplacer' => 'includes/PathRouter.php',
        'PhpHttpRequest' => 'includes/HttpFunctions.php',
        'PrefixSearch' => 'includes/PrefixSearch.php',
        'ProtectionForm' => 'includes/ProtectionForm.php',
        'RawMessage' => 'includes/Message.php',
 -      'ReverseChronologicalPager' => 'includes/Pager.php',
        'RevisionItem' => 'includes/RevisionList.php',
        'RevisionItemBase' => 'includes/RevisionList.php',
        'RevisionListBase' => 'includes/RevisionList.php',
        'StringPrefixSearch' => 'includes/PrefixSearch.php',
        'StubObject' => 'includes/StubObject.php',
        'StubUserLang' => 'includes/StubObject.php',
 -      'TablePager' => 'includes/Pager.php',
        'MWTimestamp' => 'includes/MWTimestamp.php',
        'TimestampException' => 'includes/TimestampException.php',
        'Title' => 'includes/Title.php',
        'ApiQuerySiteinfo' => 'includes/api/ApiQuerySiteinfo.php',
        'ApiQueryStashImageInfo' => 'includes/api/ApiQueryStashImageInfo.php',
        'ApiQueryTags' => 'includes/api/ApiQueryTags.php',
+       'ApiQueryTokens' => 'includes/api/ApiQueryTokens.php',
        'ApiQueryUserInfo' => 'includes/api/ApiQueryUserInfo.php',
        'ApiQueryUsers' => 'includes/api/ApiQueryUsers.php',
        'ApiQueryWatchlist' => 'includes/api/ApiQueryWatchlist.php',
        'WikiFilePage' => 'includes/page/WikiFilePage.php',
        'WikiPage' => 'includes/page/WikiPage.php',
  
 +      # includes/pager
 +      'AlphabeticPager' => 'includes/pager/AlphabeticPager.php',
 +      'IndexPager' => 'includes/pager/IndexPager.php',
 +      'Pager' => 'includes/pager/Pager.php',
 +      'ReverseChronologicalPager' => 'includes/pager/ReverseChronologicalPager.php',
 +      'TablePager' => 'includes/pager/TablePager.php',
 +
        # includes/parser
        'CacheTime' => 'includes/parser/CacheTime.php',
        'CoreParserFunctions' => 'includes/parser/CoreParserFunctions.php',