Commit graph

556 commits

Author SHA1 Message Date
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
umherirrender
de7380b56e Change intval( User::getOption() ) to User::getIntOption()
Also changed some getOption with int or bool cast

Change-Id: Ia551a50e9de047c62be84065481fdf8c02e2ef96
2013-03-04 14:08:48 +00:00
jenkins-bot
08648b2b4e Merge "Use 'email' instead of 'e-mail' in API texts." 2013-03-03 00:42:48 +00:00
Brad Jorsch
f8d1bf2ad1 Add "upload" type to API
If a file upload is not formatted correctly for PHP to recognize it as a
file upload rather than a regular field, the API will wind up trying to
load the file contents as a text field. Since these file contents are
often a large binary file, this will tend to run out of memory trying to
apply Unicode normalization.

To prevent this and to allow for a helpful error message, mark
parameters that are supposed to be file uploads.

Bug: 44909
Change-Id: Ia4586953e2ad2d72d08852689e060e39e7920d50
2013-03-02 16:12:53 -05:00
Alex Monk
b672653acc Use 'email' instead of 'e-mail' in API texts.
Bug: 45633
Change-Id: Ieddc066be4051a20f0500b52e6b021e877d6c97d
2013-03-02 18:34:59 +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
umherirrender
5880f89707 API: Throw error when interwiki is given for various title param
See bug 44341 for action=parse, but the problem with interwiki
processing can also be happen in other modules.

This gives clearer error message on some modules
For example action=move:
Bad title "*title*"
instead of:
Unknown error: "immobile-target-namespace-iw"

Change-Id: I86524533dfd778a169b39968999918a1f531efeb
2013-03-01 16:01:26 +01:00
Yuri Astrakhan
86ce0ee506 Move <warnings> and <query-continue> to result's top and optimize
* Both the warnings and query-continue elements will now be shown
at the top of the result, making it easier for debugging and learning.
* Added int $flags parameter instead of bool $overwrite for addValue()
and setElement(). Supported flags are OVERRIDE - overrides existing value,
same meaning as true (which will continue to work), and ADD_ON_TOP which
ensures that if the value being added does not exist, it will be placed
as the first element in the parent array.
* Optimized ApiBase::setWarning to no longer use regex (faster)
* Optimized ApiResult::addValue() for a bit more efficiency
* Added ApiResult::addAsFirstElement() that inserts a named value into
the array at the top

Change-Id: I0fa2697e1eaa4947d01527bb3ad555e1051f6be4
2013-02-19 11:45:44 -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
Yuri Astrakhan
a97bb3acfa API module manager and help rewrite
This is a non-versioned part of the larger patch #41014
https://gerrit.wikimedia.org/r/#/c/41014
It will allow help subsystem optimization (merging paraminfo and help),
path towards per-module or per-system versioning, removal of the
manually maintained generator lists.

Changes:
* ApiModuleManager now handles all submodules (actions,props,lists) and instantiation
* ApiModuleManager maintains a cache of all instantiated modules
* Query stores prop/list/meta as submodules
* action=help suports generalized submodules (modules=query+value), querymodules obsolete

Change-Id: Ie2dee41e44a29cd5d5935eeaa5240b708d95a8f0
2013-02-05 01:52:55 -05:00
umherirrender
f97a3a4027 fix some spacing
Change-Id: I670a7baf3ba1e70d18346bb00938d518ba2063bd
2013-02-04 19:59:14 +00:00
jenkins-bot
7fbc18e1ba Merge "fix some spacing" 2013-01-27 13:14:56 +00:00
umherirrender
2e8da558ba fix some spacing
Change-Id: Id7eda67a43f9040117edd79fdbeb678f1c3a6da2
2013-01-26 22:11:09 +01:00
umherirrender
fac189e26a The abstract declaration must precede the visibility declaration
From phpcs

Change-Id: I169c80a911ba75d64ab8a503088903ce3b8a7cca
2013-01-26 20:00:09 +01:00
Yuri Astrakhan
258929f572 API debugging flag $wgDebugAPI to disable some security checks
Intentionally introduce a big security hole for debugging only.
Just like $wgShowDebug, $wgShowExceptionDetails, and $wgShowSQLErrors,
that introduce security vulnarabilities for debugging purposes,
this flag allows developers to remove some security checks in their
LocalSettings.php. This is a much safer approach than temporarily
changing production code to ignore certain conditions and later
forgetting to remove those changes before commiting the code.
Whenever enabled, a warning will allways be added to all output.

Change-Id: Ideb271dc1c9087f0843da03d024d70cc2cd776ae
2013-01-18 17:58:06 +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
jenkins-bot
d72590124e Merge "Minor cleanup" 2013-01-14 20:15:14 +00:00
Yuri Astrakhan
32fd68f81c Minor cleanup
Fixed spacing, eol chars, "string" --> 'string'

Change-Id: I630247c6c5b469efb67ec9de32e8533ae88e59fb
2013-01-12 01:50:48 -05:00
umherirrender
b65a72da0b fixed timestamp validation for api
wfTimestamp returns false on failure.

Renamed variable to output original input on failure and not the false

Change-Id: I39d31f35dae88b8a6e50ebee76a3be8722603ef3
2013-01-05 21:09:16 +01:00
Reedy
f921b41f15 Swap isSpecialPage for canExist()
Add another check in ApiBase::getTitleOrPageId

Change-Id: I2123e3a3034cb815cf35f66f2fbf2b94fb27069f
2012-10-23 23:56:35 +02:00
Tim Starling
343cbf7463 Add an API log
During incident response, it was not possible to tell what API modules
were being requested and by whom, since the action parameter is often
posted. This change logs the API parameters whether they are posted or
sent in the query string.

I did try to get the API parameters from the module, but that turns out
to be difficult. Modules create submodules (generators, page sets) as
local variables, which are created in a procedural style and destroyed
before logging is done, so there is no easy way to query them for
parameter lists after execution completes.

In ApiOptionsTest, use a real ApiMain object like all the other API test
cases, rather than a mock object. Otherwise the test fails.

Change-Id: Idc786007fe61811d1874f29b5ce4762dd97b1847
2012-09-24 21:22:09 +00:00
Siebrand Mazeland
475a1daa03 Replace some occurrences of wfMsg* by alternatives. Undeprecated wfMsgReplaceArgs.
* wfMsgReplaceArgs isn't really i18n related. It just replaces text parts.
* Updated language.txt. Now refers to mediawiki.org.
* Removed deprecated Block::formatExpiry(). Merge Id7d057a4 first.
* Reformatted weirdly formatted array in ApiBase.php.
* Removed wfMsg() in RandomTest.php.

Change-Id: Ied5cfda8fa5d9283dfeebdcb0e1af8453d47e7a9
2012-09-03 11:49:58 +02:00
Reedy
c6e2265424 Some API errors didn't include the prefix of the module in parameter related error messages
This fixes up/normalises these usages (probably want refactoring out at a later date)

