Commit graph

126 commits

Author SHA1 Message Date
Brad Jorsch
ce0de4aa88 API: Don't double generator list
Bug: T77974
Change-Id: I1746da0f802e6ab7f87c83ad9918c05f98ab5ea8
2014-12-09 09:28:35 -05:00
Brad Jorsch
e2055fe0a5 API: Allow generators to return data
It has long been requested that list=search and list=prefixsearch be
able to indicate the search result ordering when used as generators.
This change introduces a generic mechanism to allow for generators to
specify additional page data.

Bug: T16859
Bug: T75623
Change-Id: I115338d2bd890ccc109a79c65f92099c0d41fc2d
2014-11-26 10:41:17 -05:00
Brad Jorsch
991de897e4 API: Split list=deletedrevs into prop=deletedrevisions and list=alldeletedrevisions
list=deletedrevs has always been an odd one: it pretends to be a prop
module sometimes in taking titles from ApiPageSet, but when the pageset
supplies no titles it acts like a list module. This causes problems
such as bug 71389, and makes the whole thing unnecessarily confusing.

The solution is to split the "prop" and "list" aspects into separate
modules: prop=deletedrevisions when input should come from ApiPageSet
and list=alldeletedrevisions when not.

At the same time, let's take advantage of the situation to clear up some
other bugs. And let's share the revision-formatting code with
ApiQueryRevisions instead of partially reimplementing it.

Bug: 23489
Bug: 27193
Bug: 44190
Bug: 71396
Bug: 71389
Change-Id: I3e960d5c655bc57885d6d4ee227e67104808add7
2014-11-04 15:02:03 -05:00
Brad Jorsch
25a6a86690 API: Add doc warning to ApiPageSet::populateFromQueryResult
The cause of bug 72764 was an extension misusing
ApiPageSet::populateFromQueryResult(). Add a warning in the docs for
that method about proper usage.

Bug: 72764
Change-Id: I5b0a069d796f7f41ab0b16048d7b3d6600207383
2014-10-30 18:46:51 +00: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
07e40d04c6 API: Add ApiPageSet accessors for just good and missing titles
ApiPageSet::getAllTitlesByNamespace is fine when that's what you want.
But in all existing uses in core, it's not what's actually wanted.
* ApiQueryBacklinksprop can generate wrong ORDER BY because it considers
  redirect and invalid titles that it doesn't acutally query.
* ApiQueryCategoryInfo raises a fatal error with category redirects.
* ApiQueryDuplicateFiles and ApiQueryImageInfo will add information for
  redirects, leaving them missing the standard data and missing from
  indexpageids.

What all these need is really something along the lines of
"ApiPageSet::getGoodAndMissingTitlesByNamespace". So let's add that,
plus a few similar methods for good measure.

Bug: 71337
Change-Id: I3a205057edcbc303393718e1c8bfb1f1b1f95323
2014-09-26 11:25:36 -04:00
Yuri Astrakhan
703464a88c Cleanup - let's make IDEs more useful
http://phpdoc.org/docs/latest/references/phpdoc/types.html

If IDEs have many warnings, we don't look at them.
Let's minimize the number of warnings, and make them useful again.

* Some function docs fixes
* Removed unused $iwprefixes var in ApiQuerySearch.php
* declared private $blockStatusByUid in SpecialActiveusers
* declared private $repo in UploadFromChunks

Change-Id: Ifd20f78b168b9a913fdb8d89dc26a76a173b1c29
2014-08-13 16:02:59 -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
Siebrand Mazeland
f077c4b1d6 Update formatting
Change-Id: I18aff576262479c9bb1c56eb8e1d1aaae200e4b1
2014-02-06 09:27:05 +01:00
Siebrand Mazeland
0cef781886 Fix CodeSniffer errors and warnings
Change-Id: Idc74e34634d88625773fb8f73315f61edfa67e28
2014-02-05 11:20:17 +01:00
eranroz
75e28dc018 Support ApiPageSet in ApiWatch
Add support for ApiPageSet capabilities in ApiWatch to support batch
operation on titles, pageids etc. The old 'title' parameter (for a
single page) is still supported to keep backwards compatibility.

Moved a function from ApiPurge to ApiPageSet: getInvalidTitlesAndRevisions() gathers
warnings about invalid/missing titles/ids in the requested page set.

Split from If993f6e8.

