Commit graph

57 commits

Author SHA1 Message Date
umherirrender
aff21af9ae Allow aliased field names with separated syntax
This introduce the syntax from aliased table names for aliased field
names into the abstract database layer:

array( 'alias' => 'field' ) gives 'field AS alias'

This patch also includes changes to query pages, api and some more
places to show, how the new syntax looks in "production".

This allow us to remove the "AS" for Non-PostgreSQL databases, if we
want that.

Change-Id: I5f0de1c2f29092c173aec3de93ffdef436799e8d
2012-08-15 15:16:09 +02: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
9c37ab4fb3 * (bug 28817) Add reference help page link to API Modules
Last followup of r92396

Should be all modules with documentation pages in core now documented...
2011-07-17 17:02:06 +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
Sam Reed
bdf84cb20e Swap else if for elseif
Trimming trailing whitespace also

Doing in 3 commits, so hopefully reviewable in CR...
2011-06-17 16:03:52 +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
Derk-Jan Hartman
921619b119 Correct the address of the FSF in some of the GPL headers
59 Temple Place -> 51 Franklin Street
2010-06-21 13:13:32 +00:00
Sam Reed
faf34b4073 Per http://www.mediawiki.org/wiki/Special:Code/MediaWiki/66168#c7252 switch while ( $row = $db->fectchObject( $res ) ) to foreach ( $res as row )
On ApiQueryUsers switch $r to row, and remove nested brackets
2010-06-20 18:48:34 +00:00
Sam Reed
a90a0783de Nuke $db->freeResult() from Api stuffs 2010-06-20 17:48:21 +00:00
Roan Kattouw
d06b682e72 API: Add pltitles and tltemplates to prop=links and prop=templates respectively, similar to prop=categories's clcategories 2010-06-06 10:17:02 +00:00
Sam Reed
e55ed729c4 Mixture of things.
Couple of class comments

Normalisation of "." usage at end of lines (removed)

Normalisation of {prefix}parameter as per bug 23461
2010-05-11 22:30:18 +00:00
Jack Phoenix
eba6c94002 API: fix copyright symbol, coding style cleanup, more braces 2010-02-24 14:45:19 +00:00
Sam Reed
b15f2c8c46 Normalise comment usage (# --> //) 2010-01-23 22:52:40 +00:00
Sam Reed
b739e97341 More of r61437 (adding/removing whitespace) 2010-01-23 22:47:49 +00:00
Aryeh Gregor
3758769f0d stylize.php on API code
"I wouldn't object to stylizing the API code to bring it in line with
the rest of MW on principle, but I'm not gonna bother myself." --Roan
<http://www.mediawiki.org/wiki/Special:Code/MediaWiki/60657#c5108>

If you're seeing this commit in blames, tell your blame tool to ignore
whitespace, e.g., git blame -w or svn blame -x -w.
2010-01-11 15:55:52 +00:00
Roan Kattouw
2df33ff098 * API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB

For those who really care, per-file details follow:

ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
  (which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
  $wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
  will return false. Callers should check the return value and set a
  query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
  the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
  setIndexedTagName() on an array already in the result. This is needed for the
  'new' order of adding results, which means addValue()ing one result at a time
  until you hit the limit or run out, then calling this function to set the tag
  name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
  enable size checking in addValue(). This is used for stuff like query-continue
  elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
  decreases $mSize.

ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
  reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()

ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
  at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
  fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()

ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid

DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB

ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.

ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
  need for $lastId.

ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)

ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
  couldn't be processed.

ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
  didn't fit.

ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items

ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly

ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive

ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue

ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
Siebrand Mazeland
c426e6b9d7 Consistent casing for wfGetDB(), getDB(), and getDBKey() 2008-11-06 22:38:42 +00:00
Roan Kattouw
6071d72917 (bug 15173) Make prop={links,templatelinks} not break in PostgreSQL 2008-08-16 21:02:31 +00:00
Roan Kattouw
dde1b39e7e API: Change descriptions for some limit parameters to actually refer to the correct type of result 2008-07-22 13:26:15 +00:00
Roan Kattouw
dc4efc975b Revert most of r37534, which was an over-revert: just changing addQuotes() back to strencode() was enough. 2008-07-10 21:20:43 +00:00
Brion Vibber
0b0b33cd52 Partial revert of r37502, 37503: double-quoting of SQL strings 2008-07-10 21:08:37 +00:00
Roan Kattouw
d4bebe41ce API: Some cleanup and fixes before 1.13 is released:
* Fix regression from r37270: prop=categories paging was broken in generator mode.
* Fix drlimit=max, which was broken since r31384
* Use titleToKey() and keyToTitle() on title parts of the continue parameters in prop={links,templatelinks,categories,images}
* Use addQuotes() rather than strencode() in those same modules
* Don't trim message names in ammessages, it's stupid and undocumented
* Add $wgAPI{Meta,Prop,List}Modules to DefaultSettings.php explicitly
2008-07-10 14:13:11 +00:00
Roan Kattouw
afedf99ebe API: Add paging (i.e. limit and continue) parameters to prop={links,templatelinks,langlinks,extlinks,categories,images}. This means that these modules will no longer request data from the database without a LIMIT, and that clients will have to use the query-continue method to get all the results. 2008-07-07 17:32:22 +00:00
Roan Kattouw
00d4f3c482 Killing filesort in prop={links,templatelinks} when {pl,tl}namespace isn't set. 2008-07-07 13:08:03 +00:00
Alexandre Emsenhuber
087a9f70c5 WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>

Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage

One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
Roan Kattouw
ba0f2974df Force the pl_from/tl_from index here, as there are reasons to believe MySQL 4 selects the wrong index here (see bug 14102) 2008-05-13 14:01:40 +00:00
Roan Kattouw
3ca55a03ad (bug 14012) prop=templates filesorts under some conditions 2008-05-13 10:39:01 +00:00
Siebrand Mazeland
79d5225c0e * remove end of line whitespace
* remove empty lines at end of file
* remove "?>" where still present
2008-04-14 07:45:50 +00:00
Roan Kattouw
19358606a1 API: Changing all modules' getParamDescription(), getAllowedParams() and getDescription() methods to public. ApiParamInfo needs them, and some versions of PHP threw fatal errors because they were protected. Oddly, other versions didn't (maybe because the caller and the callee have a common ancestor?) 2008-01-28 19:05:26 +00:00
Victor Vasiliev
0495f90ebb Revert r28215: incorrectly moved files 2007-12-06 18:33:18 +00:00
Victor Vasiliev
4e4cdf079e Create includes/api/query for Query API and includes/api/edit for Edit API 2007-12-06 18:22:15 +00:00
Yuri Astrakhan
8ca133afff API: Big change: Removed all userCanRead() checks per IRC discussion. Only rvprop=content will now check that the page can be read. 2007-07-14 19:04:31 +00:00