Commit graph

116 commits

Author SHA1 Message Date
Sam Reed
a52f1eef80 * Expose list of skins in meta=siteinfo 2011-01-23 02:05:26 +00:00
Sam Reed
1f05665cf3 Styleli[zs]e the API up to date (Been a while since) 2010-12-30 17:06:09 +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
Bryan Tong Minh
b98f2a5a71 (bug 25174) Add equal sign to boolean parameters in examples, so that the examples work immediately when posted 2010-11-23 22:05:27 +00:00
Sam Reed
bc25b2b427 Tab out siprop, so they are a bit more aligned 2010-11-03 13:00:24 +00:00
Matthew Britton
1e2199b76b reimplement r73652 having actually read coding conventions this time 2010-09-24 14:40:18 +00:00
Matthew Britton
5ea75e4395 API: sinumberingroup now gives correct size of 'user' group, and omits size of implicit groups rather than showing 0. 2010-09-24 13:00:46 +00:00
Alexandre Emsenhuber
457eb73b61 Standardised file description headers, added @file 2010-08-07 19:59:42 +00:00
X!
fdf170e1b7 Followup r70587: Remove unnecessary references 2010-08-07 16:46:57 +00:00
X!
527332491f * (bug 24236) Add add, remove, add-self, remove-self tags to meta=siteinfo&siprop=usergroups 2010-08-06 19:25:34 +00:00
Sam Reed
ddc7efbedf stylize api up to date 2010-08-05 07:02:09 +00:00
Sam Reed
ace7e5b87a Resolve minor fixme from r69761 2010-07-23 15:58:32 +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
Tim Starling
42017a2f47 Use $wgContLang not $wgLang for checkTitleEncoding() and getSpecialPageAliases(), it doesn't make sense to use the user language, WebRequest and SpecialPage certainly don't. The DatabaseOracle use of checkTitleEncoding() is weird and probably broken, but at least it uses the right object now. 2010-07-22 04:00:39 +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
Derk-Jan Hartman
0fa66a5343 Use the helper function Title::newMainPage() instead of newFromTitle().
Patch by User:Umherirrender
2010-06-19 11:49:26 +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
7ced9bc569 API: fix copyright symbol, coding style cleanup, more braces 2010-02-26 13:18:56 +00:00
Sam Reed
1f9a7d791c Implement 9 modules dieUsage errors 2010-02-13 00:48:31 +00:00
Sam Reed
d2d950d256 Start of blanket coverage of dieUsageMsg in getPossibleErrors
Only basic ones done.

