Commit graph

89 commits

Author SHA1 Message Date
Brad Jorsch
d458953f20 ApiQueryCategories: Supply limit for DB query
The limit is applied in PHP, but all matching rows are being fetched
from the database. We should only fetch the number of rows needed.

Bug: T231462
Change-Id: Ie64ea6f79a187942c476868c383a1349d110aa7c
2019-09-02 11:39:45 +00:00
Reedy
4691389fa4 Use (int) rather than intval()
Bug: T216969
Change-Id: I4c06716c83b69d128f26fa7f68736808aa2d3d64
2019-02-25 00:38:33 +00:00
Umherirrender
c9d303d39e Remove "Created on" from file header comments
It is the job of git and svn to provide this information/metadata.
The form was different, some with short, some with long month name
some with leading zero at the day, some without.
The year is also present in the Copyright clause

Change-Id: If006907b82b9e45f13cfa2e45d41107a95570e1a
2018-01-26 23:12:40 +00:00
Brad Jorsch
61de3c3e61 API: Handle pltitles/tltemplates/clcategories/imimages with only invalid titles
If the parameter contains only invalid titles, it shouldn't be ignored.

Bug: T162816
Change-Id: I3ee6aeab421db5732b652fed21292d8509f8d757
2017-10-12 15:48:15 +00:00
Baha
036b9c4167 Make API documentation links language aware
Links generated by the API are now aware of the user's preferred
language and will show documents in that language if available.

To test, log in to mediawiki.org and set your language preference to 'es',
then on an MediaWiki installation with this patch view the generated
expanded API help at `api.php?action=help&recursivesubmodules=1&modules=main`.
Each link to documentation on mediawiki.org should take you to its
translated /es subpage, if one exists.

Bug: T104518
Change-Id: I339a1f3ae1bce9d759cf251899d57c32b1def91e
2017-04-05 11:08:25 -04:00
Brad Jorsch
4e6810e4a2 API: i18n for warnings and errors
API warnings and error messages are currently hard-coded English
strings. This patch changes that.

With a few exceptions, this patch should be compatible with non-updated
extensions:
* The change to ApiBase::$messageMap will blow up anything trying to
  mess with it.
* The changes to the 'ApiCheckCanExecute' hook will cause a wrong
  (probably unparsed) error message to be emitted for extensions not
  already using an ApiMessage. Unless they're currently broken like
  Wikibase.

Bug: T37074
Bug: T47843
Depends-On: Ia2b66b57cd4eaddc30b3ffdd7b97d6ca3e02d898
Depends-On: I2e1bb975bb0045476c03ebe6cdec00259bae22ec
Depends-On: I53987bf87c48f6c00deec17a8e957d24fcc3eaa6
Depends-On: Ibf93a459eb62d30f7c70d20e91ec9faeb80d10ed
Depends-On: I3cf889811f44a15935e454dd42f081164d4a098c
Depends-On: Ieae527de86735ddcba34724730e8730fb277b99b
Depends-On: I535344c29d51521147c2a26c341dae38cec3e931
Change-Id: Iae0e2ce3bd42dd4776a9779664086119ac188412
2016-12-06 10:20:48 -05:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
umherirrender
e3322c0bd8 API: Use message-per-value for apihelp-query+categories-param-prop
Use message-per-value for message
apihelp-query+categories-param-prop to allow smaller strings
for translation.
Each prop in a message also will show up a new parameter on the help
page without the adjust of the translation (but than in english instead
of fully skip it).

Change-Id: Iabdd4d3b7efcd0c4c800e24cc5c78db47df2f454
2015-08-06 10:32:53 +02:00
RobinHood70
15ecc5a93a Update getHelpUrls() for reworked mw.org API pages
Community members restructured the mediawiki.org API pages, e.g.
the meta allmessages query submodule is no longer in the catch-all
https://www.mediawiki.org/wiki/API:Meta?oldid=1408361#allmessages_.2F_am
but its own https://www.mediawiki.org/wiki/API:Allmessages

