Commit graph

234 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
eikes
2f002458d5 Split "suppressrevision" into two user rights
In this change, a new passive user right named "viewsuppressed"
which can be used in order to view suppressed page content was added
to MediaWiki core.
Furthermore, this right was also added to the list of available rights,
to qqq.json and to en.json where also the description of the
"suppressrevision" right was adjusted in order to reflect reality.

Bug: 20476
Change-Id: Id1baacb9c782763db5e05ef8b5c1b761997efcc9
2014-07-19 18:11:15 +02:00
Roan Kattouw
de7d383d8f Followup e48ecbc5: fix fatal error due to undefined variable
Bug: 66669
Change-Id: I195a5ff539f09addb92d2bb07d53bdb3aef0db1f
2014-06-16 18:40:35 +00:00
Reedy
e48ecbc524 Switch API to use Config classes
Only done where globals are config (so not $wgParser, $wgContLang etc)

Change-Id: Ic39cdd858cfb9096a2bc09618f97e64270d76f13
2014-06-15 23:56:38 +01:00
jenkins-bot
926f665234 Merge "API: Fix prop=revisions&rvdiffto= without rvprop=content" 2014-05-20 01:34:12 +00:00
Thiemo Mättig
23632a4ecd Use precise ApiMain/ApiQuery type hints in all API modules
Which type is used depends on the ApiModuleManager responsible for
the API module. There are two managers, one in ApiMain and one in
ApiQuery. Both contain a list of API modules they instantiate.
Both use $this as the first parameter in the constructors of the
individual modules. There is no other regular way to instantiate the
modules, so we know the type must either be ApiMain or ApiQuery.

The lists don't intersect.

I would have prefered the naming scheme $mainModule for ApiMain
modules and $queryModule for ApiQuery modules but since this
doesn't add much I left the shorter variable names untouched.

Change-Id: Ie6bf19150f1c9b619655a06a8e051412665e54db
2014-05-16 11:07:23 -04:00
Brad Jorsch
4e5b1a4ecd API: Fix prop=revisions&rvdiffto= without rvprop=content
Make sure $this->section is initialized (and other stuff is checked)
when rvdiffto is used.

Bug: 64744
Change-Id: Ie6c50ad946ed5150819d004dabfe898a131a0a07
2014-05-02 10:41:25 -04:00
umherirrender
e63299d208 Fixed some @params documentation (includes/api)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I758fa4ad80ac95e2ddd3770bcb9b7d2e57ec34ea
2014-04-18 13:55:36 +00:00
addshore
719d7a2f03 Add final period to API module descriptions
Change-Id: Icae68c1ab1fd0006e00a3a9a56ae8f831d3d0d45
2014-03-10 09:04:08 +00:00
Kunal Mehta
45eeecde9a Fix typo in ApiQueryRevisions
Bug: 60635
Change-Id: Icd04ad8e5faaa4cb49a84e2002c953ef9f436cc7
2014-01-30 19:38:55 +00:00
Brad Jorsch
48de797fbd Improve API query RevDel handling
* ApiQueryDeletedrevs, ApiQueryFilearchive, ApiQueryRecentChanges, and
  ApiQueryWatchlist will now return entires where fields have been
  revision-deleted. "Hidden" indicators will be provided as appropriate.
* ApiQueryImageInfo, ApiQueryLogEvents, ApiQueryRevisions,
  ApiQueryContributions will now return field values in addition to the
  "hidden" indicators when the requesting user has the necessary rights.
* Modules that return "hidden" indicators will now also return a
  "suppressed" indicator.
* ApiQueryImageInfo will now return info for DELETED_FILE file revisions
  if the requesting user has the 'deletedtext' right.
* ApiQueryLogEvents, when searching by user or title, will now return
  entries where the user or action are revision-deleted if the
  requesting user has the 'deletedhistory' right.
* ApiQueryContributions now uses the correct user rights rather than
  'hideuser' to determine when to show contributions where the username
  was revision-deleted.
* ApiQueryContributions will now indicate when the revision text is
  hidden.
* Fix a bug in ApiQueryDeletedrevs found during testing where specifying
  the "content" prop along with the "tags" prop or "drtag" parameter
  would cause an SQL error.
* Fix various PHP warnings in ApiQueryFilearchive caused by the lack of
  ArchivedFile::selectFields() fields.
* ApiQueryImageInfo::getInfo's $metadataOpts parameter has been renamed
  $opts, and now may have an option to indicate the user to use for
  RevDel visibility checks.
