Add a hint to the getError function which should be called in the
getPossibleErrors() function.
Also do this for getTitleOrPageId.
Change-Id: I601feb8a5b8699ce4d81814aa3cd127552a525ac
The existing doc blocks for all three of these functions is entirely
wrong.
* ApiBase::requireOnlyOneParameter
* ApiBase::requireMaxOneParameter
* ApiBase::requireAtLeastOneParameter
Change-Id: Id0dd86be3cbfa813a43f918c7d780c7ee2afc09e
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.
Change-Id: I758fa4ad80ac95e2ddd3770bcb9b7d2e57ec34ea
Add support for ApiPageSet capabilities in ApiWatch to support batch
operation on titles, pageids etc. The old 'title' parameter (for a
single page) is still supported to keep backwards compatibility.
Moved a function from ApiPurge to ApiPageSet: getInvalidTitlesAndRevisions() gathers
warnings about invalid/missing titles/ids in the requested page set.
Split from If993f6e8.
Change-Id: I820dcb64d469616b10741df013911197cc5bde29
Fixes to patch that introduced ApiBase::requireAtLeastOneParameter.
Includes line breaks, code formatting, and documentation fixes.
Change-Id: I1a2faebf7cc9a2126def66d8a4ce64dbfa84059b
Follows-Up: Iae6649ed503fdbf14 (5e7a9c6f8e)
Added new ApiBase::requireAtLeastOneParameter() helper method for modules
that need one or more of a combination of parameters. The associated help
message function has also been added.
Change-Id: Iae6649ed503fdbf14b313d0be1a82f3dca8d7162
Fixed a little documentation issue, removed a line of unreachable code
and fixed up two formatting issues in the process.
Change-Id: If29391ee1a0daf19973437f36c3216b8716debd0
In general, the web UI does a check of the watchlist preferences along
the lines of "watch if watchdefault, or if watchcreations and the title
doesn't exist". So there's no way to have it watch edits but not
creations. Make the API behavior match this.
For API action=protect&watchlist=preferences, we want to use
'watchdefault' always to match the behavior of the web UI.
For Special:Upload, the code is all there to do a "watch if
watchdefault, or if watchcreations and the file doesn't exist". But for
some reason that code wasn't being used in favor of just using
watchcreations all the time. Fix that, too. And have the API use that
instead of checking if the file page exists.
Bug: 56766
Change-Id: I57fc46d9a97b3ea2169173727db842d0d7ecf81d
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
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
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
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
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
Badcontinue results in
<error code="unknownerror" info="Unknown error: "badcontinue""
/>
because there is one array deep too much.
Change-Id: Iff88c3864f65e5da6cd31594396dffdaa71b5593
This allows extensions to modify the array.
This completes the serie of hooks for similar get methods in ApiBase.
Change-Id: Ib398f5815ab57f25d56356b0997c55a03fd96874
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
* 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
Also fix the condition in getPossibleErrors to avoid reporting of:
<error code="nosectiontitle" info="The sectiontitle parameter must be
set" />
Change-Id: Ifd808a040590ddffc0527da5ef0cc8cacdd008d9
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
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
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
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
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
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
* 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
* 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