Change-Id: I5583d69d9e65a1ee09d31a37c88f369e7c0f7708
2012-08-17 14:54:24 +01:00
umherirrender
e421c99e87 Allow importing pages as subpage
Adding a "root page" input to Special:Import, which is used as prefix
before each imported page. With this option, it is possible to import
pages as subpage of a user or a project page.

On de.wp the import is often done into a low used namespace (100 or 101)
and than moved to the user space. Doing this in one step, makes things
easier.

Change-Id: Id5dbf742295a1bbddd8cb6eaa09fb28051f26613
2012-08-15 10:10:46 +02:00
Aaron Schulz
d6a72e1bb4 Merge "Rename 'file-session-key' in api message map" 2012-08-04 18:10:30 +00:00
umherirrender
bb0975708e Rename 'file-session-key' in api message map
Follow up r92009

Change-Id: I4752d47e54f4b13101400bed097eccc525e8506e
2012-08-04 16:05:21 +02:00
umherirrender
c5d36b5b18 unknown error 'filerevert-badversion'
Adding 'filerevert-badversion' to message map
use some local vars in ApiFileRevert

Change-Id: I2341f3f212af484d446a7a84c1b5c7984597468d
2012-08-04 15:40:36 +02:00
umherirrender
99bc0ae1a5 Add hint for pipe-separated list to action=help
Also fix helptext for integer min/max for isMulti param

Change-Id: I84caf01ace8eefd9de4fe783a6cafac3201f2e0a
2012-07-29 10:48:52 +02:00
umherirrender
ea47fb834f Add hints to comment of ApiBase::needsToken/getTokenSalt
Change-Id: I7141256527aaff5496ac4e163199c947fb27fed0
2012-07-27 14:43:55 +02: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
a2e40f12f5 (bug 31777) Upload unknown error ``fileexists-forbidden''
adding messages to ApiBase::$messageMap and to message files for client
side localisation

Change-Id: I37e03130c6b90e4614514cd76b73eab6890eb82f
2012-07-01 19:35:31 +02:00
Alexandre Emsenhuber
58852d8827 Deprecated Title::userIsWatching(); use User::isWatched() instead.
* The problem is that Title::userIsWatching() relies on $wgUser,
  which is not suitable on every case. Instead User::isWatched()
  requires both an User and a Title object.
* Replaced all core calls from the former to the latter
* Added a cache in User for the WatchedItem instances so we do not
  need to do a database request every time something want to know
  whether a page is watched or not, which can happen several times
  per request.

Change-Id: Ifa9c55b7ffb487ce6893c74df233eedc7654dc5e
2012-06-29 23:22:35 +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
Alexandre Emsenhuber
18cc220038 Don't make two database requests to load the same object, again.
I know there's no second parameter to WikiPage::newFromID(), but this will change soon.

This follows-up I098dd36619fff3610be6894037220d3472b809d5.

Change-Id: Ic28b7e05db51e55a5f49fed70c042ba11e4d97fe
2012-05-04 22:10:36 +02:00
umherirrender
e0ded894d9 (bug 30488) API now allows listing of backlinks/embeddedin/imageusage
per pageid

Move the possibles errors set by ApiBase::getTitleOrPageId to
ApiBase::getTitleOrPageIdErrorMessages and remove it from used modules

Change-Id: If037e04665d2524c1f2476bc7996d9573753a4b8
2012-05-02 01:35:04 +01:00
Reedy
b9e6daa3aa Simplify and refactor out api code for getting title or page id
Change-Id: I098dd36619fff3610be6894037220d3472b809d5
2012-04-27 15:58:04 +01:00
Alex Monk
de9354fd3a (bug 30410) Remove deprecated $wgFilterCallback. The 'filtered' API error was also removed, along with EditPage::AS_FILTERING.
Change-Id: Ic0b7b2f22ab61c9d760d280e5ab4e24af1160b7a
2012-04-24 22:08:41 +01:00
Reedy
2bfd84eb8c Duplicate array keys aren't going to do very much...
Change-Id: I3421f70332f9514e71d4c1f0751be567108c1099
2012-04-05 19:35:09 +01:00
umherirrender
1788cc76c5 (bug 31883) Limit of some params is not documented in API autodoc
Original bug description: Limit of bkusers of list=blocks and titles of
action=query is not documented in API help

For that params no PARAM_TYPE was set, determine the type with the same
code as in r85758 (action=paraminfo) and its modification in r86917

Move the adding of that text out of the else, than the doc is also
added to params with more than 50 default values
(which looks to be intend of that piece of code).

Change-Id: I3fa59d2a7ae688da79dab57dc0576a69f786cca5
2012-04-03 14:58:44 +02:00
Liangent
fc072f2dfc Was causing Notice: Array to string conversion in .../includes/api/ApiBase.php on line 285 and examples of list=allimages are not displayed properly
Change-Id: I4fde14245ac19716957beb634a274c3a6042d776
2012-03-26 21:36:24 +08:00
Ryan Kaldari
71bdf4a745 better error message and comment 2012-03-08 00:34:42 +00:00
Roan Kattouw
14b9e780c2 It seems that parseMsg() sometimes receives strings, probably from bad dieUsageMsg() callers or badly formatter error arrays. I don't want to have to track this down, so I'm making it fail gracefully and just cast any strings to arrays 2012-03-07 02:09:22 +00:00
Niklas Laxström
53317d179b Added @since annotations 2012-02-26 14:16:53 +00:00
Sam Reed
1374c143a6 Improve documentation 2012-02-24 18:38:04 +00:00
Sam Reed
b834075972 * (bug 32341) Add upload by URL domain limitation.
Essentially reverts r109741  live again

Which was r109562, r109564, r109570
2012-02-09 23:22:38 +00:00
Sam Reed
138ddc452f 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 17:42:35 +00:00
Sam Reed
b7d68a8716 Documentation and whitespace 2012-02-09 01:06:57 +00:00
Sam Reed
af198296ef Revert feature out of r109562, r109564, r109570
Leaving typo/brace fixes and other minor code improvements
2012-01-22 17:33:44 +00:00
Sam Reed
f619564720 * (bug 32341) Add upload by URL domain limitation. 2012-01-19 19:16:06 +00:00
Sam Reed
81ef87f61a * (bug 33733) API: Unknown error: mustbeloggedin
Add message to messagemap
2012-01-14 23:45:21 +00:00
Niklas Laxström
8522618068 Ping r108847, missed one half quote 2012-01-13 21:19:44 +00:00
Siebrand Mazeland
1033737a05 Change usage of quotes in API messages from ``x'' to "x". 2012-01-13 21:11:27 +00:00
John Du Hart
f423134ac7 Missing check for ISMULTI on help parameters, thanks santhosh 2012-01-03 11:05:55 +00:00
John Du Hart
ef616c24b0 Bug 33482 - Api incorrectly calls ApiBase::parseMultiValue if allowed values is given as an array
Simply means that if you have an array of acceptable values and you only accept one at a time, you can have pipes in the allowed values.
2012-01-03 11:02:26 +00:00
Sam Reed
4024f986bd Followup r107393, treat '' the same as getting false from getExamples, the default if it's not overridden 2011-12-31 00:22:37 +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
Brion Vibber
adf5768359 Revert r106870: doesn't seem like it would format things consistently as expected. 2011-12-20 22:05:40 +00:00
Sam Reed
b956a8eb19 For r106521/r106865, wrap long example description strings
Follows up r106439
2011-12-20 21:37:51 +00:00
Sam Reed
6c80c5ff87 Prep work for * (bug 33147) API examples should explain what they do
Now formatted in the autogenerated documentation

