Commit graph

5686 commits

Author SHA1 Message Date
Fomafix
6866cfec37 Simplify PHP by using ?? and ?:
Also remove not necessary surrounding parentheses.

Change-Id: I0eb5c9c1bdfb09a800258379cdcefb5fd4d3d21c
2018-07-10 20:03:17 +00:00
Translation updater bot
b4f2a28c3f Localisation updates from https://translatewiki.net.
Change-Id: I3aa4ab1da349c15c6fb33c323324119aa352eff8
2018-07-03 21:54:37 +02:00
Max Semenik
b6e13c7e6e Hard-deprecate ApiBase::profile{In|Out}()
The only remaining calls are getting removed in I37641dee50a.

Change-Id: I3ee698781a4698d1ef8e74209b82fb1f984fb8e9
2018-06-28 13:57:46 -07:00
Translation updater bot
42ae4a4d82 Localisation updates from https://translatewiki.net.
Change-Id: I401fa4fb518d8f772e3bd1cc06eda55a066d75e1
2018-06-28 21:55:54 +02:00
Translation updater bot
28eb784704 Localisation updates from https://translatewiki.net.
Change-Id: Ia319ca22827e6f4f8302c03342db181e3e350596
2018-06-27 21:53:09 +02:00
Max Semenik
3840b8a17e Refactor ApiOptions for reusability
Because GlobalPreferences needs an API and that API needs to behave like
this one, it makes sense to make them share code. Move some functionality
into separate functions to make this possible.

Bug: T62856
Change-Id: Ic64934e7f7226a309d71c22626119ea233e2caeb
2018-06-26 15:46:40 -07:00
Translation updater bot
198f9a4178 Localisation updates from https://translatewiki.net.
Change-Id: I6c8bffce7566484cc46e852b20c0b29d655e8a36
2018-06-26 21:55:47 +02:00
Translation updater bot
979b7b5911 Localisation updates from https://translatewiki.net.
Change-Id: Ie589a2973df5cc34bc5b622cd135608b7bb29a34
2018-06-25 21:54:09 +02:00
Translation updater bot
74e7bbcfce Localisation updates from https://translatewiki.net.
Change-Id: I9a6171181bfab383402ad99e1f59315d5aded560
2018-06-24 22:07:51 +02:00
jenkins-bot
75c03d08fa Merge "API: Check assert parameters earlier in the request" 2018-06-22 21:36:36 +00:00
Translation updater bot
4ce981bcef Localisation updates from https://translatewiki.net.
Change-Id: Ibd413089aba90336bcc5bd0be2fdccb78130781c
2018-06-21 22:09:18 +02:00
Brad Jorsch
d927830935 API: Check assert parameters earlier in the request
Specifically, check the assert and assertuser parameters before setting
up the action module, so errors in parsing the module's parameters due
to being logged out don't override the client's intended "am I logged
in?" check.

Note this means that assertion failures will no longer use custom module
output formatters. This seems like an acceptable tradeoff: on Wikimedia
sites in May 2018 there were no requests that would have been affected
by this change.

Bug: T197672
Change-Id: I02a71395d5ed9f445e57162f2136292825f8dbb5
2018-06-21 14:50:47 -04:00
Translation updater bot
16489838b4 Localisation updates from https://translatewiki.net.
Change-Id: I07213bede472c7fc7f22596703492b8dace4360d
2018-06-20 22:54:25 +02:00
Brad Jorsch
b18ae822e2 API: Use param-per-value for meta=filerepoinfo's friprop docs
This avoids documenting properties that may not be valid on the local
wiki, depending on which repos are actually available.

This patch also documents the other values available from repo types
available in MediaWiki core.