* ApiQueryWatchlist now properly uses the actual user's rights for
  checking whether wlprop=patrol is allowed, rather than using the
  wlowner's rights.

Bug: 27747
Bug: 27748
Bug: 28261
Bug: 34926
Bug: 48966
Change-Id: Idec2199976f460e1c73a26d0717e9fc4ab8042bb
2014-01-17 11:43:22 -05:00
Brad Jorsch
97041a612e Remove change_tag_tag_id index forcing from API too
Change I6b8f35bd removed the forcing of the change_tag_tag_id index in
the UI code paths, but didn't do the same for the API like it probably
should have.

Change-Id: Ie3a00b3a0ad194169a026370510f3e21c3abc079
2013-12-04 12:26:24 -05:00
Siebrand Mazeland
a37e466918 Fix CodeSniffer errors and warnings on yet more API classes
Change-Id: I67739a0b7c456f3684abea84833753e79a485c07
2013-11-15 17:53:10 +00:00
Siebrand Mazeland
dadbe23810 I'm in your API classes updating your formatting
Change-Id: I6087573dfdc6edcd63062508056ebcf3502e03f2
2013-11-14 18:28:26 +00:00
Reedy
7d922d08bf Removed $wgOldChangeTagsIndex
Bug 40866

Change-Id: Ifa003dece15d0866ed50cf3e2ecc6a5e70a3932a
2013-07-12 19:06:15 +01:00
umherirrender
c802c5b1ab Remove unneeded parenthesis from warning text in prop=revisions
Change-Id: I8d2ca6a4b7199fa1f4fe3b3e63dbefb2cc273d7b
2013-06-09 12:07:41 +02:00
umherirrender
da39005596 Removed space after isset
While at it, added/removed some other spaces in the same files

Change-Id: Iabb23a448f6f53eb6020155f9c744f74f8b11786
2013-04-26 14:18:06 +02:00
umherirrender
15abcf71ca Added/Removed spaces around string concatenation
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !

Fixed windows newline style

Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
2013-04-13 13:36:24 +02:00
Yuri Astrakhan
0aa24ae558 Fixed many small spelling mistakes and php docs, var decl.
Change-Id: I1508ed7eb77e5e4f700fb63955d626c4f5915840
2013-03-10 23:45:51 -04:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
umherirrender
f97a3a4027 fix some spacing
Change-Id: I670a7baf3ba1e70d18346bb00938d518ba2063bd
2013-02-04 19:59:14 +00: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
Yuri Astrakhan
983545c362 API Cleanup: renamed '_badcontinue'->'badcontinue', one die()
* If a query module has 'continue' parameter, it will auto-report
that it has 'badcontinue' error.
* Added APIQueryBase::DieUsageContinueIf( $condition ) that shows
correct badcontinue error if $condition is true.

Change-Id: I9c48bda6de0cde3c117ad24460bddf6980279633
2013-01-14 21:19:16 -05:00
Brad Jorsch
9f3863c507 (bug 43820) Content also needed for prop=revisions&rvdiffto=
It was somehow overlooked that prop=revisions&rvdiffto= also requires
that the content for the current revision be fetched.

Change-Id: Ie1d718458da8cdb6ba63bd7ea512db3b299fc1e2
2013-01-10 09:24:39 -05:00
jenkins-bot
f741e3d95d Merge "(bug 42168) Nicely handle missing revisions in ApiQueryRevisions." 2012-12-20 14:59:28 +00:00
daniel
e0ca64fb6c (bug 42168) Nicely handle missing revisions in ApiQueryRevisions.
ApiQueryRevisions had fatal errors when the Content object of a revision was null.
Should be fixed now.

Change-Id: Ic41d03fc55413ba7ba1c96b4f06d71d79fb7c4eb
2012-12-20 15:22:58 +01:00
Alex Monk
9072a50845 (bug 43137) Don't return the sha1 of revisions through the API if the content is revdel'd
Change-Id: Ic2cad08cdae428d04dbdc31665c531d8a4759cbb
2012-12-17 17:08:35 +00:00
IAlex
8fe652709d Merge "Add 'contentmodel' to resultproperties in prop=revisions" 2012-11-15 10:10:00 +00:00
daniel
cef8005d3a When returning rev content, always include model.
query=revisions can be used with rvprop=content to retrieve the
content of revisions. The contentmodel should always be included
with the content (just like the contenformat is), so the client
is able to interpret the structure contained in the content blob.

Change-Id: I67cf48f905ff83a86992e1a54f7ad0feaf2b2c94
2012-11-14 14:53:34 +01:00
Kevin Israel
4f6234213f (bug 41899) Fix "Undefined index: start" notice
Unsetting the continue param rather than setting it to null
results in this PHP error message.

