Commit graph

94 commits

Author SHA1 Message Date
Brad Jorsch
fdddf94570 API: Overhaul token handling
The current token handling is a mess. This simplifies things greatly:
* *All* tokens are obtained from action=query&meta=tokens, rather than
  being spread over action=tokens, action=query&prop=info,
  action=query&prop=revisions, action=query&prop=recentchanges, and
  action=query&prop=users. All these old methods are deprecated.
* Similarly, there is only one hook to register new token types. All old
  hooks are deprecated.
* All tokens are cacheable.
* Most token types are dropped in favor of a 'csrf' token. They already
  were returning the same token anyway.
* All token-using modules will document the required token type in a
  standard manner in action=help and are documented in machine-readable
  fashion in action=paraminfo.

Note this will require updates to all extensions using tokens.

Change-Id: I2793a3f2dd64a4bebb0b4d065e09af1e9f63fb89
2014-08-26 14:53:45 -04:00
Brad Jorsch
f0a6435f3b API: Remove action=paraminfo 'props' and 'errors' result properties
The format for 'props' was never specified and the list for 'errors' is
impossible to keep updated when considering that many errors come from
MediaWiki backend code and extension hook functions. And since there
doesn't seem to be any real use case for either of these, let's just
kill both of them instead of wasting effort on trying to fix them.

Note that neither getResultProperties nor getPossibleErrors are called
from any extensions in gerrit, and none of the other deprecated methods
are called outside of the implementations of those two methods. Removing
the obsolete methods is left to the maintainers of the extensions, as
keeping them hurts nothing and is needed to maintain compatibility with
earlier versions of MediaWiki.

Change-Id: Ie11a401d60c834059fbf1b5625ca8ea093b3337c
2014-08-07 16:51:19 +01:00
addshore
719d7a2f03 Add final period to API module descriptions
Change-Id: Icae68c1ab1fd0006e00a3a9a56ae8f831d3d0d45
2014-03-10 09:04:08 +00:00
Siebrand Mazeland
d026e1a403 Address errors and warnings in CodeSniffer in api/
Change-Id: I06de371393d50eada33154626874b106d814642b
2013-11-17 16:52:24 +01:00
Brad Jorsch
43f3ab65cf SECURITY: Prevent tokens in jsonp mode
Add checks to token-returning functions to prevent returning tokens in
jsonp mode. This affects action=tokens, action=login,
action=createaccount, and action=query&list=deletedrevs.

Also, remove the "gettoken" parameter to action=block and
action=unblock, which has been deprecated since 1.20.

Bug: 49090
Change-Id: Ibeaa5c72d8084585092b15935a3f5709104bf7f7
2013-09-03 15:04:47 -07:00
umherirrender
a35cce4be0 Fixed spacing in api folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Id7779dca4d1185245cf5764102b8de8b232c34b6
2013-04-20 07:47:36 +00:00
umherirrender
e43dc272bd Fix align of block comments
Change-Id: I88ea33a125a71671886b49e4ebf4c1d0a1cce572
2013-03-07 17:27:38 +01:00
Alex Monk
b672653acc Use 'email' instead of 'e-mail' in API texts.
Bug: 45633
Change-Id: Ieddc066be4051a20f0500b52e6b021e877d6c97d
2013-03-02 18:34:59 +00:00
Antoine Musso
b2fba3f27f api: remove duplicate __contruct calls
For historical reasons, all our API class had a dummy __construct which
simply calls their parent constructor.  This patch removes all such
occurences to save out some bytes.

Change-Id: I667955d7821f780fc5ce23823d74dedb1729b9fa
2013-01-29 09:38:17 +01:00
umherirrender
2e8da558ba fix some spacing
Change-Id: Id7eda67a43f9040117edd79fdbeb678f1c3a6da2
2013-01-26 22:11:09 +01:00
Yuri Astrakhan
503cd2f4ae (bug 35885) remove api version string and parameter
API was using SVN's version keyword which GIT does not support.
All related methods were either removed, or for those that
could have been used from extensions, emptied out.
api.php?version now shows unrecognized param warning.

