Commit graph

100 commits

Author SHA1 Message Date
Sam Reed
2730c42dd8 Whitespace fixes
Addition/tweak of documentation
2011-05-08 21:47:01 +00:00
Sam Reed
ab28af877c Followup r85884
Fixup the APIs strange way of doing table aliases on a join....

Only used in very few places
2011-04-30 23:18:34 +00:00
Sam Reed
cf023d04dc As I've removed most of Roans reason to use php magic variables, completely remove them this time.
Followup r84430
2011-03-20 22:46:09 +00:00
Sam Reed
24d0b16dc9 Followup r84392
Be a bit more explicit about the code, add a bit of readability into foreach too
2011-03-20 22:35:41 +00:00
Roan Kattouw
a6c758a39a Per r83812 CR, solve the categorymembers paging problem by doing separate queries for each value of cl_type, with some trickery to make paging work. This makes the enum->varchar schema change for cl_type unnecessary, so I'll revert that.
Code was largely copied from Tim's CR comment on r83812 but adapted to deal with the fact that we have to apply the cmcontinue-induced WHERE on cl_sortkey and cl_from only for the first query. Because ApiQueryBase doesn't let us unset or overwrite conditions like these in a nice way, I added an $extraQuery parameter to ApiQueryBase::select() that excepts additional query parameters that are only applied to that query but not stored in the object.
2011-03-20 16:25:01 +00:00
Sam Reed
e357db3122 * (bug 27670) Ordering by timestamp (and usage of start and end) isn't as clear in auto generated document, as it is on mw.org
Followup r83797, closing. Adding bit of documentation, + RELEASE-NOTES
2011-03-13 00:07:22 +00:00
Sam Reed
8c6f2012b9 * (bug 27670) Ordering by timestamp (and usage of start and end) isn't as clear in auto generated document, as it is on mw.org
where dir = (newer|older)

Will look at doing (asc|desc)(ending)?
2011-03-12 23:39:15 +00:00
Sam Reed
20548c2596 Fix r83390, need to do where ipb_deleted IS NULL as we're left joining in the table, so it can be null
Duh
2011-03-07 22:58:26 +00:00
Sam Reed
aea7a5a482 Followup r83390
If the user is allowed to view hidden users, put a missing property on all users.