Bug: T197730
Change-Id: I6bf9fbf4ac29042d9f7524c6c1a5990051150cd3
2018-06-20 10:47:18 -04:00
Translation updater bot
a406a49e9f Localisation updates from https://translatewiki.net.
Change-Id: I84f0d16eb74abe7d6b1a85bb3861fd95018101b5
2018-06-19 22:02:49 +02:00
Translation updater bot
c9d7f667ec Localisation updates from https://translatewiki.net.
Change-Id: Idafba5d45cb472eb430092517016d0666fe0f30d
2018-06-18 21:54:31 +02:00
Translation updater bot
e599ca3982 Localisation updates from https://translatewiki.net.
Change-Id: I98ff6cea4c6f300ddbe91e383d709e65da2fdcfd
2018-06-17 22:00:00 +02:00
Translation updater bot
01ec27b92f Localisation updates from https://translatewiki.net.
Change-Id: I9c4e0d3ae69eae41d25bf120e93954d93e127037
2018-06-16 21:52:56 +02:00
Translation updater bot
a525ce2e65 Localisation updates from https://translatewiki.net.
Change-Id: I8725e92d4f6aea313e6461a4c6ef5c76e87d86ed
2018-06-15 22:01:30 +02:00
jenkins-bot
84fa176c9c Merge "Avoid deprecated LinkCache::singleton()" 2018-06-14 23:48:54 +00:00
Translation updater bot
6d7b35df75 Localisation updates from https://translatewiki.net.
Change-Id: I693bcc8f16293b435b4b334d0c48e09671f73d36
2018-06-14 22:14:20 +02:00
jenkins-bot
1abed55d47 Merge "Expose sort orders from search engine in ApiQuerySearch" 2018-06-13 16:29:36 +00:00
Erik Bernhardson
7bf3c40506 Expose sort orders from search engine in ApiQuerySearch
Selectable sort orders were added to search some time ago, but never
appear to have been used.  Expose them in ApiQuerySearch.

There is one large problem here, but it's not easily solvable.
Specifically supported sort orders vary per search engine, but the
available api parameters are calculated with the default search
engine. This is already a problem with search profiles so it's
nothing new, just continuing the existing problem. Much like
search profiles we hide the functionality when multiple engines
are available.

Bug: T195071
Change-Id: I187a530bc973c08386d2c2126e02a85b952d9022
2018-06-13 08:57:16 -07:00
Erik Bernhardson
2a43939ffb Push pagination decision for search into SearchEngine
Various code using the search engine shouldn't need to implement it's
own methods, such as over-fetching, to determine if there are more
results available. This should be knowledge internal to search that is
exposed by a boolean.

Change-Id: Ica094428700637dfdedb723b03f6aeadfe12b9f4
2018-06-11 13:35:44 -07:00
Erik Bernhardson
c2a308075f Convert SearchResultSet to typical iteration
The funky iteration here was at best annoying. Switch
it over to an iterator based approach with appropriate
BC code to simulate the old iteration style.

Depends-On: I19a8d6621a130811871dec9335038797627d9448
Change-Id: I9fccda15dd58a0dc35771d3b5cd7a6e8b02514a0
2018-06-11 13:35:41 -07:00
Kunal Mehta
c4e5a9dd97 Avoid deprecated LinkCache::singleton()
Change-Id: Ie0e5c4ef0fe6ec896378bb2433af0898655dd907
2018-06-10 23:55:11 -07:00
Max Semenik
6e956d55aa Replace call_user_func_array(), part 2
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

In one occurrence, a simple conditional instead of trickery was much more readable.

This patch finishes all the easy stuf in the core, the remainder is either unobvious
or would result in smaller readability gains. It will be carefully dealt with in
further commits.

Change-Id: I79a16c48bfb98b75e5b99f2f6f4fa07b3ae02c5b
2018-06-07 20:19:26 -07:00
Translation updater bot
7ac6279d14 Localisation updates from https://translatewiki.net.
Change-Id: I76a6f7a48e28f135120f73121eac582dd96b3411
2018-06-07 23:19:17 +02:00
jenkins-bot
0e96bc1a9e Merge "Replace call_user_func_array(), part 1" 2018-06-07 12:11:10 +00:00
Translation updater bot
fe2fcd8904 Localisation updates from https://translatewiki.net.
Change-Id: I6ffcde700fa06cecb3d4bc4016ddc3c0ca2559e9
2018-06-06 22:26:48 +02:00
Translation updater bot
05e5f781a1 Localisation updates from https://translatewiki.net.
Change-Id: I6dec7f28bdbcee3b2de48f7ce2c584db45aea730
2018-06-05 21:55:47 +02:00
jenkins-bot
998b8afae9 Merge "Introduce ApiMaxLagInfo hook" 2018-06-05 18:01:49 +00:00
Amir Sarabadani
5a7e9ba954 Introduce ApiMaxLagInfo hook
This will be useful when an extension does something expensive and wants to
make sure users don't put too much pressure on the system.

Bug: T194950
Change-Id: I8a396d07c2d5764a680d0e5536cd1f99edbe141e
2018-06-05 19:46:09 +02:00
Max Semenik
8085c58a4b Replace call_user_func_array(), part 1
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