The links in the generated API help, e.g.
https://www.mediawiki.org/wiki/Special:ApiHelp/query+allmessages,  are no
correct. They're not 404s but they don't take you directly to the
relevant page.

This patch set fixes the getHelpUrls() URLs (and does nothing else).
I tested them all.

Thanks RobinHood70!

Change-Id: Icea94abdd22d1ad468172642a21641e7c5ce2046
2015-05-04 08:15:54 +00:00
Brad Jorsch
beab6b009e Change API result data structure to be cleaner in new formats
Nothing in this patch should result in changed output for format=json or
format=php except as noted in RELEASE-NOTES-1.25, and changed output for
format=xml should be similar or cosmetic. However, other code accessing
the result data directly may need to be updated.

Bug: T87053
Bug: T12887
Change-Id: I3500708965cb8869b5aed1543381aad208dadd13
2015-04-20 17:49:37 -04:00
Aaron Schulz
7e1a34ba32 Removed FORCE INDEX from API category queries
Change-Id: I7333256b90e18b9ccb6cc0852d021a5fad2c7b45
2015-02-23 05:10:57 +00:00
Brad Jorsch
f62bc7536e API: Fix access on getExamplesMessages
ApiBase declares it protected, but for some reason I had made it public
in all subclasses.

Change-Id: I8a50d4f47e66c7f09137968d3941dc5cdc1d28e4
2014-10-29 11:15:27 -04:00
Brad Jorsch
ad225f501c API: Internationalize all remaining core API modules
This also adds some new ApiBase::PARAM_* constants to generate more
helpful help, and a method to override the default description message
for the use of ApiDisabled and ApiQueryDisabled.