For list=users, do the same, but we can't easily distinguish to other people the difference between "hidden", or "missing", so no reason to do it
2011-03-06 20:51:31 +00:00
Sam Reed
5ad9f48ef8 Fix where ipb_deleted from r83390 2011-03-06 20:38:00 +00:00
Sam Reed
c488abeeb8 * (bug 27897) list=allusers and list=users list hidden users
Refactored addition of block information, and also checked if user is allowed to view hidden user fields
2011-03-06 17:59:08 +00:00
Sam Reed
573abcbd8c Refactor out the duplication I left with a TODO in r79659 2011-02-27 21:31:47 +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
Sam Reed
25637962d5 What's a boolif? 2010-09-25 16:38:44 +00:00
Matthew Britton
bb3897976d follow up r72387: using ApiQuery here breaks ApiParamInfo (bug 25248) 2010-09-23 10:46:08 +00:00
Platonides
925c6d0c36 Make happy check-vars. This shows it that getQuery() returns an ApiQuery (more specifically, that getQuery() doesn't return an article) 2010-09-04 18:31:37 +00:00
Alexandre Emsenhuber
457eb73b61 Standardised file description headers, added @file 2010-08-07 19:59:42 +00:00
Roan Kattouw
075c8d1624 Followup to r69776: cache result of extractRequestParams() because it gets called 2 or 3 times per module per request now. Also touch up documentation here and there 2010-07-23 10:15:29 +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
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
Alexandre Emsenhuber
750a03860f Fixed some doxygen warnings 2010-03-08 21:11:32 +00:00
Alexandre Emsenhuber
00ed478a33 Fixed some doxygen warnings 2010-03-07 17:26:23 +00:00
Jack Phoenix
96b4f302af API: fix copyright symbol, coding style cleanup, more braces 2010-02-24 13:34:11 +00:00
Sam Reed
9e44e9295d Fixup spaces to tabs from r62404 2010-02-14 14:29:24 +00:00
Sam Reed
2081a0693f Rest of dieUsageMsg in getPossibleErrors 2010-02-13 00:28:27 +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
48ae7ab6ff * API: (bug 17529) rvend ignored when rvstartid is specified
* To fix this, make the prop=revisions query slightly less performance-zealous and allow WHERE rev_timestamp <= 'foo' when sorting and rangescanning by rev_id
* Make adding ORDER BY in ApiQueryBase::addWhereRange() optional
* Move a RELEASE-NOTES entry to the right section
2009-02-18 15:26:09 +00:00
Roan Kattouw
7526c937c7 API: More docs, break long lines in docs 2009-02-13 14:13:03 +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
Alexandre Emsenhuber
fc4b2f597e Fix encoding 2008-12-11 19:11:11 +00:00
Roan Kattouw
d5a1e9cf4b API: (bug 16225) apfrom=Talk:Foo behaved like apfrom=Foo because Talk: was interpreted as a namespace prefix. This caused bugs when trying to query-continue with a title like Talk:Talk:Foo. Other XXfrom and XXprefix parameters probably had this bug as well. 2008-11-03 10:13:00 +00:00
Tim Starling
c4dd73000a * Fix r41814: totally broken use of empty(), ignores conditions that compare with numeric zero. I've told you before, don't use empty() to test for zero-length arrays.
* Fix r34767: wrong indexes used in ApiQueryLogEvents
2008-10-25 08:13:40 +00:00
Roan Kattouw
798cc41a51 (bug 15881) API: Empty or invalid parameters cause database errors 2008-10-07 18:23:39 +00:00
Roan Kattouw
0f639816ce (bug 15471) Fix regression from r40088 which caused apprefix=Main_Page/ to fail because Main Page/. is not a valid title 2008-09-04 13:42:22 +00:00
Roan Kattouw
fb84c15c1e API:
* Add titlePartToKey() and keyPartToTitle() which use the substr() hack to preserve trailing spaces
* Migrate function calls where needed. ??continue parameters still use titleToKey() because they're generated using keyToTitle() and therefore can't contain trailing spaces
2008-08-27 16:48:30 +00:00
Daniel Friesen
69e49e832e ApiQueryBase::titleToKey and ApiQueryBase::keyToTitle;
Don't bother constructing a title object when the $title/$key is ''. (Why were we doing this check after creating the title object, there's no point in even creating a big object if we're just going to check the old string we already had to see if it's empty)
And as a bonus, use trim() so that user input such as ' ' does not dish out an error (There really isn't much difference between "&title=" and "&title= " if one shouldn't output an error, why should the other?).
2008-08-25 06:57:15 +00:00
Daniel Friesen
4fcb1312f2 Revert 39936 and 39935;
This 'fix' is merely a bad workaround and creates more issues rather than simply fixing.
A) Part of the Title class is being /duplicated/ meaning more bugs are going to show up when someone improves stuff inside Title and doesn't know stuff is duplicated here.
B) This change breaks cases as $wgCaptialLinks is now a per-namespace array, not a boolean.
C) This is the wrong way to 'fix' the issue, titleToKey and keyToTitle are meant to handle full titles, not prefixes, the issue is not that they break prefixes, it's that they are being misused and thus outputting something other than expected. The best way to fix this issue, would probably be to pad the title with something like '.' and then strip that single character off the db key.
D) Because whitespace is no longer being trimmed actual titles aren't being normalized properly in the other modules causing 'foobar ' to attempt to use the db key 'foobar_' which cannot exist.
2008-08-25 06:50:31 +00:00
Roan Kattouw
27cb2f9ab0 Follow-up for r39935: re-fix bug 14651 by making the first letter uppercase if needed in keyToTitle(). Code stolen from Yuri in r17039, who removed the functionality without explanation in r17096. So much for today's history lesson. 2008-08-25 05:51:46 +00:00
Roan Kattouw
511ae2aca2 API: Go back to using the good old str_replace() hacks rather than Title methods in ApiQueryBase::titleToKey() and keyToTitle(). Error handling was awkward and the Title methods over-normalize the input, causing bug 15275 (apprefix ignores spaces at the end) 2008-08-25 05:41:53 +00:00
Roan Kattouw
309e57fd4a API:
* BREAKING CHANGE: list={backlinks,embeddedin,imageusage} now return an array with keys 0, 1, 2, ... (list) rather than an array with pageIDs as keys (hash table/associative array) for consistency with other list= modules.
* Attempting to fix an error about "Invalid title ``''" (i.e. empty string as title) I encountered at Wikipedia.
2008-08-19 15:05:29 +00:00
Roan Kattouw
07db2080a5 Fix regression from r37046: tokens should not be supplied when in JSON callback mode. Also remove ApiQueryBase::getTokenFlag() which is now obsolete. 2008-07-05 11:18:50 +00:00
Roan Kattouw
d4fe7a3763 Another regression from r36678: dieUsageMsg() expects an array, not varargs. 2008-06-29 22:29:08 +00:00
Roan Kattouw
826bcef0fa Fix regression from r36678: we can't use $this->dieUsageMsg() in a static method, so let's make ApiQueryBase::keyToTitle() and titleToKey() non-static. 2008-06-29 22:26:23 +00:00
Roan Kattouw
87711e1bc7 Fix fatal errors introduced in r36678 2008-06-27 10:37:40 +00:00
Roan Kattouw
ff1354373c Use the proper Title methods in ApiQueryBase::titleToKey() and keyToTitle(). This fixes bug 14651 for much more than just apprefix. 2008-06-26 15:48:44 +00:00
Roan Kattouw
903732fd15 API: Requesting a token you aren't allowed to request no longer dies with an error but just throws a warning and doesn't give you the token. 2008-05-21 14:33:27 +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