Patchset 2: added release note.

Change-Id: Ieb6be0ac047d6a4a46fb6522fbbdc058bb386411
2012-11-08 13:58:47 -05:00
umherirrender
7268330aa2 Add 'contentmodel' to resultproperties in prop=revisions
Change-Id: Ied3ad1b5088821fbb6c51fd91a5eac09e900fd96
2012-10-31 19:44:48 +01:00
umherirrender
185da8808e (bug 40574) hints for generatexml param in api modules
Change-Id: I782d64eed5faac6836a57463e195e64c4314199c
2012-10-30 10:16:04 +00:00
aude
8bac2d0e7c fix bug 41122, provide missing revId param in ApiQueryRevisions
Change-Id: I8e6b4f845f15bb230965e0e765fdc0f15f67c014
2012-10-18 23:33:34 +02:00
daniel
bb51a58e57 Cleanup of Wikidata branch.
This cleans up several issues raised in comments to I3b2dad3a,
mostly style and merge artifacts.

Change-Id: I99f5e300a671db1353db151cd187ffd2e4478d03
2012-10-08 17:34:47 +02:00
daniel
c546fae8ed merge latest master into Wikidata branch
Change-Id: Id4e0f40c03679c13d8934a6add99b5cd86d0437d
2012-10-08 13:58:54 +02:00
umherirrender
eb41fc9dc1 Add User to Title::userCan calls in api
Change-Id: I86ee1398abe4a790796d61aba1e1739bc55e565b
2012-09-22 13:33:33 +02:00
daniel
9994968774 merged master
Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
2012-08-29 15:20:15 +02:00
Daniel Kinzler
392af46809 Revert "merged master"
This reverts commit 67bfdc7a68
2012-08-29 13:14:49 +00:00
daniel
67bfdc7a68 merged master
Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
2012-08-29 12:06:38 +02:00
daniel
2bc191889a Fixing creation of DifferenceEninge
Creation of DifferenceEninge insteances was based on invalid assumptions
in several places.

Change-Id: Ib67ca893ea53a27d4ac7efd8a9ca0d3b2d93949f
2012-08-24 20:49:19 +02:00
Siebrand Mazeland
c848f486bc Replace deprecated wfMsg* calls with Message class calls.
Doing this in steps of roughly 100 changes per commit, so that it remains
reviewable. This should be the one but last change set with the "easy"
ones for core.

Change-Id: If894a92dd65b2f5f4f096b9133685eb3b067a1d8
2012-08-21 21:58:47 +02:00
daniel
0139923580 fixing long lines
Change-Id: Iebcd40a1a37a3a93cc571fa2c2b0a87f53dc97a4
2012-08-20 21:33:07 +02:00
daniel
29719f846b merging latest master
Change-Id: I36b7f2f63ab8c08f8412d521dc68ea45c8b67711
2012-08-20 16:55:28 +02:00
Brad Jorsch
7a657188a1 (bug 38904) prop=revisions&rvstart=... should not blow up when continuing
A query using prop=revisions in enum mode will return a query-continue
using rvstartid. If the original query included rvstart, the client will
therefore send both the rvstart from the original query and the
rvstartid from the query-continue. And the API will then return an error
that rvstart and rvstartid may not both be used in the same query.

Since there is no way for the API to instruct the client to ''not'' send
the rvstart when continuing, we'll just use rvcontinue instead. Then the
module can ignore both rvstart and rvstartid to get the intended
continuation.

Change-Id: I145215996b8a7818196cdfb583a1fdacae973fee
2012-08-02 14:47:02 -07:00
daniel
d87135d706 merged master
Change-Id: Iad12ee382d6aeb1fab6fefb611d290b74865ea4b
2012-07-23 22:07:18 +02: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
daniel
906a1ba51f [bug 37746] string ids for content model and format.
The content model is stored as a varbinary(32), the format
as varbinary(64).

If the standard model resp. format is used, null is written
to the database instead of the actual id, saving space.

Change-Id: I32659b49a9ad3cb8ecae9019562cff7de42b65f9
2012-06-26 15:56:06 +02:00
daniel
4c812f8462 use 'contentformat' instead of 'textformat' in result
Change-Id: If2d392329bb1618dbacf489f96b53115281b8e97
2012-06-14 17:15:08 +02:00
daniel
a830943203 Merge branch 'master' of ssh://gerrit.wikimedia.org:29418/mediawiki/core into Wikidata 2012-06-14 12:43:43 +02:00