Change-Id: Idcec077ef3fdf029b632cceafd0150851ad723e3
2018-06-04 23:39:04 -07:00
Translation updater bot
662a418d92 Localisation updates from https://translatewiki.net.
Change-Id: Iccda6c6d7b123642f366c37440486b9132357286
2018-06-02 22:26:03 +02:00
Translation updater bot
d3e3d7a452 Localisation updates from https://translatewiki.net.
Change-Id: I31d331db53d5f1425541930dbff6f7b28ba470f7
2018-06-01 21:54:03 +02:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Bartosz Dziewoński
b191e5e860 Use PHP 7 '<=>' operator in 'sort()' callbacks
`$a <=> $b` returns `-1` if `$a` is lesser, `1` if `$b` is lesser,
and `0` if they are equal, which are exactly the values 'sort()'
callbacks are supposed to return.

It also enables the neat idiom `$a[x] <=> $b[x] ?: $a[y] <=> $b[y]`
to sort arrays of objects first by 'x', and by 'y' if they are equal.

* Replace a common pattern like `return $a < $b ? -1 : 1` with the
  new operator (and similar patterns with the variables, the numbers
  or the comparison inverted). Some of the uses were previously not
  correctly handling the variables being equal; this is now
  automatically fixed.
* Also replace `return $a - $b`, which is equivalent to `return
  $a <=> $b` if both variables are integers but less intuitive.
* (Do not replace `return strcmp( $a, $b )`. It is also equivalent
  when both variables are strings, but if any of the variables is not,
  'strcmp()' converts it to a string before comparison, which could
  give different results than '<=>', so changing this would require
  careful review and isn't worth it.)
* Also replace `return $a > $b`, which presumably sort of works most
  of the time (returns `1` if `$b` is lesser, and `0` if they are
  equal or `$a` is lesser) but is erroneous.

Change-Id: I19a3d2fc8fcdb208c10330bd7a42c4e05d7f5cf3
2018-05-30 18:05:20 -07:00
Bartosz Dziewoński
52b0799e8d Use PHP 5.6 constant expressions for some bitfield constants
I searched the entire codebase for 'const' and looked for things
that looked suspiciously like manually calculated bitfield unions.
As of PHP 5.6, we can have them calculated automatically when
defining constants.

Change-Id: I7d971d1a63f8916db2f8f6c053c7dd0a13add92d
2018-05-30 18:05:18 -07:00
Krinkle
7759b85acc Merge "Split ApiUsageException and UsageException to class per file" 2018-05-29 23:39:11 +00:00
jenkins-bot
930a808814 Merge "Split ApiMessage to class per file" 2018-05-29 22:18:24 +00:00
Reedy
765370a6db Add @deprecated tags to various class_alias calls
Bug: T195576
Change-Id: I10cd8415891bfe4a278eee06c9cfe905b3e036dc
2018-05-29 13:10:20 -07:00
Translation updater bot
b379b06951 Localisation updates from https://translatewiki.net.
Change-Id: Ia47406929fcf2e288dbc4621ae6cf64ad2c3d070
2018-05-29 22:01:52 +02:00
Brad Jorsch
24be43b9aa API: ApiBase::getParameter() shouldn't throw on other params' errors
This regression was introduced in Ia19a1617b7.

Bug: T195777
Change-Id: I1e1eb3861ced83f79e56d2325ab693ef4e393999
2018-05-28 18:45:24 -04:00
Translation updater bot
f3dd9d3f7b Localisation updates from https://translatewiki.net.
Change-Id: Ied787b7f07a91cabbe26a85d04e2ed730444637e
2018-05-28 22:17:22 +02:00
Reedy
d741d0d962 Split ApiUsageException and UsageException to class per file
Change-Id: I54c7d5e6616ac1a23082cc72e60ed92cb7eef715
2018-05-27 20:43:55 +00:00
Translation updater bot
a98c478ea4 Localisation updates from https://translatewiki.net.
Change-Id: I5c895f4b61a73570671acf36c817cc405f54ec0b
2018-05-27 21:57:03 +02:00
Reedy
5522a7a9b8 Split ApiMessage to class per file
Change-Id: If8f51e6535d0ec6e35336a6702c5e35be35bcf09
2018-05-27 00:31:30 +00:00
jenkins-bot
468690e036 Merge "Rename ApiQueryContributions to ApiQueryUserContribs to match api module name" 2018-05-26 23:57:30 +00:00
Reedy
0be39da9b0 Rename ApiQueryContributions to ApiQueryUserContribs to match api module name
Change-Id: I865628b87eda7be349522fcfaf94f5563142026e
2018-05-26 23:07:15 +00:00