Commit graph

377 commits

Author SHA1 Message Date
Kevin Israel
725df97b1b Deprecate wfDebugDieBacktrace
Change-Id: I12336983e29524a450fc61ed9df4d840066be9b6
2013-09-27 19:57:41 -04:00
nischayn22
50ca5a7d17 hook to intercept upload_by_url
This is planned to be used for intercepting by UW for Flickr blacklisting.

Bug: 42307
Change-Id: Ia3daaeba1ce5e69e751ffc2ae5afd5e449cf4aa7
2013-07-24 19:11:33 +02:00
Brad Jorsch
18062eb3b0 Add user rights 'viewmywatchlist', 'editmywatchlist'
These are needed for OAuth grants.

Note that, even if 'editmywatchlist' is not granted, various actions
will still allow for adding but not removing of pages.

Change-Id: Ie33446a228dd6ed0114730935c1bf65667f5ce01
2013-06-26 10:20:40 -04:00
Brad Jorsch
c94454687f Return errors from WatchAction
Currently, WatchAction::doWatch and WatchAction::doUnwatch return true
always. Let's have them return a status object instead.

This also cleans up the handling of Status objects in some of the API
modules.

Change-Id: I9dd9f0fd499c37f29fa12bcdb6142238a1f11e4d
2013-06-20 15:51:05 -04:00
Marius Hoch
4650adb9b2 Only show notoken as possible API error once
Currently notoken is being listed as possible
API error twice if it's explicitly set as
required parameter and needsToken() returns
true.

See:
https://www.wikidata.org/w/api.php?action=paraminfo&modules=edit

Change-Id: Ia17c5cfa634919b43affa146df0d1dc0ff06b758
2013-06-11 00:03:46 +00:00
Matthias Mullie
52ecc8d9b5 invalidparammix/missingparam get the module prefix twice
dieUsage will call encodeParamName, which will already prefix the error code with the module prefix

E.g. for ApiViewFeedbackArticleFeedbackv5 (prefix afvf), this error code was
(incorrectly): afvfafvfinvalidparammix. Should be: afvfinvalidparammix

Change-Id: Ia351678b49e96ef58dce773331ebe9a1b3ebf824
2013-06-03 20:23:18 +02:00
umherirrender
2d9b71818f ApiHelp: Avoid header for example, when there no examples
When writing a new extension the source:

	public function getExamples() {
		return array(
			//TODO
		);
	}

would produce a empty "Example:" header on the help page. Avoid this, by
changing the condition to check for truthy instead of false and empty
string.

Change-Id: I67ecacbbac66b97ed96412abf79b49aebe0ebdbf
2013-05-28 15:37:41 +00:00
umherirrender
9d690a51c4 Fix badcontinue in possible errors of paraminfo
Badcontinue results in
<error code="unknownerror" info="Unknown error: &quot;badcontinue&quot;"
/>
because there is one array deep too much.

Change-Id: Iff88c3864f65e5da6cd31594396dffdaa71b5593
2013-05-16 08:55:39 +02:00
umherirrender
da39005596 Removed space after isset
While at it, added/removed some other spaces in the same files

Change-Id: Iabb23a448f6f53eb6020155f9c744f74f8b11786
2013-04-26 14:18:06 +02:00
umherirrender
a35cce4be0 Fixed spacing in api folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Id7779dca4d1185245cf5764102b8de8b232c34b6
2013-04-20 07:47:36 +00:00
umherirrender
4975761eb2 API: Add new hook 'APIGetPossibleErrors'
This allows extensions to modify the array.

This completes the serie of hooks for similar get methods in ApiBase.

Change-Id: Ib398f5815ab57f25d56356b0997c55a03fd96874
2013-04-19 15:25:58 +02:00
umherirrender
c9d5aa1890 fixed php doc in ApiBase
Change-Id: I9c893de8c067be3e926f5de5f0b87ac47b81772d
2013-04-05 15:47:36 +02:00
umherirrender
b1584c4748 Remove spaces around ::
Change-Id: I24fe5ad907bcf5235aa91b650785c571502456a1
2013-04-03 12:57:10 +02:00
umherirrender
a06611755a API param validation: Set strict mode for in_array
The in_array gives true when the allowed values contains a 0 as value,
for example by namespaces,

action=query&list=allpages&apnamespace=test|tset

was not rejected

Change-Id: I9220a955ffaf2bcb0d1d5b27c948af2f85714110
2013-04-02 12:05:50 +02:00
umherirrender
6c278b6d7e fix some spacing
* Removed spaces around array index
* Removed double spaces or added spaces to begin or end of function
  calls, method signature, conditions or foreachs
* Added braces to one-line ifs
* Changed multi line conditions to one line conditions
* Realigned some arrays

Change-Id: Ia04d2a99d663b07101013c2d53b3b2e872fd9cc3
2013-03-25 22:22:46 +00:00
umherirrender
8764b3aa7c Remove spaces in function signature
Change-Id: I45aea7a7af88cd913b2f485913620a8af0ab2fed
2013-03-18 20:44:43 +01:00
umherirrender
4b34c32ed2 API: Remove useless PARAM_REQUIRED = false
Also fix the condition in getPossibleErrors to avoid reporting of:
<error code="nosectiontitle" info="The sectiontitle parameter must be
set" />

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

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
jenkins-bot
493b766fdb Merge "Fixed many small spelling mistakes and php docs, var decl." 2013-03-11 14:17:08 +00:00
Yuri Astrakhan
0aa24ae558 Fixed many small spelling mistakes and php docs, var decl.
Change-Id: I1508ed7eb77e5e4f700fb63955d626c4f5915840
2013-03-10 23:45:51 -04:00
umherirrender
435d16e003 API param validation: Add wrong value to error message on user params
It is always nice to get the wrong value back to know it.
Refactor a bit to avoid the array wrapping and unwrapping for non-multi
params.

Adjust another variable, add doc comments, removed a empty line and
reorder a condition for easy reading.

Change-Id: Ia91aa5908b82ad1209dc7da1139f91e1f2b45fac
2013-03-09 22:14:03 +01:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
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