Bug: 71638
Change-Id: Ic0c3d232e0498d58a043037e2e0c6f0b1c3edad3
2014-10-20 16:56:35 -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
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
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
Siebrand Mazeland
b9b699cd1f Fix CodeSniffer errors and warnings on a number of ApiQuery classes
Change-Id: I763f79c66cd8ed2ca19586323d5b3ee8b60ffd18
2013-11-15 10:33:50 -08:00
Siebrand Mazeland
56aba313f6 Update formatting on some API classes (must've forgotten these)
Change-Id: I3fe42e75c3029dc76d2d1d40609c9a69aae8e987
2013-11-14 18:13:55 +00:00
umherirrender
97234cc884 Added spaces before and removed spaces after 'array'
Fix some other spacing while at it

Change-Id: I13f81533eaf40e06c13cf377c0f08ef5cef01d00
2013-04-14 21:57:46 +02:00
umherirrender
b1584c4748 Remove spaces around ::
Change-Id: I24fe5ad907bcf5235aa91b650785c571502456a1
2013-04-03 12:57:10 +02:00
Siebrand Mazeland
6d3bbbbdd9 Update PHPDoc comments
Change-Id: Id20f632762d705ba5e5eb18088f6e9e551b3f42b
2013-04-02 13:42:10 +02: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
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
Aaron Schulz
e6faa2fd76 Merge "escape HTML elements in docblock with double quotes" 2012-07-18 19:17:46 +00:00
Brad Jorsch
2b3f4d821c Avoid mangling fields in API continuation parameters
API continuation parameters encode sufficient state for a subsequent
query to continue where the previous one left off; this may sometimes
include page titles, with or without the namespace. Given that these
page titles are already in the exact format required for the next
request's SQL query, it is not necessary to "normalize" them in any way.
And if normalization does more than just change spaces to underscores or
vice versa (e.g. it canonicalizes namespace aliases or capitalizes the
first letter of the title), it can be actively harmful: see bug 36987
and bug 29290.

Note this patch involves a breaking API change: the values for the
"continue" parameter of various modules have been changed, and some
modules will now return "continue" as the continuation parameter instead
of reusing "from".

Note this patch also corrects a minor logic bug in ApiQueryAllLinks,
changing ">" to ">=". The line is being changed anyway, so I didn't
bother doing a separate changeset.

Change-Id: I459232e919d20f89f6de9d20640fd48c8fd5781c
2012-07-17 16:08:39 -07: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
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
umherirrender
81dd7fefa5 ORDER BY/GROUP BY accept arrays
renaming all variable which hold "' DESC'" to $sort
to keep it all the same

Change-Id: I75118f8cdd701f53949fe5cdd7155fb07f78ff65
2012-05-05 15:29:08 +02:00
umherirrender
1b41425ee4 (bug 26909) follow up r102947: fix the navigation with 'dir'
and 'continue' for some prop-Modules

Due to missing change of the where for the query-continue in my first
patch, using dir=descending will end up in a loop 

Change-Id: I6a9ade9feddcfd046de347cd83a756af828b5c18
2012-03-30 23:19:34 +02:00
Siebrand Mazeland
1033737a05 Change usage of quotes in API messages from ``x'' to "x". 2012-01-13 21:11:27 +00:00
Sam Reed
6115b93df8 Re-instate most of the revisions for bug 33147 "API examples should explain what they do"
Using this to sync up my working copies

Should have the little niggles tidied up though
2011-12-27 16:22:35 +00:00
Brion Vibber
ad0d48d6bc Revert r106439, r106441 - bad formatting mushing separate lines together 2011-12-20 22:11:29 +00:00
Sam Reed
1b46e91efd Convert a few more descriptions
Ping r106439
2011-12-16 15:45:16 +00: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
Roan Kattouw
2563e19c39 (bug 26909) Add dir parameter for prop= API modules. Modified patch by Umherirrender 2011-11-14 08:19:55 +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
d5e46f9614 Followup r92396
More modules documented, pretty much only action=query&list= to be done (ie links added where documentation pages exist already)
2011-07-17 16:51:11 +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
Roan Kattouw
8cc843f25c API: BREAKING CHANGE: (bug 28541) Output of binary ICU sortkeys is broken. Change sortkey fields in prop=categories and list=categorymembers to hexadecimal strings, that way we don't have any issues with scary binary stuff. Also change cmcontinue to take hex-encoded sortkeys and swap the order back to normal (previously sortkey was at the end because it could contain pipe characters, but that's not an issue with hex). 2011-04-17 12:41:29 +00:00
Sam Reed
ec07a4fe7b Bit of documentation, explicitness, variable definition 2011-02-24 23:03:00 +00:00
Sam Reed
fa64025161 More parameter documentation 2011-02-19 00:30:18 +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
Alexandre Emsenhuber
457eb73b61 Standardised file description headers, added @file 2010-08-07 19:59:42 +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
Tim Starling
b2dc451c82 Rewrote r69339 etc. to clean up API cache header handling.
* Introduced a "cache mode" concept to simplify the header generation code, and to avoid odd results when conflicting cache header requests are received from submodules, or at least to formalise the handling of such cases.
* Made the cache mode private by default, so that code written in ignorance of caching tends to be safe. If different query modules are used in a single request, private caching is preferred over public caching.
* Removed the "must-revalidate" option from all CC headers, this is really specific to page views with a hacked squid in front, I don't think it's applicable here.
* Made the watchlist module private. This is really the definition of private data. There's nothing in the HTTP spec that says the URL for a CC:public request is private and can't be leaked. CC:private provides protection against unknown proxy behaviour.
* In ApiQueryAllmessages: avoid calling $wgLang->getCode() to check if it's necessary to make a new $wgLang when lang= is specified, since this is the only thing that unstubs $wgUser.
* Removed "FIXME: should this check $user instead of $wgUser?" Answer is no.
2010-07-23 07:17:56 +00:00
Sam Reed
8f1d2cb199 Big blitz on unused variables (a lot of $db = $this->getDb() ) 2010-07-22 22:13:21 +00:00
Sam Reed
2d21295243 * (bug 23473) - Give description of properties on all modules
Commit patch by John Du Hart with a few minor tweaks/fixes
2010-06-23 19:36:26 +00:00