Change-Id: I910ca1448ed2ed697ac19b17c486d130aa1d7e03
2013-01-18 12:41:18 -05:00
Alex Monk
38d962030d (bug 38633) Don't block non-existent users via the API
Change-Id: I49232e177b23e11d04f64ac0d939073fa9418d64
2013-01-04 13:20:16 +00:00
Szymon Świerkosz
44d988fb72 (bug 32434) API allows reblocking the user without reblock parameter.
This change adds special case in processing of the block form.
An unused parameter 'AlreadyBlocked' was replaced by 'Reblock'.
Parameter 'PreviousTarget' was added so API user can block him/herself.

Change-Id: I29275eb4b5f425b7382ba8b7dec050209878f81b
2012-12-20 17:02:40 +01:00
Aaron Schulz
e6faa2fd76 Merge "escape HTML elements in docblock with double quotes" 2012-07-18 19:17:46 +00:00
Antoine Musso
4f5d2386f3 escape HTML elements in docblock with double quotes
Doxygen choke on text enclosed by '<' and '>' since it tries to
interpret them as HTML or XML elements. This patch adds double quotes
in includes/api/*.php files around the two following strings:

 <Firstname>.<Lastname>@gmail.com
 <Firstname><Lastname>@gmail.com

Which becomes:

 "<Firstname>.<Lastname>@gmail.com"
 "<Firstname><Lastname>@gmail.com"

Tested locally, it prevents doxygen 1.8.0 related warnings.

Change-Id: I36d82eb3fd4989ee3ffc65b0b527b83711d1ba69
2012-07-15 22:15:45 +02:00
umherirrender
89bb46e2e4 API: Cleanup around comment/reason params
* Moving setting of empty string to param description.
* Removing word "(optional)" from comment/reason param, because all not
  required params are optional.
* Correct description of action=rollback for default comment.

Change-Id: Ifa5b60a7b55b216c43049cd81cb584b2e0518eed
2012-07-08 23:31:26 +02:00
Petr Onderka
80aa025528 Added result properties to action=paraminfo
Added information about the properties of the results of API calls
to action=paraminfo, including information about "property groups":
what should the prop parameter be set to to get that property.

Uses the same format for types as parameters already do.
The output format of some modules doesn't fit this, so the result
properties for them weren't added, or only partially.

Partially implemented modules:
* expandtemplates:
  parsetree is in its own tag
* protect, allusers, backlinks, deletedrevs, info, imageinfo,
  logevents, querypage, recentchanges, revisions, searchinfo,
  usercontribs, userinfo, users, watchlist, upload:
  response with partially complex structure

Not implemented modules:
* feedcontributions, feedwatchlist, opensearch, rds:
  non-standard reponse
* help:
  error is normal response; not very useful for automated tools anyway
* paraminfo, parse, pageprops, siteinfo, userrights:
  response with complex structure

Change-Id: Iff2a9bef79f994e73eef3062b4dd5461bff968ab
2012-06-06 19:24:59 +02:00
Aaron Schulz
fdb74872a8 Merge "multi dbms support in api" 2012-05-20 18:15:42 +00:00
umherirrender
278bb4414f multi dbms support in api
Add some calls to Database::timestamp
Change some calls from Database::strencode to
Database::addQuotes to avoid ' in raw sql
Remove ' from ints in raw sql
Rename some vars to avoid duplicate names

Change-Id: I63f5602fa968f969a42932902a3ccc45fc54b432
2012-05-16 19:22:36 +02:00
Reedy
c87a63935a Merge "(bug 19195) Make user IDs more readily available with the API" 2012-05-10 18:47:42 +00:00
Szymon Świerkosz
aa86d2d3e6 (bug 35993) gettoken should go die in a fire (part 1)
Mark gettoken param as deprecated, so users can fix their tools.
The second part will remove the support for gettoken from ApiMain,
but that is in the future.

Change-Id: I369ddc740c38d80aa8389544087ac6671cabc618
2012-05-06 16:43:09 +02:00
umherirrender
426ccbf42e (bug 19195) Make user IDs more readily available with the API
Add some block ids and user ids to the result of some modules

Change-Id: If50604b888a54827eddde76574e779db6c7263ec
2012-04-22 14:20:46 +02:00
Reedy
df3e3943bd Bug 35646 - ApiBlockTest::testMakeNormalBlock() broken
Change-Id: I964cde249ce7193cb1ba8c3430645c36067876fb
2012-04-02 19:12:20 +01:00
Sam Reed
53000baecf Oh noes, moar http:// -> https:// 2011-11-28 15:43:11 +00:00
John Du Hart
2e7d867478 Removed the 'eclipse helper' bit on top of every API module
It's a parctice that dates back to 2006 when the API was first written, and frankly isn't covered by the coding conventions. Same thing with the docblocks, they're all copypasted with some bits changed and don't even make sense if you look at them in the genereated code docs.
I don't feel that any of us depend on this anymore (get a better IDE), so in the inerest of consistancy it's time we said goodbye to it.
2011-11-16 00:17:26 +00:00
Alexandre Emsenhuber
56508fdca6 Removed usage of $wgUser in block and unblock processing:
* Made HTMLFormField pass the HTMLForm object to the validation and filter callbacks (so that they can get a context)
* Added new parameter to SpecialBlock::checkUnblockSelf() to pass the user doing the request
* SpecialBlock::processForm() and SpecialUnblock::processUnblock() now require a context as second parameter; added SpecialBlock::processUIForm() and SpecialUnblock::processUIUnblock() as adaptators from HTMLForm as second parameter to context
2011-11-13 07:25:56 +00:00
Sam Reed
fa65fa3243 Documentation
Deprecated code updates
2011-10-27 00:46:17 +00:00
John Du Hart
40f19e6def Adding context to the API
This will probably break something somewhere so when it does please yell at me on IRC and I'll fix it.
2011-10-26 23:27:01 +00:00
Aaron Schulz
7d5c9504b5 (bug 31679) Fixed use of 'allowusertalk' 2011-10-13 22:23:13 +00:00
Sam Reed
a5628f5734 Based on diff to wikia, set more functions consistently public rather than protected 2011-08-17 22:24:21 +00:00
Sam Reed
6e84e9ccd9 Followup r92396, add help urls for most of the core (non query) modules 2011-07-17 16:38:24 +00:00
Antoine Musso
6a8e32e986 Single messages can be passed as strings to Api::dieUsageMsg()
Since r88045
2011-05-19 17:51:16 +00:00
Paul Copperman
f7e6dfb4a3 Various fixes for PHPUnit tests:
* Block.php: Set mExpiry to the value we store in the database, so that Block::equals() returns true. Fixes BlockTest::testInitializerFunctionsReturnCorrectBlock.
* In Title::checkUserBlock(): Convert message parameters to plain strings to make strict comparisons work. Fixes TitlePermissionTest::testUserBlock().
* ApiBlock.php: Follow-Up r85166, add 'Confirm' parameter to data array. Fixes ApiBlockTest::testMakeNormalBlock().
* ApiQueryTest.php: Use $wgMetaNamespace instead of $wgSitename	to account for customizations.
* RandomImageGenerator.php: Use default value for constructor param to prevent fatals.
* ApiTestCaseUpload.php: 
** Fix undefined variable $fileName.
** Remove stray ini_set statements, they don't belong there. Especially ini_set( 'error_reporting', 1 ) will effectively disable all reporting, which makes errors hard to track.
* ArticleTablesTest.php: Put testbug14404() in group Broken, as the fix for the bug has been reverted in r83868.
2011-04-07 14:54:38 +00:00
Platonides
b37e81b76b Use class name Html in canonical form.
Removed unused globals $wgHooks, $wgBlockAllowsUTEdit, $wgUser, $wgOut
$wgUser was already set global at function beginning.
Moved global out of switch
2011-03-24 21:35:14 +00:00
Happy-melon
6dbcdc1be0 Blame hashar for this giant commit; he teased me for making so many smaller ones earlier... :D
* Internalise $mAddress/$mUser, $mBy/$mByName, $mEnableAutoblock, $mId as getTarget(), getBlockers(), isAutoblocking(), getId().  
* This required editing AbuseFilter and CheckUser backwards-incompatibly, so push the rest of the changes out to those extensions.
* Attack the evil 14-parameter constructor and gratuitously-confusing newFromDB( $notVeryImportantParameter, $moreImportantParameter)
* Reimplement the hack for bug 13611 in a slightly less fragile fashion; could still do with further cleanup, but then again the login frontend is its own can of worms... :S
* Remove transitionary getTargetAndType() and newFromTargetAndType() methods
* Some optimisation in parseTarget()
* Fix the broken phpunit test mentioned in r84251
2011-03-21 19:12:41 +00:00
Happy-melon
21fcf991d0 Follow-ups to r84258 2011-03-18 22:28:39 +00:00
Happy-melon
04aad77ea1 Follow-up r83825: fix fatal in API 2011-03-13 17:02:50 +00:00
Happy-melon
7805997608 Divert a river through the Augean Stables that is SpecialBlockip.php.
* Move to SpecialBlock.php, and rename class appropriately
* Complete refactor
* Use HTMLForm in block form.  This changes most of the ids and field names on the form, but allows proper validation, nicer formatting, clears up several fixmes, and is generally Better(TM).
* Spin various parts out into static functions, several of which properly belong in the backend (but Block.php is a worse mess still)
* Invert some of the block options so that every checkbox makes the block more severe (so "check to disable email" is fine, but "check to allow usertalk edit" (default true) is inverted to "check to disable usertalk edit" (default false). 
* revert r40359 (move doMassUserBlock() to core).  No one seems to be using this function, which has nothing to do with the frontend UI in SpecialBlock (it might perhaps belong in Block.php); it is pretty bespoke for CheckUser, doesn't seem to have very much utility elsewhere.
2011-03-12 21:54:35 +00:00
Alexandre Emsenhuber
60f1302644 Per Platonides, fix for r82686: make ApiUploadTest work again
Added option request parameter to User::editToken() and User::matchEditToken() and use them where possible from the api.
Also removed $_SESSION usage since it's no longer needed
2011-03-02 12:52:47 +00:00
Sam Reed
27ca6b2fa8 Tweak comments, remove some unused stuff.
Explicit definitions, move a few minor bits around
2011-02-27 21:10:11 +00:00
X!
867c9402be -Add &watchuser option to ApiBlock
-Write tests for ApiBlock
2011-01-02 19:58:27 +00:00
Sam Reed
6309c920dd Delete all the "API for MediaWiki 1.8+" comments
Add since to ApiQueryQueryPage
2010-12-22 20:52:06 +00:00
Roan Kattouw
17487e40ba Replace my old e-mail address with my new one in API comments. A bit outdated (dropped the old one in September '08) 2010-12-22 20:48:10 +00:00
Bryan Tong Minh
b98f2a5a71 (bug 25174) Add equal sign to boolean parameters in examples, so that the examples work immediately when posted 2010-11-23 22:05:27 +00:00
Sam Reed
42b5c265c0 * (bug 25248) API: paraminfo errors with certain modules
Added a needsToken() function, rather than calling getTokenSalt, which can throw silly errors due to dependencies on parameters
2010-10-01 20:12:50 +00:00
Alexandre Emsenhuber
457eb73b61 Standardised file description headers, added @file 2010-08-07 19:59:42 +00:00
Sam Reed
f77fff0ffb Followup r70461 if PARAM_REQUIRED is set, use for missing param in getPossibleErrors in ApiBase
All but ApiQueryBacklinks
2010-08-04 19:20:15 +00:00
X!
1afd723c5b Followup to r70460 and r70461: Use true instead of 1 2010-08-04 14:29:39 +00:00
X!
8b466d3d0d Followup to r70460: Committed wrong version of ApiBase.php, convert all core API modules to PARAM_REQUIRED syntax 2010-08-04 14:15:33 +00:00
Sam Reed
5387b8a806 Stylize API up to date
Fix spaces from r69755

Minor update to RELEASE-NOTES per r69753
2010-07-23 07:33:40 +00:00