Format for paraminfo adds a description attribute to output


query allimages descriptions are tranformed, need to do/add to other ones
2011-12-16 15:28:35 +00:00
Jeroen De Dauw
49cdca93be add missing deprecation notices and added deprecation version to existing ones 2011-12-13 05:19:05 +00:00
Sam Reed
7ea2f68c3a Followup r105823, make it protected 2011-12-11 20:41:23 +00:00
Sam Reed
b8d83ec568 Adding a getDB function to ApiBase...
Not all subclasses will need/want it. It does however make it easier to pretend non ApiQuery derivatives actually are...
2011-12-11 20:32:37 +00:00
Sam Reed
7f3f1f7caf Followup r104441
Fix capitalisation mismatch
2011-11-28 19:17:06 +00:00
Sam Reed
53000baecf Oh noes, moar http:// -> https:// 2011-11-28 15:43:11 +00:00
Sam Reed
f3839fe71f Added "ApiGetDescription" hook 2011-11-28 15:33:28 +00:00
Roan Kattouw
792c38f424 (bug 26854) Invalid user names go unchecked. Applied most of the patch submitted by Søren Løvborg, checking for null return values from User::newFromName() 2011-11-20 10:55:58 +00:00
Alexandre Emsenhuber
2c4d6b6992 Follow-up r103332: fix "invalidoldimage" error message to say "oldimage" instead of "oldid" 2011-11-19 08:29:49 +00:00
Alexandre Emsenhuber
2bb8c2ea4d * Use WikiPage instead of Article
* Create the WikiPage object directly in execute() and pass it to both delete() and deleteFile()
* Reordered parameters of delete() and deleteFile() to be consistent and take both on the WikiPage and User objects (instead of relying on $wgUser); no callers outside of this class
* Fixed deleteFile() to match the behaviour of FileDeleteForm with oldimage parameter
* Pass the User object to getPermissionsError()
* Factorised duplicated code
* Added missing error code to ApiBase (and also a new one)
* Added missing possible error codes (with a new one too)
2011-11-16 15:57:56 +00:00
Roan Kattouw
71461de9de Followup r99224: add message to ApiBase::$messageMap too 2011-11-14 14:40:55 +00:00
Alexandre Emsenhuber
681523d5ad Fix for r100905:
* Make tests work again
* Added ApiTestCase::doApiRequest() and related to pass it to the context and removed override of $wgUser where possible
* Fix ApiLogin to get the correct User object (i.e. the logged in one)
* Fix ApiBase to feed a RequestContext to setContext() so that ApiLogin can call setUser()
2011-10-27 18:46:40 +00:00
Sam Reed
fa65fa3243 Documentation
Deprecated code updates
2011-10-27 00:46:17 +00:00
John Du Hart
24427ca1d8 Followup 100905, fixing usages of getContext() 2011-10-26 23:34:31 +00:00
John Du Hart
40f19e6def Adding context to the API
This will probably break something somewhere so when it does please yell at me on IRC and I'll fix it.
2011-10-26 23:27:01 +00:00
Sam Reed
469cc76775 Return documentation 2011-09-21 16:36:43 +00:00
Jeroen De Dauw
328765afbc doc fix 2011-09-06 20:31:51 +00:00
Roan Kattouw
5090af900c (bug 29246) Edit API occasionally throws "unknown error 231". Per comment #1 on the bug and a comment in ApiEditPage, I refactored internalAttemptSave() to return a status object. However, there are so many idiosyncracies wrt how EditPage handles various errors that I decided to put the AS_* error code in $status->value (thanks Chad for that tip) and use that to decide what to do (not part of Chad's tip). The resulting code is still a mess but at least Status objects from doEdit() are propagated now, and it'll be a little bit easier to migrate internalAttemptSave() to a proper Status-based architecture in the future. Or maybe we should just throw away EditPage and start with a blank screen, that sounds appealing to me :) 2011-08-26 16:26:17 +00:00
Sam Reed
ac0ff8fb37 Followup r92396 rename method, fix boolean comparison that was supposed to be inverted when de-indenting 2011-07-17 16:23:29 +00:00
Sam Reed
d18c0dc315 * (bug 28817) Add reference help page link to API Modules
Start of this bug, fleshed out base code implemented, plus a few key modules (will finish rest up soon)