Change-Id: I820dcb64d469616b10741df013911197cc5bde29
2014-02-04 14:44:22 -05:00
umherirrender
c0d3e85b06 Add Title::hasFragment and use it
Makes checks against the fragment easier to read and all the same.
At the moment some using strval, some use type safe comparsion.

Change-Id: I27d9c3e40e6de6800f4488de167cf06e83c88ce6
2014-01-24 15:42:13 +00:00
Siebrand Mazeland
8a096e3444 Random documentation tweaks
Change-Id: I57c3bde6551c14324cf34e4db003a319d6cebc47
2014-01-02 23:45:14 +01:00
Siebrand Mazeland
f8f3ddea50 Update docs to reduce inconsistent type compatibility in api/
Change-Id: Iaf97aeb514ddb2176491c3820fe891be8e989939
2013-11-17 21:47:51 +00:00
Siebrand Mazeland
1707a7995e Fix CodeSniffer errors and warnings (final round for API classes)
Change-Id: I97bf36ebef254818dc17378a06405b681ad19c59
2013-11-15 10:33:50 -08:00
Siebrand Mazeland
c6630e8bbe Update formatting on API classes, Part 3
Change-Id: I526be68e21836201c992b391a81f4d41e1fa801e
2013-11-14 18:12:29 +00:00
Brad Jorsch
a860b9a5b5 Fix exception in ApiPageSet
ApiPageSet is calling $this->profileOut(), then calling a function that
calls $this->profileDBIn(). Move that function to after a new
$this->profileIn().

Also, add a unit test for this situation.

Bug: 51821
Change-Id: Ib4dbfb567faadcd5e3d7d058ca6bdf8b4c83f634
2013-07-22 14:12:38 -04:00
umherirrender
ec9296e42f Do not returning external title in ApiPageSet::getRedirectTargets
Having a page with a redirect to "en:Main Page" will be added as "Main
Page" to the output, that is wrong

http://test.wikipedia.org/w/api.php?action=query&titles=Redirect%20to%20interwiki%20page&redirects

Change-Id: I7b59f592c1293dbb96f4c4279201bf04fcfea29d
2013-05-22 14:04:19 +00:00
Timo Tijhof
176c5354bb docs: Consistently use "since" phrasing in @deprecated
Most have it already:
https://doc.wikimedia.org/mediawiki-core/master/php/html/deprecated.html

Ran a find/replace on "@deprecated \d" to fix the odd ones.

Change-Id: I5217aaf75264a0036b5426cd8536116b4bb8f535
2013-05-15 00:56:57 +00:00
umherirrender
9f14ecf829 Added space after switch/Removed spaces after unset
While at it, added/removed some other spaces in the same files

Change-Id: I84d8001aa123a008807ad5eb76f396aed7c899a4
2013-04-26 16:42:31 +02:00
Siebrand Mazeland
6d3bbbbdd9 Update PHPDoc comments
Change-Id: Id20f632762d705ba5e5eb18088f6e9e551b3f42b
2013-04-02 13:42:10 +02:00
umherirrender
6c278b6d7e fix some spacing
* Removed spaces around array index
* Removed double spaces or added spaces to begin or end of function
  calls, method signature, conditions or foreachs
* Added braces to one-line ifs
* Changed multi line conditions to one line conditions
* Realigned some arrays

Change-Id: Ia04d2a99d663b07101013c2d53b3b2e872fd9cc3
2013-03-25 22:22:46 +00:00
Brad Jorsch
6aa1328c24 API: Fix parameter validation in setnotificationtimestamp
This was broken in I7a3d7b6e, when the ApiPageSet parameters stopped
being returned by getAllowedParams() and so by extractRequestParams().
Although it would be broken differently if they had been.

Change-Id: I4b6ec21fd7b7c932856546df1ccad574d996db1f
2013-03-21 09:07:33 -04:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
Yuri Astrakhan
dc889b9334 Two typo-bugs, credits update
* ApiMain::addFormat() had a missed bug for custom formatters.
* ApiPageSet used incorrect variable
* Marked Roan as leading until 2009 (per IRC discussion)
* Updated my involvement to present

Change-Id: I5964bcdd3f82fedad06732df39f420796abe972b
2013-03-07 15:32:45 -05: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
Jan Gerber
a72a8363b6 (bug 45201) Add option to pass defaultNamespace to ApiPageSet
Change-Id: I47f0ce18fcb877ae88e5eb26eef4c1c74a6d6755
2013-03-05 03:16:09 +00:00
Yuri Astrakhan
68820277af API continue param to streamline iteration of complex queries
Greatly simplifies query result iteration by the clients
by providing a mechanism to track sub-iterations (props in generated set)