Couple of other modules done manually
2010-02-13 00:09:05 +00:00
Roan Kattouw
e7aeb3f91f API: Support key-params arrays in 'descriptionmsg' in meta=siteinfo&siprop=extensions 2010-01-24 12:11:18 +00:00
Roan Kattouw
72d97f8fea API: (bug 22248) Output extension URLs in meta=siteinfo&siprop=extensions 2010-01-24 10:19:16 +00:00
Roan Kattouw
a94d246f1a Revert r61414 per CR comment: wfTimestampNow() doesn't take a TS_* parameter 2010-01-24 10:05:19 +00:00
Sam Reed
b15f2c8c46 Normalise comment usage (# --> //) 2010-01-23 22:52:40 +00:00
Roan Kattouw
10bafc0edb Followup to r61412: don't use time(), we have our own function for this 2010-01-23 15:05:24 +00:00
Sam Reed
e575b22704 * (bug 22240) - API: include time in siteinfo
Patch by Matthew Britton
2010-01-23 12:37:03 +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
Tim Starling
bd8fffe24d Reverted r58646 as per my comments on bug 20554. 2009-12-01 01:55:04 +00:00
Roan Kattouw
1b89cd274a API: (bug 20554) Expose average slave lag (avglag) as well as maxlag. Patch by Sam Reed. 2009-11-06 14:38:55 +00:00
Chad Horohoe
c319cc8968 (bug 13750) $wgCapitalLinks should be a per-namespace setting 2009-10-09 12:52:16 +00:00
Bryan Tong Minh
b17adbc880 (bug 17809) Add number of users in user groups to meta=siteinfo 2009-07-12 12:10:27 +00:00
Tim Starling
23cfebd3d2 * Introduced a new system for localisation caching. The system is based around fast fetches of individual messages, minimising memory overhead and startup time in the typical case. It handles both core messages (formerly in Language.php) and extension messages (formerly in MessageCache.php). Profiling indicates a significant win for average throughput.
* The serialized message cache, which would have been redundant, has been removed. Similar performance characteristics can be achieved with $wgLocalisationCacheConf['manualRecache'] = true;
* Added a maintenance script rebuildLocalisationCache.php for offline rebuilding of the localisation cache.
* Extension i18n files can now contain any of the variables which can be set in Messages*.php. It is possible, and recommended, to use this feature instead of the hooks for special page aliases and magic words. 
* $wgExtensionAliasesFiles, LanguageGetMagic and LanguageGetSpecialPageAliases are retained for backwards compatibility. $wgMessageCache->addMessages() and related functions have been removed. wfLoadExtensionMessages() is a no-op and can continue to be called for b/c. 
* Introduced $wgCacheDirectory as a default location for the various local caches that have accumulated. Suggested $IP/cache as a good place for it in the default LocalSettings.php and created this directory with a deny-all .htaccess.
* Patched Exception.php to avoid using the message cache when an exception is thrown from within LocalisationCache, since this tends to fail horribly.
* Removed Language::getLocalisationArray(), Language::loadLocalisation(), Language::load()
* Fixed FileDependency::__sleep()
* In Cdb.php, fixed newlines in debug messages

In MessageCache::get(): 
* Replaced calls to $wgContLang capitalisation functions with plain PHP functions, reducing the typical case from 99us to 93us. Message cache keys are already documented as being restricted to ASCII.
* Implemented a more efficient way to filter out bogus language codes, reducing the "foo/en" case from 430us to 101us
* Optimised wfRunHooks() in the typical do-nothing case, from ~30us to ~3us. This reduced MessageCache::get() typical case time from 93us to 38us.
* Removed hook MessageNotInMwNs to save an extra 3us per cache hit. Reimplemented the only user (LocalisationUpdate) using the new hook LocalisationCacheRecache.
2009-06-28 07:11:43 +00:00
Roan Kattouw
b6acef6319 Remove unused global left in r51727 2009-06-11 09:05:47 +00:00
Chad Horohoe
83eab2a0ce Per code review: Use Language::getLanguageNames() instead. 2009-06-11 04:49:10 +00:00
Roan Kattouw
72c9341d1d API: (bug 18785) Add siprop=languages to meta=siteinfo 2009-06-07 18:20:01 +00:00
Roan Kattouw
bb54f6c627 API: (bug 18773) Add content flag to siprop=namespaces output 2009-06-07 18:09:57 +00:00
Roan Kattouw
fc32d63609 Fix up r50126: dump $wgDBtype rather than a class name, per CR comment 2009-05-04 07:00:52 +00:00
Roan Kattouw
2e20458e1c API: (bug 18533) Add readonly message to meta=siteinfo output 2009-05-02 14:24:11 +00:00
Roan Kattouw
06687f0d95 API: Add PHP and database version to meta=siteinfo output 2009-05-02 13:35:20 +00:00
Tim Starling
4ba01bff2f Add lots more information to the siteinfo query. Based on the JS variable list. 2009-04-30 05:25:35 +00:00
Chad Horohoe
7748725389 (bug 17795) Make meta=siteinfo respect $wgDisableCounters. 2009-03-05 13:52:14 +00:00
Roan Kattouw
88f35cdf6e API: Some cleanup
* Aggressively intval() numeric things; addresses the concerns raised on bug 11633
* Use ApiQueryBase::addTitleInfo() everywhere
* Remove a drug-induced-looking line from ApiQueryWatchlist.php
2009-02-27 16:03:01 +00:00
Roan Kattouw
8c813c3c92 Redo r47313 in a more readable way (probably more efficient too) by not using all those array_* functions 2009-02-16 12:19:29 +00:00
Roan Kattouw
37070d2e5a API: (bug 17502) meta=siteinfo&siprop=namespacealiases no longer lists namespace aliases already listed in siprop=namespaces 2009-02-16 11:20:58 +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
Roan Kattouw
2b6314c9c4 (bug 17327) Normalize API help texts: remove quotes 2009-02-02 23:17:07 +00:00
Roan Kattouw
06b5d0f9d5 API: (bug 17224) Add siprop=rightsinfo to meta=siteinfo. Modified patch by Brianna Laugher 2009-01-31 15:56:52 +00:00