Tweaked/improved/updated some documentation as I went through also
2011-07-17 16:18:09 +00:00
Alexandre Emsenhuber
ffd52683c8 Create a new RequestContext to use its OutputPage and Skin members instead of messing with global ones 2011-07-08 16:18:31 +00:00
Sam Reed
8edf4a2d92 Fix trailing whitespace
Swap methods that call $this->getResult() to use temporary variable
2011-06-29 23:46:39 +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
67df4ef4c0 * (bug 27716) Make a method to do checking of 0 or 1 of the parameters existence (like requireOnlyOneParameter), but without needing one of the parameters 2011-06-06 16:45:40 +00:00
Krinkle
2d03eedf8a WatchAction requires token (BREAKING CHANGE)
* (bug 27655) Require token for watching/unwatching pages
* Previously done for API (bug 29070) in r88522
* As with markpatrolled, the tokens are not compatible and made that way on purpose. The API requires the POST method and uses a universal token per-session. Since the front-end is all GET based (also per convention like in markpatrolled and rollback) they are stronger salted (title / action specific)
* ajax.watch used the API already and was switched in r88554.
* The actual watching/unwatching code was moved from WatchAction->onView to WatchAction::doWatch. This was done to allow the API to do the action without needing to generate a token like the front-end needs (or having to duplicate code). It is now similar to RecentChange::markPatrolled (in that it  also a "central" function that does not care about tokens, it's called after the token-handling)
* JavaScript / Gadgets that utilize action=watch in their scripts:
** Effects should be minimal as they should be using the API (see r88522 and wikitech-l)
** If they use index.php and scrap the link from the page, they can continue to do so.

* There are links to the watch action all over the place. I've tried to catch most of them, but there may be some I miss. Migration in most cases is just a matter of adding an array item to the $query for:
 'token' => WatchAction::getWatchToken( $title, $user [, $action] )
or changing:
 Action::factory( 'watch', $article )->execute();
to:
 WatchAction::doWatch( $title, $user );

While replacing the usages in some cases an instance of Article() no longer had to be created, in others $wgUser had to be retrieved from global (which was implied before but needs to be given directly now)

Other notes:
* Article->unwatch() and Article->watch(), which were deprecated as of 1.18 and are no longer used in core, may be broken in scenarios where the Request does not have a 'token' but is making a call to $article->watch()
* Some extensions need to be fixed, I'm currently running a grep search and will fix them a.s.a.p 


[1] http://www.mediawiki.org/wiki/ResourceLoader/Default_modules?mw.user#tokens
2011-06-06 00:09:03 +00:00
Sam Reed
587f480923 * (bug 28392) mark action=undelete&timestamps as type "timestamp"
Allow multiple timestamps
2011-06-05 23:18:22 +00:00
Sam Reed
58ccb663e1 Followup r89515, fix double spacing in API Error message
Add both customcssprotected and customjsprotected to the possible errors output for editpage
2011-06-05 18:34:26 +00:00
Sam Reed
5749cfa480 * (bug 21107) Split error "customcssjsprotected" into separate messages for JS and CSS 2011-06-05 18:29:43 +00:00
Sam Reed
2b676156ba And even more documentation 2011-05-28 18:58:51 +00:00
Sam Reed
e22c5cb3e7 While looking at bug 26990 on TW api, it was noticed with a load of NS's they don't word wrap
So make them wordwrap like the rest of the text
2011-05-20 17:38:05 +00:00
Antoine Musso
391284b75c ApiBase::dieUsageMsg() now also accept being given a single element as a string.
So the old: 
  $api->dieUsageMsg( array( 'nologging' ) );

Can now be written:
  $api->dieUsageMsg( 'nologging' );

Saves up a few keystrokes.
2011-05-14 11:19:59 +00:00
Sam Reed
3441def388 Documentation
Remove long deprecated isBot()/isSysop() in ApiMain
2011-05-08 16:48:30 +00:00
Happy-melon
3f4e0e2e74 (bug 28797) Fix ApiBase::parseMsg() to properly handle nested error arrays. 2011-05-07 13:05:22 +00:00
Sam Reed
f985524076 More versions added to @deprecated tags
Couple of inbound calls fixed up

Some ancient code removed as it's been marked deprecated
2011-05-06 21:50:18 +00:00
Jeroen De Dauw
f266b1ca15 small doc fix 2011-04-29 22:05:36 +00:00
Jeroen De Dauw
22cd74d272 fix return type descriptions 2011-04-29 15:41:57 +00:00
Jeroen De Dauw
f8dc68bd98 fix typo 2011-04-29 15:37:01 +00:00
Sam Reed
40f33eb663 Add some more spacing due to long parameter names
Use str_repeat for ease rather than "     " etc

Fix MiserMode to MiserMode
2011-04-23 13:29:11 +00:00
Alexandre Emsenhuber
21e53d3590 * Added Profiler::isStub() to check if we are using a stub profiler, instead of checking whether $wgProfiler is set
* Replaced wfProfileClose() and wfGetProfilingOutput() by direct calls to the Profiler instance and removed them, no uses in extensions
* Also removed useless params from Profiler::getOutput() call in wfLogProfilingData()
* Only generate profiling output if it'll be used; introduced Profiler::logData() that saves profiling data (database, udp, ...) to separate it from output generation
* Removed unused Profiler::getCaller(), not used at all, and we have wfGetCaller() that does the same thing
2011-04-21 16:31:02 +00:00
Happy-melon
8779f4b55f r86001, now with less scariness :P I took out the delete action and did purge instead, which is a much more self-contained action-with-a-form. Also implement a few changes suggested by Brion on IRC last night. 2011-04-14 10:38:29 +00:00
Happy-melon
bc4a096805 Revert r86001: Brion says it's too scary :D will recommit in pieces 2011-04-13 23:36:27 +00:00
Happy-melon
6dc8136d12 New infrastructure for actions, as discussed on wikitech-l. Fairly huge commit.
* Actions come in two flavours: the show-a-form-then-do-something-with-the-result (delete, protect, edit, etc) and the just-do-something (watch, rollback, patrol, etc).  Create abstract base classes Action and FormlessAction to support these two cases.  HTMLForm is an integral part of the form-based structure.
* Look mum, no globals!  :D  Fully context-based.
* Implement watch/unwatch, credits and delete actions in the new system as proof-of-concept.  This also gives the delete frontend a much-needed overhaul.
* Stub out the newly-deprecated functions from Article.php.  This already reduces its linecount by about 15%, and there are plenty more actions still to do.
* Centralising actions like this is going to render a lot of hooks type-incompatible.  There's simply nowhere you can put the ArticleConfirmDelete hook, for instance, where it can be passed an OutputPage as the second parameter.  On the other hand, we can implement new hooks like ActionModifyFormFields and ActionBeforeFormDisplay, which can do much prettier stuff to the forms, like adding extra fields the 'right' way.  Update LiquidThreads to use these new hooks where appropriate.
2011-04-13 23:04:07 +00:00
Bryan Tong Minh
8bd336981c API upload errors may now return the parameter that needs to be changed and a sessionkey to fix the error. This is for now only done for uploads that can be fixed by changing the filename, but may be extended later to comment and pagetext. 2011-03-25 21:22:02 +00:00
Sam Reed
01caf960f2 Followup r82060
Calling intval() on an array of integers isn't going to get people very far

simplify logic, and then only do validation if $min or $max are not null
2011-03-03 23:22:39 +00:00
Sam Reed
27ca6b2fa8 Tweak comments, remove some unused stuff.
Explicit definitions, move a few minor bits around
2011-02-27 21:10:11 +00:00
Sam Reed
41e7860130 Implement getRequireOnlyOneParameterErrorMessages, to make the error messages requireOnlyOneParameter can throw.
Use in 4 modules for more dynamicness
2011-02-25 19:09:39 +00:00
Sam Reed
28f7bf1f2b Followup r82727, improve comments, cast return value to bool 2011-02-24 16:00:06 +00:00
Sam Reed
ab408b911d Seems the api edit watch/unwatch wasn't too well tested (after it got poked a lot)
EditPage::commitWatch() unconditionally  does a watch/unwatch...

And multiple watches of a watched page end up with an INSERT IGNORE, so not a big deal
2011-02-24 15:51:51 +00:00
Sam Reed
3721e827ac * (bug 27376) when using ApiBase::PARAM_TYPE => 'integer' without a min or max value, api doesn't validate the input is actually an integer
Fixup some space indention
2011-02-13 17:00:47 +00:00
Sam Reed
bfd67cf818 Remove some blank lines
Spaces to tabs in ApiBase
2011-01-07 02:53:00 +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
Roan Kattouw
ea310d143f Followup r78824: add missing message 2010-12-29 20:20:55 +00:00
Sam Reed
f63b5040e3 More minor bits of documentation
Object type hint on mPrinter
2010-12-23 19:53:28 +00:00
Sam Reed
55ebd95afd * (bug 24287) Wrap/similar on api help output 2010-12-22 21:40:33 +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
492ac9b4bf Followup r77666, bug 26219
Only add the message about multi value, if the type is not an array, or if it is an array, if it has over 50 (LIMIT_SML1) items
2010-12-04 00:36:33 +00:00
Sam Reed
612c934210 * (bug 26219) Show API limits for multi values in description
Also move bug 9675/r77612 RELEASE-NOTES to the correct section
2010-12-03 16:24:05 +00:00
Sam Reed
056b646308 Followup r74988, brion wins again ;D 2010-10-19 18:40:43 +00:00
Sam Reed
c85bf31cf3 Swap usage of create_function for defined function as a callback 2010-10-19 00:44:28 +00:00
Roan Kattouw
9c0b26028f Revert r74810 (vary API help cache on $wgUser->isAnon()) and move the POST check into the purge module. Also fix the permissions check in action=purge, which was totally broken and based on a misunderstanding of what the 'purge' right means. 2010-10-18 09:19:20 +00:00
Sam Reed
519173c0e4 Followup r74234 flip parameters 2010-10-04 21:18:38 +00:00
Sam Reed
9cda0105a9 Minor tweaks to r74232, add a value for $botMax on calls for integer validation (otherwise the bool gets pushed into it!)
Documentation in ApiDelete
2010-10-03 20:29:44 +00:00
Sam Reed
69107791db Followup r74230, if we make things array, we should make them not an array afterwards
Well, the more sane way, is just treat them seperately, than having to do $value = $value[0];, based on whether it was an array already

Cheers to Siebrand (was already poking it myself :))
2010-10-03 20:07:23 +00:00
Sam Reed
7ad52b7bdd First part of "*(bug 25303) API: integer parameter validation does not actually validate, only warn"
Actually make the validation of the range occur