Assuming the client has the param=>value dictionary with the original request
parameters, client will only need to perform this operation in their language
to get all results from the server regardless of what query they make.

  $request = array_merge( $request, $result['continue'] );

Related changes:
* Moved dieContinueUsageIf() from ApiQueryBase to ApiBase
* Internal calls will also return unused param warnings
* Reworked query unit tests for easier testing

Change-Id: Ieb45241fc6db2109f1d92fa3381165ec30701b63
2013-03-01 19:06:46 -05:00
Yuri Astrakhan
96a9603eea API Remove $wgAPIGeneratorModules - it's dynamic now
* $wgAPIGeneratorModules is now obsolete and will be ignored
* Removed generator tests - obsolete because there is no more list

Change-Id: I014260a42226854a2178345dc3cd0f50b41b3c08
2013-02-19 11:27:13 -05:00
Yuri Astrakhan
62216932c1 API PageSet allows generator for non-query modules
* PageSet can now be used in any action to process titles/pageids/revids
or any generator, redirects resolution, and converttitle functionality.
* action=purge proper usage of MustBePosted()
* Add supports for all pageset capabilities - generators, redirects, converttitles to
  action=purge and action=setnotificationtimestamp
* BREAKING CHANGE: ApiPageSet constructor now has two params instead of three, with only the
  first one keeping its meaning. ApiPageSet is now derived from ApiBase.
* BREAKING CHANGE: ApiQuery::newGenerator() and executeGeneratorModule() were deleted.

Change-Id: I7a3d7b6eb015d21ec1a9b9d9c6af9d97663f3f9a
2013-02-08 15:42:21 -05: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
Liangent
493fc3dfe3 (bug 43852) Fix converttitles param in api.php?action=query
Change-Id: I1658202f9228c2b99c0895d9c9b1a6d905f3021d
2013-01-11 09:53:34 +00:00
Reedy
493e87a34a Revert "(bug 29115) Add redirect target value on page info"
This reverts commit 0c6ba8c61d
2012-12-12 21:51:54 +00:00
umherirrender
0c6ba8c61d (bug 29115) Add redirect target value on page info
Added inprop=redirecttarget

Refactored ApiPageSet::getRedirectTargets to having one method for
resolving redirect targets and calling that from prop=info.

Change-Id: Ia5fb9f25488880c2dd63e613c913a0864464d327
2012-12-09 20:09:15 +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
Reedy
002d871048 Api method documentation tweaks
Change-Id: I43398b6016f64accf86921c72a6dac5e71e11c34
2012-07-12 16:53:00 +01:00
Antoine Musso
aab43dd495 escape tags and entity in doxygen comments
When inserting XML elements inline <such as this one>, doxygen chokes
about it not being known. Simply enclosing the tag in double quotes
prevents doxygen from emitting a warning.

Also enclosed a few invalid functions calls such as \. and double quoted
the HTML entities such as &foobar;

Change-Id: I4019637145e683c2bec3d17b2fd98b0c50a932f1
2012-07-10 17:08:32 +02:00
umherirrender
f263c6bcf2 Use Title::newFromRow in ApiPageSet::processDbRow
This avoids a query per title (due to Title::exist) in ApiQueryInfo.
The 3 minimum fields are always selected in ApiPageSet

Change-Id: Ic4876f947357d84a2f37bec60db3ccd44fe236ac
2012-06-06 18:39:30 +02:00
umherirrender
0ea2c38727 Fill GenderCache inside ApiPageSet
the queries for title and pageids are own queries created by the api,
which does not use the GenderCache, that can produce a query per row

Change-Id: I932f8d9d1cfa751dbb6f5237e2de325527d3ff53
2012-05-16 16:46:22 +02:00
Sam Reed
e1d83d5721 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 18:01:54 +00:00
Sam Reed
35e229c627 More documentation updates as I've been going around 2011-12-11 20:57:57 +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
a007de3666 Use WikiPage instead of Article 2011-11-12 07:36:41 +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
efa16d7165 Fix fixme on r89549 2011-06-06 15:58:55 +00:00
Matthew Britton
8a1f6bd717 follow up r89513: avoid internal error when only invalid revids/pageids are passed 2011-06-06 08:45:54 +00:00