Fix typo in ApiBase.php
2010-10-03 19:07:11 +00:00
Sam Reed
42b5c265c0 * (bug 25248) API: paraminfo errors with certain modules
Added a needsToken() function, rather than calling getTokenSalt, which can throw silly errors due to dependencies on parameters
2010-10-01 20:12:50 +00:00
Sam Reed
9d1e45bf42 Tweak/add some documentation as hints for some code analysis 2010-09-28 01:33:11 +00:00
Sam Reed
6c1273bc7d Fill in missing params from a dieUsage
Braces

Fixup parameter documentation
2010-09-25 16:45:41 +00:00
Sam Reed
f07567201f Remove some unused variables
Tweak php doc, "One" is not a type, so insert string in there
2010-09-25 16:37:39 +00:00
Sam Reed
ee04d754ed Only display Examples section if it's got anything in the array 2010-09-03 22:58:09 +00:00
Sam Reed
fc38716f49 ApiBase.php:
"Don't show No more than 500 ( for bots) allowed" when MAX2 isn't set

Trim trailing whitespace from Database.php
2010-08-31 21:06:01 +00:00
Sam Reed
5d383466e1 Minor followup to r70480
Only throw missingparam for string === '' when it is required

RELEASE-NOTES for breaking change
2010-08-19 14:54:09 +00:00
Platonides
50e2405a03 Refactor to avoid defining globals inside switches. 2010-08-12 14:25:07 +00:00
Alexandre Emsenhuber
457eb73b61 Standardised file description headers, added @file 2010-08-07 19:59:42 +00:00
Sam Reed
7128c455cc Followup r69091 Where did those spaces come from? :/ 2010-08-05 07:08:06 +00:00
Sam Reed
ddc7efbedf stylize api up to date 2010-08-05 07:02:09 +00:00
Sam Reed
c85b04919e Revert r70489 2010-08-05 06:58:11 +00:00
Sam Reed
0345d5e08f Move if ( is_array( $value ) && !$dupes ) { up to else block after the first !is_array. If it's not not an array, it's an array, and therefore, we can just filter dupes if requested 2010-08-05 06:08:23 +00:00
Sam Reed
c95f4a05ad Followup r70480, per Nikerabbits comment, there '''is''' something to do 2010-08-05 06:02:57 +00:00
Sam Reed
0ccf248381 -rakkaus/#mediawiki-i18n- [04-Aug-2010 22:02:04] PHP Notice: Undefined variable: required in /www/w/includes/api/ApiBase.php on line 749 2010-08-04 22:02:57 +00:00
Sam Reed
edf926dfe2 Followup r70479
If string is required, but it's value === '', that's missing!
2010-08-04 21:21:35 +00:00
Sam Reed
b70c52dd8e Further followup to r70460/r70461 and r70477
Move code into getParameterFromSettings, most of the flesh is there anyway (it checks isset( $value ) ), so we can use the else to check if it's required

A followup could be to whinge if '' is returned for a string
2010-08-04 21:19:53 +00:00
Sam Reed
dd889d04c4 Followup r70460/r70461
use self consistently

Fold in duplicate loop

missingparam can be done during attempt to set ParamCache, we might aswell give up and not finish populating the param cache if we're gonna die from a missing param
2010-08-04 20:27:56 +00:00
Sam Reed
f77fff0ffb Followup r70461 if PARAM_REQUIRED is set, use for missing param in getPossibleErrors in ApiBase
All but ApiQueryBacklinks
2010-08-04 19:20:15 +00:00
X!
8b466d3d0d Followup to r70460: Committed wrong version of ApiBase.php, convert all core API modules to PARAM_REQUIRED syntax 2010-08-04 14:15:33 +00:00
X!
20d042a99e * PARAM_REQUIRED parameter flag added. If this flag is set, and the end user does not set
the parameter, the API will automatically throw an error.
2010-08-04 13:35:08 +00:00
Bryan Tong Minh
0e61296f98 (bug 24564) Fix fatal errors when using list=deletedrevs, prop=revisions or one of the backlinks generators with limit=max. 2010-07-28 11:30:14 +00:00
Tim Starling
6afbc6762c Reintroduced the extractRequestParams() memoization as in r69782, but respecting $parseLimit. Fixes bug 24564 (fatal error due to duplicate calls to addValue()). 2010-07-28 04:12:36 +00:00
Tim Starling
287c9ea4f5 Partial revert of r69782: reverted the cache feature, it does not correctly respect $parseLimit. 2010-07-26 06:20:29 +00:00
Platonides
5833c105d0 Move getValidNamespaces() to Namespace.php 2010-07-25 22:29:05 +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
Sam Reed
8f1d2cb199 Big blitz on unused variables (a lot of $db = $this->getDb() ) 2010-07-22 22:13:21 +00:00
Sam Reed
fd2744694a Add braces 2010-07-22 06:44:23 +00:00
Roan Kattouw
70824ccccc API: Make output containing private or user-specific data uncacheable for logged-in users by setting Vary: Cookie or Cache-Control: private, whichever is appropriate. Fixes instances in core and WMF-deployed extensions only. Without this change, the output of requests like ?action=query&list=recentchanges&rcprop=patrolled&smaxage=3600 would be cached in Squid and viewable for anyone using the same URL, even if they don't have patrol rights. Other, more serious exploits are also possible. Also avoid using $wgUser in one place, kill some unused global $wgUser; instances and tweak a comment. 2010-07-14 19:00:54 +00:00
Sam Reed
f5c639fd10 Stylize API
Add a few braces
2010-07-06 13:15:59 +00:00
Sam Reed
3fe7b6912b * (bug 24136) unknownerror when adding new section without summary, but forceditsummary
Handle AS_SUMMARY_NEEDED in ApiEditPage

Fixup some braces
2010-06-27 19:22:46 +00:00
Sam Reed
928ff2b273 Resolve fixme of r66539
Move getWatchlistUser to ApiBase
2010-06-22 12:10:26 +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
Roan Kattouw
fe66ef26cd (bug 24016) API: Handle parameters specified in simple string syntax ( 'paramname' => 'defaultval' ) correctly when outputting help. Patch by Brad Jorsch. 2010-06-18 09:30:38 +00:00
Sam Reed
6b5a27c0e8 Followup to r66232 do same for limit text, and module rights 2010-05-11 22:34:41 +00:00
Sam Reed
0769301e87 Stylize Api upto date 2010-04-17 20:58:04 +00:00
Mark A. Hershberger
9c7a7e57f0 * New UploadFromUrlJob class to handle Upload-by-Copy
* Define variable for ApiUserrights.php that wasn't defined before.
* Add convertVerifyErrorToStatus and getVerificationErrorCode to
  UploadBase to translate error consts since UploadFromUrl will
  need a message to display to end-users.
* refactor mime-checking out of UploadBase::verifyFile into
  UploadBase::verifyMimeType
* Make UploadBase::verifyFile always return arrays for errors
* Use HttpFunctions instead of custom curl handler for async downloading
* TODO: Need a way to feed errors back to the requestor
* TODO: Need to add watchlist param handling and warnings checks.
2010-04-17 02:43:13 +00:00
Bryan Tong Minh
6c6c2f698c Followup to r64962: Fixed watchlist parameter in API. User options watchdeletions and watchmoves can now by overridden. Unwatching while editting is now possible. 2010-04-14 12:17:39 +00:00
Mark A. Hershberger
e90d1ecd97 * EOL ws clean on ApiBase.php
* Use an actual value for ApiUpload.php
* Commit some code I must've missed for r64852
2010-04-14 04:57:27 +00:00
Sam Reed
d840fbbc95 Revert r64955
Again partial fix to bug 23167

Bugfix watch on creation (edit and upload), in current form, setting unwatch, or nochange would follow watchcreation, which wasn't requested
2010-04-12 10:44:45 +00:00
Alexandre Emsenhuber
15dd2a1c40 Fix param names mismatch in code/doc from r64852 and r64397 2010-04-11 19:10:15 +00:00
Mark A. Hershberger
6c267f1434 * Clean up some duplicated code in r64291
Would've like to refactor the $wgUser->*Watch — but I'm not sure if the hooks that come along with $articleObj->*Watch are ok.
2010-04-10 06:11:02 +00:00
Sam Reed
2a557115f0 Fixup to r64197 per http://www.mediawiki.org/wiki/Special:Code/MediaWiki/64197#c6451
Pass $fromTitle rather than $titleObj (which is undefined)
2010-04-07 08:56:43 +00:00
Mark A. Hershberger
c1e369912f followup r64465 — make happy-melon happy 2010-04-01 11:25:56 +00:00
Mark A. Hershberger
c1afe8e84e follow up r64454 — change comment style 2010-04-01 00:35:14 +00:00
Mark A. Hershberger
9c26ed06af Get rid of E_STRICT message 2010-03-31 19:50:46 +00:00
Mark A. Hershberger
234f54a88e * Set $titleObj to null by default on getWatchlistValue since it often isn't needed & check that it is set when it is needed. (follow up r64197).
* Refactoring ApiUpload & UploadBase to make it easier to extend & read.
* Use a class constant for the upload session key instead of a hard-coded-across-several-files value.
* Add UploadBase::appendToUploadFile() method to enable protocols that do incremental upload.
2010-03-30 19:10:10 +00:00
Sam Reed
ba575d7a9e Switch if ordering as per Roans comment for r64291 2010-03-28 19:23:17 +00:00
Sam Reed
789cc18185 Followup r64197
Return null in getWatchlistValue if no change

Fixup unneccessary watch/unwatch calls

Remove useless unwatch from ApiUpload
2010-03-28 15:08:45 +00:00
Roan Kattouw
7ef2b44907 Fix coding style, whitespace in r64267 2010-03-27 21:34:07 +00:00
Sam Reed
346554a2f3 Followup to r64197
Remove the mutually exclusive else checks

Fix undefined on getWatchlistValue in ApiBase
2010-03-27 17:51:56 +00:00
Happy-melon
d6fe6de7a8 Followup to r64228 - apply restrictions in API. 2010-03-26 23:02:10 +00:00
Sam Reed
88df448d36 Fix bug 22944 in a much better fashion (using watchlist parameter)
Deprecate old watch/unwatch parameters

Move generic watchlist stuff to ApiBase/getWatchlistValue (maybe needs renaming better?)

Tweak some braces in ApiEditPage
2010-03-25 22:15:08 +00:00
Bryan Tong Minh
dd349d7b3a Merge r63621 and r63636 from REL1_16:
* Rollback chunked uploading support for 1.16
* 	Pass $sessionKey as parameter to UploadFromStash::initialize.
2010-03-12 18:26:12 +00:00
Roan Kattouw
d0045bcd78 API: Don't unstub $wgContLang in ApiBase::getValidNamespaces() 2010-02-26 18:24:58 +00:00
X!
0543d7bdce Whoops, committed wrong version 2010-02-24 17:06:19 +00:00
X!
fe72f84205 PARAM_TYPE 'user' now works for multi-values 2010-02-24 17:04:21 +00:00
Mark A. Hershberger
c871b75a3e follow up r62231, r61779, r62175
* Fix up messages
* For new FileRepo::append(), use flags to determine whether to delete or not
* Add more error checking for appending
* Fix a couple of places in Revision.php and LogPage.php where DB errors were produced when comment was null
* Remove bogus checking for !$comment, etc on the DONE phase of chunked uploading
* Don't pretend to return a value when raising an exception
* Add more tests for chunked uploads
* Verify that Status::getErrorsArray() (at least where it is used in ApiUpload::execute()) returns an array that we can pass to dieUsageMessage()
* Ensure that checkWarnings(), etc work only on the complete file
2010-02-22 02:15:30 +00:00
Jack Phoenix
4228459b24 ApiBase.php: coding style cleanup, added more braces, trimmed trailing spaces, changed copyright symbol to the proper one 2010-02-20 19:39:51 +00:00
Sam Reed
878c7da630 Followup to r62557 as per Roans comment 2010-02-16 21:59:16 +00:00
Sam Reed
eb9aa1686c Followup to r62557
Add array( 'sessionfailure' ) to getPossibleErrors for token using modules (missed adding when removing from individual modules!)
2010-02-16 01:27:19 +00:00
Sam Reed
0e8b0b41ac Refactor requiresToken to getTokenSalt - Returns salt if exists, null if no salt, else false if no token required
Move sessionfailure (token validation checking) up a couple of levels

Part of bug 21991

Followup to r62482 and r62504
2010-02-15 23:53:43 +00:00
Roan Kattouw
3a953c8e30 API performance fixes: avoid unstubbing $wgContLang and $wgUser 2010-02-15 20:50:21 +00:00
Mark A. Hershberger
26a4587d80 follow up r62353 Make ApiBase::requireOnlyOneParameter() accept parameters that are set, but false. This means that you can pass in more than one parameter, as long as it is the same as the default (false). Have to do it this way since we'd like to default boolean parameters to false in getAllowedParams() but by the time requireOnlyOneParameter() is called, the defaults are set, so we can't tell the difference between passing in a parameter set to the default and just getting the defaults. 2010-02-15 07:06:49 +00:00
Sam Reed
80f9448690 Start of "Bug 21991 - Move common query parameter (uc, rc) validation, token requiringness/checking to ApiBase/Similar"
Move token requringness check to the ApiMain

Adding an exception if we're using "gettoken" (block/unblock)

Remove array( 'missingparam', 'token' ), from the getPossibleErrors of modules that set requireToken method to true
2010-02-14 22:20:27 +00:00
Sam Reed
fcdb5b846c Move ( 'code' => 'show', 'info' => 'Incorrect parameter - mutually exclusive values may not be supplied' ) to messageMap 2010-02-14 15:16:09 +00:00
Mark A. Hershberger
8b36a2b969 various eol whitespace now instead of when someone needs to do CR 2010-02-12 06:44:16 +00:00
Sam Reed
bd7da13869 Simplification as per Bryan on r62339 comment 2010-02-11 23:09:38 +00:00
Sam Reed
c1af4821bf Cater for some more errors in ApiBase.php 2010-02-11 22:28:30 +00:00
Sam Reed
20206755ee $this->mModuleName to $this->getModuleName() 2010-02-11 22:18:16 +00:00
Sam Reed
8eb8e2e0d4 Update code documentation with Bryans help for r62282 and r62331 2010-02-11 22:06:45 +00:00
Sam Reed
72df21ef49 Followup to bryans comment for r62328
Rename possibleErrors to getPossibleErrors
2010-02-11 21:53:57 +00:00
Sam Reed
fe722d85a5 Move mustBePosted error into messageMap
Switch call to dieUsage to dieUsageMsg
2010-02-11 21:51:15 +00:00
Sam Reed
aa973b9eb7 More of bug 18771 - List possible errors in action=paraminfo
Followup to comments of r62282
2010-02-11 21:34:35 +00:00
Sam Reed
ee60482546 Start implementation of bug 18771 - List possible errors in action=paraminfo
Base has empty array() returning method, ApiBlock has implementation of possibleErrors from code above (possibly not complete)

Can be finished incrementally, so serves as a review point for Roan
2010-02-11 01:13:45 +00:00
Mark A. Hershberger
15fec3ab7f * Fix up ApiTest a bit, cookie handling works
* Start upload chunks testing
* found some problems with messages
2010-02-09 08:37:38 +00:00
Sam Reed
b15f2c8c46 Normalise comment usage (# --> //) 2010-01-23 22:52:40 +00:00
Sam Reed
47c24175d3 Add/remove whitelines to increase readability in API code files 2010-01-23 22:26:40 +00:00
Roan Kattouw
51107443dc API: Fix bug where deprecated boolean parameters would always trigger the deprecated warning. 2010-01-23 17:48:02 +00:00
Mark A. Hershberger
b15cccb688 ws only cleanup 2010-01-22 03:14:52 +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
Raimond Spekking
a0d01f9cae Follow-up r58237: fixing PHP Notice: Undefined variable: deprecated in /var/www/w/includes/api/ApiBase.php on line 633 2009-10-28 05:20:17 +00:00
Chad Horohoe
c660ee428f (bug 21106) tag deprecated parameter in action=paraminfo. Add new PARAM_DEPRECATED const for automagically tagging deprecated parameters. Keeps action=help and action=paraminfo up to date 2009-10-28 00:56:07 +00:00
Alex Z
216e60d01e (bug 18019) Warn users when moving a file to a name in use on a shared repo.
Allow only users with the 'reupload-shared' right to complete the move.
2009-10-24 04:36:11 +00:00
Siebrand Mazeland
f854edfe87 New permission 'sendemail' added. Default right for all registered users. Can for example be used to prevent new accounts from sending spam.
* hide some user settings if user is not allowed to send e-mail, but can receive e-mail
* update API 'cannot send e-mail' message
* FIXME: gives 'mailnologin'/'mailnologintext' as error. Error handling should be made more fine grained
2009-09-26 23:11:45 +00:00
Roan Kattouw
e3ab8ed99a API: BREAKING CHANGE: (bug 20426) Instead of throwing an error when a limit is set too high/low, throw a warning and continue with the limit set to the maximum/minimum 2009-08-28 16:37:48 +00:00
Bryan Tong Minh
05a916153f * Cleanup ApiUpload
* UploadBase::verifyUpload now always returns a status array
* Disabled async upload by url because wfShellBackgroundExec is broken
2009-08-26 19:38:38 +00:00
Roan Kattouw
9e881e1b2e Elaborate docs added in r53753 per CR comment 2009-07-26 18:24:47 +00:00
Roan Kattouw
4353f7b321 Followup to r53702: document $extradata parameter 2009-07-25 18:29:13 +00:00
Aryeh Gregor
da31137022 Better documentation for dieUsage()
If I got it wrong, please improve.
2009-07-23 23:50:04 +00:00
Michael Dale
369402239c other part of the r53342 commit 2009-07-15 23:15:51 +00:00
Michael Dale
aefc40d749 here it is ... the upload-api, script-server, js2 (javascript phase2) branch merge 1st attempt.
Here is a short overview of changes and associated default configuration variables (most everything is off by default) also see ~soon to be updated~: http://www.mediawiki.org/wiki/Media_Projects_Overview

= Upload Improvements =
==Upload API ==
* Based on the early work of Bryan Tong and others it adds the upload option to the api.
* We rewrite Special:Upload page to include use the new refactoring
* Added in token checks in both the SpecialUpload.php page so avoids DOS / xss copy-by-url JavaScript based cross site POST file submissions

== Copy by URL==
$wgAllowCopyUploads = false;
* http class rewrite includes a new http background download see: includes/HttpFunctions.php

* spins off a php process that calls: maintenance/http_session_download.php
* pushes updates to the session and gives the user a progress bar on http copy uploads from other server progress (using js2 upload interface) (if not using the js2 upload interface it does the request in-place but the download is limited to the php ini timeout time)

== Firefogg ==
* Firefogg enables resumable upload by chunks
* progress indicators and conditional invokation (js2 system)
* and of-course client side transcoding.

= Script Server =
$wgEnableScriptLoader = false;
* off by default if $wgEnableScriptLoader is turned on script files are grouped, gziped, cached etc.
for more info see: http://www.mediawiki.org/wiki/Extension:ScriptLoader

* Includes some early skin js include fixes (skin/script system still lots of love)
* Includes a "javascript class autoloader" this is packaged into mwEmbed so that the mwEmbed library can work in stand alone mode (while retaining localization and script serving) (one such application is the make page for firefogg.org : http://www.firefogg.org/make/index.html  )
* The file that contains the autojavascript loading classes is: js2/php/jsAutoloadLocalClasses.php
* One can use this auto class loading dependency system with extensions and add-ons but I need to better document that.

= js2 system  / mwEmbed=
$wgEnableJS2system = false

* includes initial rewrite towards more jquery based javascript code
* especially for the Special:Upload page.
* Also the edit page include support for the "add-media-wizard"
* includes dependency loader for javascript that optionally takes advantage of the script-loader
* remote embedding of javascript interfaces (like embedding video, or commons media searching)

* $wgDebugJavaScript = false; .. .this variable lets you always get "always fresh javascript". When used with the script-loader it does not minify the script-loader output.

= mwEmbed =
* Will commit a separate patch to oggHandler that conditionally outputs  <video tag> to use the new javascript video player.
** mv_embed player includes: play-head, volume control, remote embedding, oggz-chop support across plugins.
* add-media-wizard adds easy inserts of media to pages (with import)

== jQuery==
* we include a base install of jQuery, jQuery ui and some plugins.
* all the javascript classes are in the scriptloader so its easy to load any set of jquery ui components that you may need using the script-server. You get a callback so you can then execute js with dependencies loaded.

== other stuff ==
there is a bit more code in js2 that pertains to sequence editing, timed text display and basic image editing. We include a base import of pixastic-lib & pixastic-editor... will work with the pixastic developer to try and ensure upstream compatibility on our usage of the library for in-browser photo and sequence manipulation.
2009-07-14 23:52:14 +00:00
Bryan Tong Minh
31d9947618 (bug 18533) Add readonly reason to readonly exception 2009-07-12 12:38:03 +00:00
Roan Kattouw
91271d809e API: (bug 18731) Show correct SVN links for extension modules in api.php?version . Guesswork to get the path assumes extensions are in a directory called extensions/extensionname , which should be a valid assumption on sane installs. 2009-05-09 12:52:38 +00:00
Chad Horohoe
c5ae50df41 Don't explicitly check for false. Most modules without params return an empty array rather than false, in which case we still don't want to output this. 2009-05-07 20:02:20 +00:00
Roan Kattouw
e484ef763d API: Fix regression from r32224 with caused bug 18597 (internal error for empty generator= parameter) 2009-04-27 14:21:16 +00:00
Roan Kattouw
1083d741dc Followup to r49013: forgot to commit ApiBase.php 2009-03-29 16:40:31 +00:00
Roan Kattouw
5e7acff52b API: Add nosuchuser message to ApiBase::$messageMap 2009-03-26 13:01:53 +00:00
Alexandre Emsenhuber
c53e76ad34 Changed ereg(i)_replace to preg_replace, the former is throwing E_DEPRECATED since PHP 5.3 2009-03-18 19:25:29 +00:00
Alexandre Emsenhuber
9dd9379eb4 Per anomie's report on IRC: $wgMaxArticleSize is in kilobytes, not bytes 2009-03-07 17:37:29 +00:00
Roan Kattouw
21fd7af97e * API: (bug 17774) API pretends action=query doesn't exist for users without read rights
* Instead of hiding read-restricted modules, throw an error when a user without read rights tries to use them
* Do the same for write modules when $wgEnableWriteAPI is false
* Indicate whether a module needs read or write rights in action=help and action=paraminfo
* BREAKING CHANGE: action=purge now requires write rights and, for anonymous users, a POST request
2009-03-06 13:49:44 +00:00
Roan Kattouw
5349ea2dd8 * API: (bug 13209) Add rvdiffto parameter to prop=revisions
* Add $wgAPIMaxUncachedDiffs (default 1) which controls how many non-cached diffs will be served per request
* Tweak DifferenceEngine.php a bit to make cache status accessible, and remove a useless 'parseinline' which broke diff generation in the API
2009-02-28 13:25:21 +00:00
Roan Kattouw
a4b89293d6 API: (bug 17703) Fix regression from r47039 causing error code and error text to be switched for some errors. r47039 was backported to the 1.14 branch, will backport this one too. 2009-02-27 14:28:12 +00:00
Roan Kattouw
fdb926bca4 * API: Add documentation to important API classes
* Move page_is_redirect up in ApiPageSet::getPageTableFields()
2009-02-11 19:25:25 +00:00
Roan Kattouw
81bf8d0a3a * API: (bug 17357) Add subpage moving to the API
* Added Title::moveSubpages() as a backend function
** Didn't update SpecialMovepage to use this; left to braver souls
* Fix handling of errors on talk page move (will backport)
2009-02-09 14:16:51 +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
bb3980dd8d * API: (bug 17007) Add action=import
* Add intoken=import to prop=info
* Store message key and arguments in WikiErrorMsg
2009-02-04 20:11:27 +00:00
Roan Kattouw
8e361227a2 Revert r46512 (Add "check" parameter to action=email) and its followups r46515 and r46517. This functionality is already present in list=users (as usprop=emailable), where it belongs 2009-01-31 13:20:36 +00:00
Roan Kattouw
7babbd2fc5 Add the 'movenotallowedfile' message to the API message map. Turns out that's all I needed to do to support file moving through the API :D 2009-01-29 23:01:13 +00:00
X!
a9b78e1db9 Add "check" parameter to action=email 2009-01-29 01:25:17 +00:00
Roan Kattouw
6449867508 * API: (bug 15949) Add undo functionality to action=edit
* Move undo text generation from EditPage::getContent() to Article::getUndoText()
* Add some more examples for action=edit
* ApiEditPage.php: don't mix !is_null() and isset(), be consistent
2009-01-26 13:51:03 +00:00
Roan Kattouw
cd910c6544 API: Fix profiling errors caused by calling wfProfileClose() from dieUsage() 2009-01-23 20:23:34 +00:00
Alex Z
ff00dda0d0 Make API action=delete respect $wgDeleteRevisionsLimit 2009-01-20 23:37:39 +00:00
Roan Kattouw
781597bdce API: Fix weird ==/=== bug in API help: a possible value of zero is interpreted as "can be empty". 2008-12-21 00:21:01 +00:00
Roan Kattouw
8504bf43e2 API: Crusade against extract(). Left one extract() call alone in ApiQueryBacklinks.php because I don't have a better alternative for it. 2008-12-17 16:34:01 +00:00
Roan Kattouw
ec6060e5c9 API: Fix r42813, committed some stuff that shouldn't be committed just yet 2008-10-30 17:24:40 +00:00
Roan Kattouw
095803abf5 API: Tweak r42794 (add docs for ApiBase class constants) a little 2008-10-30 14:51:57 +00:00
Chad Horohoe
072649ebe8 Add some docs on these class constants 2008-10-30 00:39:21 +00:00
Tim Starling
f48c6070df Removed all instances of empty() where error suppression was not intended. Replaced with conversion to boolean, count() or empty string check as appropriate. Fixes a number of bugs due to incorrect conversion to boolean: suppressed edit summaries containing '0', ignored titles called '0', searches for '0' ignored, etc. 2008-10-25 14:04:43 +00:00
Roan Kattouw
6ad1e45cd9 API: * BREAKING CHANGE: (bug 16074) Providing prop=revisions&rvprop=content with too many titles or revisions (typically through a generator) no longer causes an error, but a warning
* Added ApiBase::truncateArray() and used it in ApiBase::parseMultiValue()
2008-10-24 13:05:44 +00:00