Commit graph

6712 commits

Author SHA1 Message Date
jenkins-bot
5949b43699 Merge "Update all use of $wgVersion to MW_VERSION" 2020-02-25 16:04:01 +00:00
Translation updater bot
27a22f9333 Localisation updates from https://translatewiki.net.
Change-Id: I3b72a8056a49f1490cffefbb22880206f835ae35
2020-02-25 08:21:50 +01:00
Timo Tijhof
f575721a06 Update all use of $wgVersion to MW_VERSION
Follows-up I04628de4152dd5.

Bug: T212738
Change-Id: I718474ec0d9fd29ac2c05477f0f2493615d8aff5
2020-02-25 02:16:12 +00:00
jenkins-bot
0d26fc6930 Merge "Hard deprecate Revision::userCanBitfield" 2020-02-24 21:49:27 +00:00
DannyS712
d3aa888904 Hard deprecate Revision::userCanBitfield
Also replace uses. Some callers had a user that could be null;
RevisionRecord::userCanBitfield requires a user, so add $wgUser
fallbacks at the callers with soft deprecations for using them,
and will hard deprecate in a subsequent task.

Bug: T245958
Change-Id: I137e21e3883b149fdd98d1b59d4e498d15b39dd9
2020-02-24 21:18:49 +00:00
Lucas Werkmeister
3201bf5e39 Inject language services into ApiQueryLanguageinfo
Change-Id: I05a03d7a81aad3d9b592e062412eea1c1e9b57d8
2020-02-24 19:37:37 +01:00
Translation updater bot
46776c620e Localisation updates from https://translatewiki.net.
Change-Id: Ib6343e12ed46dcd218b9aa9f032a0f2bdc36cefe
2020-02-24 08:27:23 +01:00
Daimona Eaytoy
60dc4b41f8 stashedit: Ensure that $summary is a string
It's only documented as string.

Bug: T245928
Change-Id: I8fa287f335e90a59ac18365e7401a5cf703130a3
2020-02-22 19:55:28 +00:00
DannyS712
bc41f44c5e Remove $wgFixArabicUnicode and $wgFixMalayalamUnicode
Bug: T241352
Bug: T241353
Change-Id: Idefd5624d761fad4a6c3cca950ce1038a4dec770
2020-02-21 19:29:31 +00:00
jenkins-bot
1cb25b580a Merge "Fix the namespace of SpecialPageFactory" 2020-02-21 15:41:18 +00:00
Translation updater bot
7deb1cfaa1 Localisation updates from https://translatewiki.net.
Change-Id: Ia43cf43e44efe43a2ea03bd6dc847a6224109c0f
2020-02-21 09:13:39 +01:00
Tim Starling
44d51cb04e Fix the namespace of SpecialPageFactory
Follows-up d4045035b0.

This class was added to the MediaWiki\Special namespace, contrary to the
plan in T166010 which reserves that namespace for core special pages.
Instead, use MediaWiki\SpecialPage, following the directory in which it
is located.

Also, fix two bugs which prevented the introduction of a namespaced
class alias.

Bug: T166010
Change-Id: I6e31340aaae32a89beb7e45b79d76a7fea9808d2
2020-02-21 13:46:19 +11:00
Bartosz Dziewoński
68e495d8b0 ApiMain: Add support for assert=anon
In VisualEditor, when the user is saving their edit, we want to ensure
that they understand how their edit will be attributed. Therefore, if
the user gets logged out or logs in in another tab, we want to display
a message about it before saving.

We've been detecting this situation by manually managing tokens and
handling the 'badtoken' error, but our code would be much simpler and
it would be possible to share it with other extensions if we could
instead rely on automatic retrying in mw.Api#postWithToken and use
'assertuser' and 'assert' parameters. 'assert=anon' is the only
feature we're missing.

Bug: T245327
Change-Id: I485f99e1f5f493262b0c9af22370da01adf1e09c
2020-02-19 22:37:31 +01:00
Translation updater bot
b7562e5936 Localisation updates from https://translatewiki.net.
Change-Id: I5b91a99e0fee851bead045e588381ce904acef69
2020-02-19 07:54:19 +01:00
jenkins-bot
4fbf949afa Merge "Fix some PHPStorm inspection warnings in includes/api" 2020-02-18 19:32:58 +00:00
Tim Starling
a06e3d06b1 Fix some PHPStorm inspection warnings in includes/api
Notably:
* In ApiManageTags, I used a switch instead of a dynamic function name,
  so that the call graph will be correct.
* In ApiImageRotate, checkTitleUserPermissions() has always returned
  void, this was an error introduced in 4e6810e4a2

Change-Id: Iea22616b8e7e2e0cc804619a54f8690898b2cb82
2020-02-18 14:17:37 -05:00
Aaron Schulz
6b12696452 Move UIDGenerator code to a service and put it under /libs
All MediaWiki dependencies have been removed or injected.

Change-Id: I01c9e96edd6b03496c1595670967ffa5a4069c9d
2020-02-18 00:20:40 +00:00
Translation updater bot
a6f5dad6bf Localisation updates from https://translatewiki.net.
Change-Id: Iacd73f45c0624c21f9ec64c395c5d2ac6890297c
2020-02-17 08:04:08 +01:00
Petr Pchelko
204fa7e509 Remove usages of deprecated Language methods
Change-Id: Iad3375b141b1d87c890baec6ecd16ed92f93e699
2020-02-16 00:45:48 +00:00
Brad Jorsch
e0f3a29349 API: Fix fetching login token from action=query&meta=tokens on private wikis
Accidentally broken by I991809acf.

Also added a test that should hopefully prevent this from accidentally
being broken again.

Bug: T245149
Change-Id: Ia7985397db50efe8af81f643f2a0a89d0ece179e
2020-02-14 15:42:54 -05:00
Reedy
4f98a95aa1 Don't use 'message' as a logging key
Bug: T245280
Change-Id: I5904fe7539322c4d923bc8b8c88fda272d7dff8b
2020-02-14 20:31:29 +00:00
Reedy
511f9b5d95 Don't pass 'ip' through to logging
Bug: T245280
Change-Id: Ib89be9f799e79f46dab661a387822cab43703f61
2020-02-14 17:46:10 +00:00
Translation updater bot
f7f0699367 Localisation updates from https://translatewiki.net.
Change-Id: I68e0d7a99b81f57f026c0406e7b9f67999f1758a
2020-02-14 07:57:57 +01:00
Daimona Eaytoy
7bf077baf5 ApiRollback: Properly deal with UserIdentity
Follow-up I1462edc170127, which enabled the
UserDef::PARAM_RETURN_OBJECT flag for the 'user' parameter,
so that it returns UserIdentityValue objects instead of string
values, but the internal use of that value was still expecting
a string


Bug: T245159
Change-Id: I2f8d8c406ab81b6d5dc19a1fff389646af61001e
2020-02-13 18:11:04 +00:00
Translation updater bot
1c11d177e0 Localisation updates from https://translatewiki.net.
Change-Id: Ib77e50610a2786734f41eef3ae064d50a089b12f
2020-02-13 08:09:30 +01:00
Ricordisamoa
1b3bc281ac Clean up redundant Exception|Throwable union type
PHP 7.0 makes many error conditions throw instances of the new Error class
which does not extend the known Exception.
The Throwable interface provides a concise and type-safe way of handling
either, e.g. for logging purposes, but HHVM did not support it, requiring
tedious fallback checks.

This commit replaces occurrences of Exception in code paths equally
covered by Throwable, like Exception|Throwable parameter and return types
(also nullable), instanceof guards, duplicated `catch` blocks, as well as
related comments and documentation blocks, with the exception of $previous
parameter descriptions consistent with the manual at
https://www.php.net/manual/en/exception.construct.php

Proper type declarations have been added or reinstated where possible.

Change-Id: I5d3920d3cc66936a350314e2f19c4f6faeffd7c0
2020-02-12 20:28:40 +00:00
Translation updater bot
c033c62628 Localisation updates from https://translatewiki.net.
Change-Id: I0416c6bbc91c669b4e7bc058547c1270ba302a19
2020-02-12 07:55:09 +01:00
jenkins-bot
9b2199bcf1 Merge "ApiDisabled: Correctly fall back to api-help-no-extended-description" 2020-02-12 00:11:14 +00:00
Translation updater bot
ae3dee0d89 Localisation updates from https://translatewiki.net.
Change-Id: Ic14fb1b58302bed2e2f1d16b690cc27e0aad957f
2020-02-11 07:53:38 +01:00
Translation updater bot
d68fe17bb7 Localisation updates from https://translatewiki.net.
Change-Id: I685856eb029595a57db4443b75cf046f8e0b94b6
2020-02-10 07:54:14 +01:00
jenkins-bot
c57205f452 Merge "API: Remove unused "non-whitelisted CORS origin" log" 2020-02-07 23:15:14 +00:00
Translation updater bot
d60771a7d7 Localisation updates from https://translatewiki.net.
Change-Id: I4db9a6bc2ac8ec54f618190d1ddd99f95996993e
2020-02-07 08:34:28 +01:00
jenkins-bot
206e2fd72d Merge "Introduce ContentHandlerFactory" 2020-02-06 22:38:37 +00:00
ArtBaltai
30e54b3962 Introduce ContentHandlerFactory
Added:
- ContentHandlerFactory
Tests:
- PHPUnit
Changed
- Calls of changed and deprecated
- DI for some service/api
Deprecated:
- ContentHandler::* then similar to ContentHandlerFactory
- ContentHandler::getForTitle
- ContentHandler::$handlers

Bug: T235165
Change-Id: I59246938c7ad7b3e70e46c9e698708ef9bc672c6
2020-02-07 00:53:51 +03:00
jenkins-bot
43d4d098c6 Merge "ApiQueryExtLinksUsage: Avoid bad query plan" 2020-02-06 15:59:21 +00:00
Translation updater bot
28c59b7d4d Localisation updates from https://translatewiki.net.
Change-Id: I9c106734e3644e690ce3f4cf778ecd3a37d7ebb7
2020-02-06 07:55:13 +01:00
Translation updater bot
7516cb05fa Localisation updates from https://translatewiki.net.
Change-Id: Ic5fc5056b0a1d76174728694b9745281496357e4
2020-02-05 07:54:17 +01:00
jenkins-bot
8d1a7b906e Merge "Deprecate access of logos directly from config, introduce wgLogos" 2020-02-05 02:09:32 +00:00
Brad Jorsch
c42ee486f4 ApiQueryExtLinksUsage: Avoid bad query plan
Apparently MariaDB will sometimes decide it makes more sense to scan and
filesort 80 million rows instead of using an index that allows it to
check only the LIMIT.

A STRAIGHT_JOIN (along with fixed table order) seems to avoid this.

Bug: T244254
Change-Id: I1bf1203459922e2a16fa7339ff424a67005e4a2a
2020-02-04 16:05:11 -05:00
Brad Jorsch
d4c2f0d899 Move some validation logic from ApiStructureTest to ParamValidator
ApiStructureTest has a lot of logic for validating Action API settings
arrays during CI. Some of that logic should be part of ParamValidator
instead.

Bug: T242887
Change-Id: I3c3d23e38456de19179ae3e5855397316b6e4c40
Depends-On: I04de72d731b94468d8a12b35df67f359382b3742
2020-02-04 20:29:35 +00:00
Brad Jorsch
c2b1525908 API: Use ParamValidator library
This brings significant modularization to the Action API's parameter
validation, and allows the Action API and MW REST API to share
validation code.

Note there are several changes in this patch that may affect other code;
see the entries in RELEASE-NOTES-1.35 for details.

Bug: T142080
Bug: T232672
Bug: T21195
Bug: T34675
Bug: T154774
Change-Id: I1462edc1701278760fa695308007006868b249fc
Depends-On: I10011be060fe6d27c7527312ad41218786b3f40d
2020-02-04 13:36:14 -05:00
jdlrobson
8cd2e13363 Deprecate access of logos directly from config, introduce wgLogos
Add getAvailableLogos static method and wgLogos config variable

Longterm we'll phase out wgLogo and wgLogoHD for this more extendable
config.

wgLogoHD is marked as deprecated. wgLogo continues to function as before
when wgLogos doesn't exist to cause minimum disruption.

From now on all logos should be accessed via getAvailableLogos. Patches
in Minerva and Vector follow. See I00899c16c0325f36b671baf17e88c2b5187b3526,
I569e0d800e147eabc7852567acd140108613f074 and
I013bd0904fe8c55efa49d14e84cf06ec1412896f.

Bug: T232140
Change-Id: I66a971631c623cc94b58eb0e5e5bad804789bf1c
2020-02-04 01:56:20 +00:00
Peter Ovchyn
61e0908fa2 languages: Introduce LanguageConverterFactory
Done:
* Replace LanguageConverter::newConverter by LanguageConverterFactory::getLanguageConverter
* Remove LanguageConverter::newConverter from all subclasses
* Add LanguageConverterFactory integration tests which covers all languages by their code.
* Caching of LanguageConverters in factory
* Make all tests running (hope that's would be enough)
* Uncomment  the deprecated functions.
* Rename FakeConverter to TrivialLanguageConverter
* Create ILanguageConverter to have shared ancestor
* Make the LanguageConverter class abstract.
* Create table with mapping between lang code and converter instead of using name convention
* ILanguageConverter @internal
* Clean up code

Change-Id: I0e4d77de0f44e18c19956a1ffd69d30e63cf51bf
Bug: T226833, T243332
2020-02-03 11:38:03 +02:00
Translation updater bot
d60c1c1b3f Localisation updates from https://translatewiki.net.
Change-Id: I0059fc2f3b780dd547a32d1637b4a5fb1c7615ee
2020-02-03 07:55:20 +01:00
Translation updater bot
ed8604f229 Localisation updates from https://translatewiki.net.
Change-Id: Ib1eb92ce2249eadf6786686bf77b9507f708349c
2020-01-31 09:20:41 +01:00
Brad Jorsch
7a8fa0d9fd API: Remove unused "non-whitelisted CORS origin" log
This log message was added at the request of Wikimedia's Security team
in 2016, but as far as I can tell was never enabled on Wikimedia sites.

Rather than adding more logic to avoid logspam when browsers include an
Origin header for same-orign requests, let's just get rid of it
entirely.

Bug: T243908
Change-Id: I799b17a5f4891f9e739d6b62551a5736b8a6664e
2020-01-29 09:28:35 -08:00
Translation updater bot
e3a670e190 Localisation updates from https://translatewiki.net.
Change-Id: I801dd48f22b98eb3e17dc7c5b49d1fe602cc63f3
2020-01-29 07:54:28 +01:00
jenkins-bot
e963682c34 Merge "ApiQueryAllRevisions: Fix second example" 2020-01-28 18:46:52 +00:00
DannyS712
76ddd260a2 ApiQueryAllRevisions: Fix second example
Bug: T241806
Change-Id: Ifc349b299dc75f8423a7308b333a4334cd28a8f6
2020-01-28 17:46:58 +00:00
jenkins-bot
aba8016fae Merge "Upgrade phan to 0.9.1" 2020-01-26 07:44:22 +00:00
Daimona Eaytoy
41ee2f2c61 Upgrade phan to 0.9.1
Released just now.

Many old suppressions can now be removed. Enabling the issue for
undeclared variables is left to do later, given that there are
roughly 200 warning.

Change-Id: I99462a1e9232d6e75022912e2df82bc2038476ef
2020-01-25 10:53:26 +00:00
jenkins-bot
8a19838915 Merge "ApiParse: Use the right Skin object for building section edit links" 2020-01-24 22:01:28 +00:00
Bartosz Dziewoński
965b788178 ApiParse: Use the right Skin object for building section edit links
Apparently the section edit links may depend on state that is
available through context in the Skin object, but not necessarily
through the global context, such as the current user and page title.

Allow ParserOutput::getText() to take a 'skin' option for this purpose.

Bug: T234868
Change-Id: Iaa83e5f801c7776bf8218d8ce7484e2485b227d4
2020-01-24 18:53:20 +01:00
jenkins-bot
3c896fce16 Merge "Drop support for passing a User to ApiBase::checkTitleUserPermissions" 2020-01-24 17:52:53 +00:00
Translation updater bot
e1ef300f07 Localisation updates from https://translatewiki.net.
Change-Id: I12c78740a5344967d7328ae9552b1eb18eaac303
2020-01-24 07:55:55 +01:00
DannyS712
df46acc56d Drop support for passing a User to ApiBase::checkTitleUserPermissions
Deprecated and unused

Bug: T241354
Change-Id: I7726eba3e583548a284bffb8a28df0767bda31b4
2020-01-23 10:44:22 -08:00
Translation updater bot
c1b445c44c Localisation updates from https://translatewiki.net.
Change-Id: Ib93db5231d13831aca093bda28c8a2bf5204d853
2020-01-20 07:54:53 +01:00
jenkins-bot
a4d9ec9f1e Merge "Remove unused variable $commentStore" 2020-01-20 05:18:01 +00:00
Tim Starling
5873281251 Remove unused variable $commentStore
Change-Id: I0c1c135962c62a0a979afc513b41768eee110b33
2020-01-20 15:59:06 +11:00
Translation updater bot
24b512a03a Localisation updates from https://translatewiki.net.
Change-Id: I9e30191999637586fe54b9313bf40fce7ca48857
2020-01-16 09:09:38 +01:00
Translation updater bot
283d9144f6 Localisation updates from https://translatewiki.net.
Change-Id: If522b945e7394e53dc3eeeb0a735434fceebec4f
2020-01-15 09:29:47 +01:00
Brad Jorsch
edc3272816 ApiDisabled: Correctly fall back to api-help-no-extended-description
ApiBase falls back to this message when the module itself doesn't define
an extended-description message. ApiDisabled and ApiQueryDisabled should
do so as well.

Bug: T242534
Change-Id: I8f3ed17559363d9c66c5baf0ef7b0675714dc877
2020-01-13 09:24:11 -05:00
Translation updater bot
34d115b481 Localisation updates from https://translatewiki.net.
Change-Id: Ie1afc962d9fe56d72987f45c2433977028e0ab7e
2020-01-13 08:29:13 +01:00
James D. Forrester
0958a0bce4 Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull
Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
2020-01-10 14:17:13 -08:00
James D. Forrester
41f8acfd52 Coding style: Auto-fix MediaWiki.Commenting.DocComment.*
Change-Id: Iea5a07e10712723970a15008eb367e0af226fcc3
2020-01-10 12:28:12 -08:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
Translation updater bot
52a4a58beb Localisation updates from https://translatewiki.net.
Change-Id: I28c5d80048a974e8261e60cc1ba0540a57846016
2020-01-10 08:06:21 +01:00
jenkins-bot
5f477d7877 Merge "mw.Api: Add helper method #getErrorMessage" 2020-01-09 13:54:38 +00:00
jenkins-bot
091a882b77 Merge "Avoid master connections for prop=info and intestactionsdetail=full" 2020-01-07 20:56:02 +00:00
jenkins-bot
40576f59dd Merge "Sort user groups when shown in drop-downs" 2020-01-07 00:01:46 +00:00
jenkins-bot
b19a78a6c8 Merge "Add @phan-assert-false-condition to ApiBase::dieContinueUsageIf" 2020-01-06 10:39:13 +00:00
Translation updater bot
b49062f230 Localisation updates from https://translatewiki.net.
Change-Id: I458e42732c4bc50494aed763b6838ddb03e51227
2020-01-02 08:21:46 +01:00
jenkins-bot
cf92c2dc44 Merge "Use namespaced IPUtils class" 2020-01-01 23:56:22 +00:00
jenkins-bot
74aee4ed08 Merge "Use wikimedia/ip-utils 1.0.0 to replace IP class" 2020-01-01 23:55:38 +00:00
Kunal Mehta
99007e96c7 Use namespaced IPUtils class
Change-Id: I047e099a93203a59093946d336a143d899d0271f
2020-01-01 02:36:49 -08:00
James D. Forrester
610954eda6 Use wikimedia/ip-utils 1.0.0 to replace IP class
Adjust use in ApiBase.

Depends-On: I9a172b2bd922c3a62248545906bd9bdfcac03a43
Change-Id: Ie5485b1df9f3886add943ddcf8b0824e87a7f3e4
2020-01-01 02:29:11 -08:00
Daimona Eaytoy
dbf0990447 Avoid PHP scalar type juggling in includes/ (part 2)
Continuation of e5444ea55a.

Change-Id: I9f95e7de4e219dee3abcdd210bb708d949f378d0
2019-12-30 20:57:18 +00:00
jenkins-bot
ec52fd8d7c Merge "Allow null on ApiQueryBase::addTimestampWhereRange" 2019-12-29 20:01:40 +00:00
Thiemo Kreuz
c21b978408 api: Fix incomplete PHPDoc block in ApiBlockInfoTrait
The @see points to a totally different class – which is fine. But no
tool knows it is supposed to inherit the @return type from there.

Change-Id: I40cd0f329980553b7b5f03e8539ee80ca5f032b3
2019-12-29 11:40:01 +00:00
Translation updater bot
74c325e7c5 Localisation updates from https://translatewiki.net.
Change-Id: Ia9fc22a2e83f96eeb7255a73e42604c03a8c6a5d
2019-12-29 09:39:18 +01:00
Umherirrender
3ec00a7405 Allow null on ApiQueryBase::addTimestampWhereRange
Also add null to the underlying functions used here

Change-Id: I2e45fa449cf4c82d9a0e4323c4ac3ac2155bcadc
2019-12-28 22:20:48 +01:00
Translation updater bot
ad5de06421 Localisation updates from https://translatewiki.net.
Change-Id: Id91c9511e284fd3d1565b6bd752df9a9fa393bd8
2019-12-26 14:52:08 +01:00
jenkins-bot
c07ccc4fd3 Merge "ApiParse: Fix handling of pageid + redirects when passed a non-redirect" 2019-12-26 08:21:48 +00:00
Translation updater bot
5d0f3b1821 Localisation updates from https://translatewiki.net.
Change-Id: I30412a5f3948db301a86f63149d6c4beb93e80c4
2019-12-24 09:03:52 +01:00
Brad Jorsch
a2d2ccc8c5 ApiParse: Fix handling of pageid + redirects when passed a non-redirect
The setting of $pageParams in that code path was assuming the page was
specified by title, breaking when it was passed a pageid.

Bug: T241362
Change-Id: Ia5b34ee392c94e5ae7693e95b58806c1dac2b24e
2019-12-23 09:24:17 -05:00
Umherirrender
7dffd6a064 Add @phan-assert-false-condition to ApiBase::dieContinueUsageIf
@phan-assert-false-condition $x will make Phan infer that the argument
to parameter $x is falsey if the function returned successfully.

Change-Id: I928474e922980b2759fcc4252b1df21164297e0a
2019-12-22 22:58:16 +01:00
Translation updater bot
1521e3aafe Localisation updates from https://translatewiki.net.
Change-Id: Ic957e13b27f76976c2036abd6172a4bae2dea05a
2019-12-22 16:35:39 +01:00
Translation updater bot
2c3e8709c8 Localisation updates from https://translatewiki.net.
Change-Id: I169d57ca62250b81913c4e26f0fe00b15178c18a
2019-12-18 08:26:33 +01:00
Brad Jorsch
bba047c7ec API: Update docs on addWhere() and related methods
Change-Id: I189f0949e20b4e4ee130e3c7961635169853aeb4
2019-12-17 13:13:45 -05:00
Translation updater bot
c27126c6ca Localisation updates from https://translatewiki.net.
Change-Id: I29f9f2e57113b84d1f7c3053c62c9a11ed09ec55
2019-12-17 08:53:38 +01:00
jenkins-bot
e398253aba Merge "ApiEditPage: Fix error message for edit conflicts" 2019-12-16 18:01:06 +00:00
Brad Jorsch
605d3a3812 ApiQueryUserContribs: Stringify user names in query
Until I70473280, integer literals were always quoted as strings, because
the databases we support all have no problem with casting
string-literals for comparisons and such.

But it turned out that gave MySQL/MariaDB's planner problems in some
queries, so we changed it to not quote actual PHP integers.

But then we run into the fact that PHP associative arrays don't preserve
the types of keys, it converts integer-like strings into actual
integers. And when those are passed to the DB unquoted for comparison
with a string-typed column, MySQL/MariaDB screws up the comparison while
PostgreSQL simply throws an error. Sigh.

So ensure the user names passed to the database are actually strings.

Bug: T240808
Change-Id: If2bca6ab9faa5b50516e47f06b0b26b3648e4cbf
2019-12-16 09:10:13 -05:00
Translation updater bot
a0fcffb38b Localisation updates from https://translatewiki.net.
Change-Id: I829c1f93f7cf3274945c7b33cacd9044e8140bc9
2019-12-16 11:16:46 +01:00
Bartosz Dziewoński
7171488c71 mw.Api: Add helper method #getErrorMessage
Given an API response indicating an error, it returns a jQuery object
containing a human-readable error message that you can display
somewhere on the page.

Handling the "real" API responses from the server is easy, since they
already contain the error message and we basically just extract it.
The important part of this patch is handling the issues that happen
on the client, or server-side issues where the error-handling API
code never runs, so we have to figure out what happened and make up
our own error message.

I have not yet seen any mw.Api consumer that handles all the error
cases correctly (I thought VisualEditor did, but in the process of
writing this patch I learned that we missed a few cases there as
well), and most don't even try. This might not be perfect but it
should be the closest thing so far.

The new code is inspired by error handling in VisualEditor (see
I69d9432162f195dcfe9470485b549a1b007617ff) and in mw.Upload.BookletLayout.

New messages:
* 'api-clientside-error-noconnect'
  - Adapted from 'apierror-offline' and 'visualeditor-error-noconnect'
* 'api-clientside-error-http'
  - Adapted from 'visualeditor-loadwarning' and 'visualeditor-error-http'
* 'api-clientside-error-timeout'
  - Copied from 'apierror-timeout'
* 'api-clientside-error-aborted'
  - Entirely new
* 'api-clientside-error-invalidresponse'
  - Copied from 'visualeditor-error-invalidresponse'

Update some existing code to use it, as an example:
* mediawiki.page.watch.ajax
  - Removed messages: 'watcherrortext'
* mediawiki.special.unwatchedPages
  - Removed messages: 'watcherrortext'
* mediawiki.action.edit.preview
  - (errors were hardcoded in English)
* mediawiki.feedback
  - Removed messages: 'feedback-error2', 'feedback-error3'
    (error1 and error4 remain, they handle errors not caused by the API)
* mediawiki.Upload.BookletLayout
  - Removed messages: 'apierror-timeout', 'apierror-offline', 'apierror-unknownerror'
* mediawiki.page.ready
  - Removed messages: 'logout-failed'
* 'mediawiki.page.patrol.ajax
  - (the messages are already used by the patrol API)

Example usages in extensions:
* VisualEditor: I69d9432162f195dcfe9470485b549a1b007617ff
* DiscussionTools: Ice92fafb1f546510dab28e3f8aa7d2280668965a

Bug: T240519
Change-Id: Ie18666b41f4aff1ab4bcf93f9df6e3000ac7b500
2019-12-14 17:17:45 +01:00
jenkins-bot
980666d5c7 Merge "API: Deprecate wgEnableOpenSearchSuggest and opensearch+suggest parameter" 2019-12-13 18:26:04 +00:00
Timo Tijhof
15dbbe324c API: Deprecate wgEnableOpenSearchSuggest and opensearch+suggest parameter
The OpenSearch and prefixsearch APIs are always on for external use.

This internal parameter and feature flag was used as emergency switch
when the feature was still new, as a way to selectively ignore queries
from our own frontend code if we decided to turn the feature off.

At the time, there was also the $wgEnableMWSuggest configuration variable.
The idea being that if the JS is undeployed, it may still be cached in the
HTML and in some browsers. The $wgEnableOpenSearchSuggest variable allowed
the MW servers to identify those requests and return empty array without
any further DB load. Thus returning an empty array, which the frontend
at the time (mwsuggest.js) treated the same way visually as if the suggestion
feature didn't exist.

Since then:
* $wgEnableMWSuggest was removed in MediaWiki 1.20. The search suggestions
  in Vector and other skins are now always on.
* The "Disable search suggestions" user preference was removed
  in MediaWiki 1.23 (T54812).

Proposing to remove this additional complexity.

Change-Id: Iec572012de171d02871b8dc3207d2b34d17bf9ef
2019-12-13 18:11:43 +00:00
Bartosz Dziewoński
88a723bd87 ApiEditPage: Fix error message for edit conflicts
The 'editconflict' message is used by the normal edit form, and it
expects a parameter (page name), which was never passed.
'edit-conflict' should have been used instead.

This doesn't change the error code, which is mapped in ApiMessageTrait
and it already has a case for 'edit-conflict'/'editconflict'.

Change-Id: Ic95af27a67b95310b27ec344503d0a5cd88d79a2
2019-12-13 15:46:41 +01:00
jenkins-bot
5a668b0791 Merge "Localisation updates from https://translatewiki.net." 2019-12-13 09:16:28 +00:00
jenkins-bot
cab00f54ab Merge "Return HtmlArmor for Search ResultSet snippets" 2019-12-13 08:27:35 +00:00
Translation updater bot
941eb7d95c Localisation updates from https://translatewiki.net.
Change-Id: I6201eac71c4fdcf08d50a9f414e0fad076516409
2019-12-13 08:32:12 +01:00
Erik Bernhardson
0c8289e5db Return HtmlArmor for Search ResultSet snippets
Passing around strings that are expected to be safe html and are
known to be based on user input is a fairly unsafe operation. Make
it harder to do the wrong thing by requiring HtmlArmor to be returned
from the ResultSet snippets. This does not address the snippets on
individual result objects as the api surface is larger and requires
more bc handling.

Change-Id: I76231d6fc53c4982eb4cd174d2e6a75eb2740497
2019-12-12 10:14:50 -08:00
Translation updater bot
e57586072b Localisation updates from https://translatewiki.net.
Change-Id: Ia61d116950005fa52703449a8406d8af4296bba5
2019-12-12 08:49:54 +01:00
Amir Sarabadani
de9b8ac318 Set default for ApiPageSet::mParams to empty array
Now we can do this given we are using php7, this would also fix some
errors in php 7.4

Bug: T239761
Change-Id: I78254afd16ec88e3bf2ffa4890b92275bd794596
2019-12-11 14:00:20 +01:00
jenkins-bot
9d8954a372 Merge "build: Upgrade phan to 0.9.0" 2019-12-09 16:15:27 +00:00
Daimona Eaytoy
ce0856b12f Fix more scalar types in docblocks
Change-Id: I574d4e261ab986e028c3ce26c4f0ec648b88a2ac
2019-12-08 17:59:08 +00:00
Daimona Eaytoy
598c4d7fcb build: Upgrade phan to 0.9.0
Scalar casts are still allowed (for now), because there's a huge amount
of false positives. Ditto for invalid array offsets.

Thoughts about the rest: luckily, many false positives with array offsets
have gone. Moreover, since *Internal issues are suppressed in the base
config, we can remove inline suppressions.

Unfortunately, there are a couple of new issues about array additions
with only false positives, because apparently they don't take
branches into account.

Change-Id: I5a3913c6e762f77bfdae55051a395fae95d1f841
2019-12-07 20:16:19 +00:00
Umherirrender
7286cf1c96 Avoid master connections for prop=info and intestactionsdetail=full
There is no security issue using RIGOR_FULL here, because the
information is not used to take an action. It is used for information to
the caller and the caller may not allow the action.
But even the caller allows the action, the action api code would check
permission with RIGOR_SECURE before doing the action.

Also use the constant to make clear which string is from api and which
one is from the PermissionManager

Bug: T239451
Change-Id: If182f0e967187704ba3fdd14592a0badff097571
2019-12-06 21:29:15 +01:00
Translation updater bot
90bbed0f12 Localisation updates from https://translatewiki.net.
Change-Id: Ic48076bba16ee063b6a034d87b29137599237a05
2019-12-06 08:37:38 +01:00
Translation updater bot
7f4f113158 Localisation updates from https://translatewiki.net.
Change-Id: Ie594819bdc46f38329c265a372453c9392bfef2f
2019-12-05 08:34:50 +01:00
jenkins-bot
f4489908ce Merge "Set visibility on ApiQueryImageInfo::getTransformCount" 2019-12-04 21:39:36 +00:00
jenkins-bot
fde4381fc0 Merge "Remove hacks for lack of index on rc_this_oldid" 2019-12-04 21:39:22 +00:00
Umherirrender
268ffea9a2 Set visibility on ApiQueryImageInfo::getTransformCount
Change-Id: I41a088963ffbf35a97617f224cd6b80e8ae5570d
2019-12-04 22:23:28 +01:00
Brad Jorsch
152376376e Remove hacks for lack of index on rc_this_oldid
In several places, we're including rc_timestamp or other fields in a
query selecting on rc_this_oldid because there was historically no index
on the column.

The needed index was created by I0ccfd26d and deployed by T202167, so
let's remove the hacks.

Bug: T139012
Bug: T239772
Change-Id: Ic99760075bde6603c9f2ab3ee262f5a2878205c7
2019-12-04 16:00:02 -05:00
Brad Jorsch
9084591e10 ApiEditPage: Test for bad redirect targets
Apparently everything downstream assumes callers already handled
interwiki titles.

Bug: T239428
Change-Id: Ie54f366986056c876eade0fcad6c41f70b8b8de8
2019-12-04 19:22:41 +00:00
jenkins-bot
5afbc90670 Merge "Add 'slot' param for recentchanges API query" 2019-12-03 20:51:23 +00:00
jenkins-bot
dce7e7c384 Merge "Remove duplicate variable name from class property PHPDocs" 2019-12-02 16:09:39 +00:00
Thiemo Kreuz
78ca9eff4a Remove duplicate variable name from class property PHPDocs
Repeating the variable name doesn't do anything. Documentation
generators don't need it. It's more stuff to read that doesn't add new
information. And it can become outdated.

Note there are two types of @var docs. When used inline (and not on a
class property) the variable name is needed.

Change-Id: If5a520405efacd8cefd90b878c999b842b91ac61
2019-12-02 12:58:29 +00:00
Translation updater bot
b2882643d1 Localisation updates from https://translatewiki.net.
Change-Id: Ie325806ed14ea7cc82552a863c9ee33da1ed9809
2019-12-02 08:29:24 +01:00
Translation updater bot
5950111f24 Localisation updates from https://translatewiki.net.
Change-Id: I99982b02b1f7d3e945ab059b169b6afe06a83f19
2019-11-29 08:33:21 +01:00
jenkins-bot
af4b49e67c Merge "Improve param docs" 2019-11-28 19:36:24 +00:00
Umherirrender
c7ad21c25f Improve param docs
Change-Id: I746a69f6ed01c3ff000da125457df62b02d13b34
2019-11-28 19:08:59 +01:00
Translation updater bot
23548f48c5 Localisation updates from https://translatewiki.net.
Change-Id: I2798fdf3fd5cfaf2b5042200813abba8ea54c985
2019-11-27 08:27:39 +01:00
jenkins-bot
7731054ab7 Merge "Don't fail hard on bad titles in the database." 2019-11-26 18:31:34 +00:00
Translation updater bot
cf08ef5183 Localisation updates from https://translatewiki.net.
Change-Id: I50d2ab28a3eca0f5517745ddc7688a6d7714eeb4
2019-11-26 08:29:54 +01:00
daniel
e98094956a Don't fail hard on bad titles in the database.
This updates some code that has been constructing TitleValue directly
to use TitleValue::tryNew or TitleParser::makeTitleValueSafe.

Bug: T200055
Change-Id: If781fe62213413c8fb847fd9e90f079e2f9ffc9d
2019-11-25 22:15:38 +01:00
Cormac Parle
b4c7426a3f Add 'slot' param for recentchanges API query
Pass 'rcslot' as a param for the recent changes API to
only get changes (incl. reverts) for the specified slot

Bug: T230862
Change-Id: Iae53b1b22515116c61318ebe5ad3550c45554484
2019-11-25 12:54:47 +00:00
Translation updater bot
25b59c3c0e Localisation updates from https://translatewiki.net.
Change-Id: I89aec62c5ae5d945159473ae717457f7cbd33b31
2019-11-19 08:45:43 +01:00
Translation updater bot
441f354bcc Localisation updates from https://translatewiki.net.
Change-Id: If829f3e0fe1cd7abdc7aa7f287be29676ece74e9
2019-11-15 08:30:33 +01:00
Translation updater bot
30e46b8d66 Localisation updates from https://translatewiki.net.
Change-Id: Idb3b3f0bb759a85f90ed575e25f151cf6df12d82
2019-11-14 08:53:55 +01:00
Umherirrender
b1a38362f3 Add missing @param and @return to documentation
Using @see is not enough description

Enable the php sniffs for now, but skip /tests/ to fix it later.
That avoids new issues in future patch sets

Change-Id: I49cb341a2880bfaeefb6bbfbb1717051ea3a4b16
2019-11-13 17:26:55 +01:00
Translation updater bot
f3249dcd0b Localisation updates from https://translatewiki.net.
Change-Id: I4e3204d60606c2823113963e5aef15f8a68f97a5
2019-11-13 08:36:02 +01:00
brendajerop
1e06cd907d Modify apihelp to include info about revision deleted parameters
Currently apihelp doesn't mention that if you query information
about revisions, e.g a user that made a certain revision,
the response will be "userhidden". This commit includes that information
in modules API:Revisions, API:AllRevisions, API:DeletedRevisions,
API:RecentChanges, API:UserContribs, API:Watchlist, API:ImageInfo
and API:Compare.

Bug: T186573
Change-Id: I579f0d8c8183d5b158b9d3c9d6ae58e99984e58c
2019-11-12 11:03:53 +00:00
Translation updater bot
4b904fb748 Localisation updates from https://translatewiki.net.
Change-Id: I14de989fb271a662391b6aefc9c0fb210538664b
2019-11-12 08:42:42 +01:00
Translation updater bot
6ac295cea5 Localisation updates from https://translatewiki.net.
Change-Id: I102cbade8fd2c9a95a11ace51dd85f7b966a0d97
2019-11-11 08:32:49 +01:00
Translation updater bot
e7004b6265 Localisation updates from https://translatewiki.net.
Change-Id: Iac79ee30be4bbf49e210a5c62be1ab8d9524338d
2019-11-07 08:45:03 +01:00
jenkins-bot
1876680167 Merge "Run GenderCache for api query modules using ApiQueryBase::addTitleInfo" 2019-11-05 21:07:15 +00:00
jenkins-bot
ee2751a70b Merge "Minor cleanups" 2019-11-05 10:46:25 +00:00
Translation updater bot
7a6d613e5e Localisation updates from https://translatewiki.net.
Change-Id: If7d6cec7d6a75e8c04e53b7f774a763122e7e387
2019-11-05 08:56:10 +01:00
Translation updater bot
c2b28f0ca6 Localisation updates from https://translatewiki.net.
Change-Id: I28c7bc0628f506644aade0cb708142dc5a2b9c96
2019-11-04 08:32:07 +01:00
Max Semenik
f1c9cf8879 Minor cleanups
* Identifier case
* Returning a void function result
* Unused variable
* Missing documentation

Change-Id: Ibfd2fc5ae1d91c7c9c6a34bcd4523384d3bca576
2019-11-03 17:10:23 -08:00
Umherirrender
731d9f748e Run GenderCache for api query modules using ApiQueryBase::addTitleInfo
When converting a Title object into a string for user or user talk
namespace the gender information are needed.

This patch set improves performance on wikis with gender distinction
like dewiki or ruwiki by combining the fetch of the information into one
query and avoids a query per unique user name.
It also avoids false results for request with apihighlimit, because the
apihighlimit with 5000 is higher than the query max limit of the
GenderCache with 1000

Bug: T200238
Change-Id: Ibe0561b210dbeb654117dad777e839640f51b4e4
2019-11-02 22:23:23 +01:00
jenkins-bot
2ee984df73 Merge "Clean up the grammar of api/i18n/en.json" 2019-11-02 20:17:39 +00:00
jenkins-bot
733dc6b639 Merge "Hard deprecate User::isEveryoneAllowed" 2019-10-31 18:32:36 +00:00
Petr Pchelko
e4b7fc3570 Hard deprecate User::isEveryoneAllowed
The method was soft-deprecated in 1.34. It's not used in any WMF
installed extensions or the tarball, so it can be hard deprecated.

Bug: T220191
Change-Id: I2f48d62a8dd3592918a6197168d31a1e08bd2a3e
2019-10-30 11:17:19 -07:00
Translation updater bot
906ac1645e Localisation updates from https://translatewiki.net.
Change-Id: Ie17a0bbfda92e4af81187e113dded1c88f906f14
2019-10-30 08:29:33 +01:00
jenkins-bot
17b931caf6 Merge "Remove Language::factory and getParentLanguage use" 2019-10-29 09:25:29 +00:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Translation updater bot
96105e2758 Localisation updates from https://translatewiki.net.
Change-Id: I8d859670eeef2b875ef77ffa270b81bebcd41469
2019-10-25 08:36:18 +02:00
DannyS712
93554568bb Emit namespace for titles in ApiWatch
Bug: T235477
Change-Id: Ib7a1e6c727f8c7d04b5b0b41ed385d451f25f611
2019-10-24 15:26:34 +00:00
Daimona Eaytoy
b5f0d61ee4 Fix new phan errors, part 8
Bug: T231636
Change-Id: I61852ba55362ab9ae8cc8c1ab6b27565ce1d08e7
2019-10-22 10:09:13 +02:00
Translation updater bot
c35f3851e9 Localisation updates from https://translatewiki.net.
Change-Id: Idb5a6ddf8555c2d2d84fb3ce22d72b145aaff57c
2019-10-21 08:57:37 +02:00
Tchanders
a6533885b8 Revert "Revert "Store block reasons as CommentStoreComments in block classes""
This reverts commit 5f06efb318, which
reverted 9335363789, which makes
the deprecated property AbstractBlock::mReason private.

After 9335363789, AbstractBlock::mReason is obsolete, since the block
reason is now stored as a CommentStoreComment, AbstractBlock::reason.

Change-Id: Ica0a74be90383689ca8e4cfe6d0fb25c9a5942c5
2019-10-20 10:41:17 +01:00
jenkins-bot
78a2b8f485 Merge "Fix new phan errors, part 5" 2019-10-20 01:39:44 +00:00
Daimona Eaytoy
5f06efb318 Revert "Store block reasons as CommentStoreComments in block classes"
This reverts commit 9335363789.

Reason for revert: It's full of code accessing AbstractBlock::mReason
out there, see [1]. Also, it was never hard deprecated. While that may
be acceptable under some circumstances, it's definitely not OK to remove
code when there are consumers around. I'd have fixed it right now without
reverting if it were a single repo, but there's just too many.

[1] - https://codesearch.wmflabs.org/search/?q=-%3EmReason&i=nope&files=&repos=

Change-Id: I8669f502b50cff89e28dada0f65fe2b130ae9b37
2019-10-19 18:55:45 +00:00
Thalia
9335363789
Store block reasons as CommentStoreComments in block classes
AbstractBlock::setReason now accepts a string, Message or
CommentStoreComment. The CommentStoreComment is accessed via
AbstractBlock::getReasonComment.

AbstractBlock::getReason returns the reason as a string, with
the language and format consistent with how block reasons were
built before this commit. This method is deprecated, since it
makes assumptions about the language and format needed. The
deprecated mReason property is no longer public.

Doing this (and T227005) will remove the implicit dependency of
BlockManager::getUserBlock on language, which causes a recursion
error if the block is checked before the user has loaded. It also
provides a mechanism for getting the block reason in a language
specified by the caller. (This does not apply to DatabaseBlock
reasons entered via the Special:Block form, which were not and
are still not translatable.)

This commit also updates authentication classes to return the
translated reason.

Bug: T227007
Change-Id: Iec36876e930dff96a256aebbdc39cbfb331c244e
2019-10-18 17:47:56 -04:00
Daimona Eaytoy
d3252fc870 Fix new phan errors, part 5
Some of the errors are suppressed because they're phan false positives.
The idea behind this is that they'll be fixed in a future version of
phan, and we'll just have to remove the suppressions.

Note: I'm disabling UnusedPluginSuppression so that we can start suppressing
issues even if they're still disabled. The sniff should be re-enabled
as soon as we upgrade phan.

Bug: T231636
Change-Id: I0f7fa06a9e03fbb86c7a5eb6e50a850bb258a7f7
2019-10-18 20:45:53 +00:00
jenkins-bot
97d3794c4c Merge "Set constant visibility, part 1" 2019-10-18 03:36:59 +00:00
Max Semenik
bdf7e3f5bd Set constant visibility, part 1
Change-Id: I3dad26b1a0bd469fa84fee5c15d9b581765ceb94
2019-10-18 02:19:24 +00:00
jenkins-bot
7a9fbd750d Merge "Remove deprecated method ApiQueryUserInfo::getBlockInfo" 2019-10-17 15:19:36 +00:00
Translation updater bot
85e6921b30 Localisation updates from https://translatewiki.net.
Change-Id: Id36d38444930ffaa87ea800fdee3909a270cfd77
2019-10-17 09:03:39 +02:00
Thalia
7bbda9811b Remove deprecated method ApiQueryUserInfo::getBlockInfo
Change-Id: Ib291a7893cde780c3505f7cd499e222410e0efa9
2019-10-16 20:46:02 +01:00
Translation updater bot
15f367f214 Localisation updates from https://translatewiki.net.
Change-Id: Ib484474be1a89fab734a388788caea9e83a446a2
2019-10-16 09:20:26 +02:00
Umherirrender
f5d0ecce94 Run executeGenderCacheFromResultWrapper with titles in prop=linkshere
The gender information are only needed when outputting titles,
in other cases (when only pageids are selected) it results in a
undefined property

Bug: T235316
Follow-Up: I911dcb160a7b169091b9e8f66fb3908d0f2a1ba4
Change-Id: I5c9a501919914afd38343551c755126c98d457e6
2019-10-12 10:40:22 +02:00
Umherirrender
c722875c07 Use real varargs in ApiBase class
Change-Id: I7419fc690c5291ad511b67f4ab6e96afde480238
2019-10-11 20:11:59 +02:00
jenkins-bot
3440ae000c Merge "build: Upgrade mediawiki-codesniffer from 26.0.0 to 28.0.0" 2019-10-11 17:39:08 +00:00
James D. Forrester
9be9e77b51 build: Upgrade mediawiki-codesniffer from 26.0.0 to 28.0.0
Newly-disabled general rules:
* MediaWiki.Commenting.FunctionComment.MissingSplatVariadicArg
* MediaWiki.Commenting.FunctionComment.SuperfluousVariadicArgComment
* MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedException
* MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedExceptionMessage
* MediaWiki.Commenting.PhpunitAnnotations.ForbiddenExpectedExceptionMessageRegExp
* MediaWiki.Usage.NullableType.PHP71NullableStyle
* MediaWiki.Usage.PHPUnitTypeHints.MissingTypehint
* PSR12.Files.ImportStatement.LeadingSlash
* PSR12.Properties.ConstantVisibility.NotFound

Change-Id: Ifcf8c6d5fecc47a32741114b5a5b746a41510045
2019-10-11 10:05:43 -07:00
jenkins-bot
cd7972620f Merge "Fix new phan errors, part 1" 2019-10-11 16:26:48 +00:00
Daimona Eaytoy
cae0110e5a Fix new phan errors, part 1
First part, mostly doc-only.

Bug: T231636
Change-Id: Id59f585740fa5bfb53c257287121f51a30de38fe
2019-10-11 15:04:04 +00:00
jenkins-bot
66d647b893 Merge "Highlight internal modules in API help and sandbox" 2019-10-11 14:48:01 +00:00
Lucas Werkmeister
3983e1af46 Highlight internal modules in API help and sandbox
This mostly mirrors the existing handling for deprecated modules. In
lists, internal modules are ordered after deprecated ones, with
deprecated internal modules at the very end.

action=paraminfo gains an array of internalvalues analogous to
deprecatedvalues. Help messages for internal modules are prefixed with
the text “Internal”. The help page and API sandbox styles color internal
values in red, just like deprecated values (and matching the existing
style for the “this module is internal or unstable” warning in the help
page), but do not add a strikethrough.

Bug: T185508
Change-Id: I5dfc3bacbc070d74f467eb1a4042cab159aa28ec
2019-10-11 16:30:16 +02:00
jenkins-bot
b04f47a614 Merge "Unsuppress PhanParamsTooMany" 2019-10-10 21:10:20 +00:00
jenkins-bot
6dbb5748fd Merge "Check and add block cookie to every uncached API request" 2019-10-10 20:48:13 +00:00
David Barratt
20fb3632cd
Check and add block cookie to every uncached API request
The cleanest way to add the block cookie is to check for the users block when
the Caching headers are being added to the request. This prevents side effects
when checking for blocks and also prevents extensions from having to be aware
of block cookies.

Bug: T196575
Change-Id: I4f8de725e4be616e41d842f09f6144518237bbd5
2019-10-10 15:55:20 -04:00
Daimona Eaytoy
69cadf44a9 Unsuppress PhanParamsTooMany
This is the last repo-wide suppressed issue. Hurrah.

Bug: T231636
Change-Id: I3dc939f115bea14848c9c40bc52a7601f86ca0a7
2019-10-10 12:44:08 -07:00
jenkins-bot
59e351fb7b Merge "Avoid extra Title::newFromId calls in api modules with revisions" 2019-10-10 19:29:56 +00:00
Umherirrender
18a4584d17 Avoid extra Title::newFromId calls in api modules with revisions
The query for revisions include fields from the page table,
so use it with Title::newFromRow and pass it to the revision store.
If missing the revision store is using Title::newFromId for each row

For prop=revisions the page must always selected

Change-Id: I31d85bcdcfcd29892e91bf4fe1d7ec27bd61e593
2019-10-10 19:14:19 +00:00
Daimona Eaytoy
e3412efac3 Unsuppress PhanParamReqAfterOpt, use PHP71 nullable types
These were all checked with codesearch to ensure nothing is overriding
these methods.
For the most part, I've updated the signature to use nullable types; for
two Pager's, I've just made all parameters non-optional, because you're
already forced to pass them with a required parameter at the end.

Bug: T231636
Change-Id: Ie047891f55fcd322039194cfa9a8549e4f1f6f14
2019-10-10 11:53:58 +02:00
Translation updater bot
d39a05a302 Localisation updates from https://translatewiki.net.
Change-Id: I4a93ff7dcabd36cfff0aa9989474140e52147668
2019-10-10 08:28:40 +02:00
Daimona Eaytoy
19cd15f7cd Fix some phan warnings for too many params (part 1)
Bug: T231636
Change-Id: Ib0ca6bf2c426c21c4d42944c53a219e5940a5f11
2019-10-10 04:44:53 +00:00
jenkins-bot
85f022b7eb Merge "Export $wgMainPageIsDomainRoot in siteinfo API" 2019-10-09 16:17:19 +00:00
Translation updater bot
155e41c770 Localisation updates from https://translatewiki.net.
Change-Id: If1db2d48a1623bf74ce84db433005c58b78c23a9
2019-10-09 08:28:48 +02:00
Lucas Werkmeister
4adc557efa Clarify description of action=purge parameters
forcelinkupdate and forcerecursivelinkupdate are not limited to links
updates – content handlers can register arbitrary other secondary data
updates to perform.

(Both parameters also immediately update the parser cache for the
canonical parser options, but this does not seem worth mentioning.)

Change-Id: I5f3c8d1c22a08fee816121374620f207698c2715
2019-10-08 19:15:51 +02:00
C. Scott Ananian
315a859b53 Export $wgMainPageIsDomainRoot in siteinfo API
Follow up to a5deeac58c.

Bug: T120085
Change-Id: I58bfc55362fb8da7f22891ce0f57aa4996c51b16
2019-10-04 17:23:57 -04:00
Thalia
3722d0426d Document 'blockpartial' in ApiBlockInfoTrait::getBlockDetails
Change-Id: I734606446ef2edf90f4051f90d1889dc8158d0f2
2019-10-03 18:45:58 +01:00
James D. Forrester
b995fdcbb0 HHVM removal: Drop HHVM version data in ApiQuerySiteInfo
Change-Id: I985a1140c1f16acc8ba400f078e2d148dba3e8e8
2019-10-02 17:06:56 -07:00
James D. Forrester
d3473aca47 HHVM removal: Drop HHVM code path for Exception not Throwable in API code
Change-Id: I8c7e9bc35e4f415fa04199049313253a576846cf
2019-10-02 17:06:56 -07:00
jenkins-bot
599ab27c66 Merge "Turn PasswordReset into a service" 2019-10-02 21:41:43 +00:00
Translation updater bot
9937927433 Localisation updates from https://translatewiki.net.
Change-Id: Iabb74d9efdb7b75149b8affd05041eeb4a5ee03b
2019-10-02 08:22:47 +02:00
Max Semenik
631f56c576 Turn PasswordReset into a service
My team has plans to work in this area, better make it more testable.

Bug: T232694
Change-Id: I200874ec10db69378ada1743b2a7953b3fa01e3e
2019-10-01 14:42:18 -07:00
Translation updater bot
1be39cb1aa Localisation updates from https://translatewiki.net.
Change-Id: I2ff71393f57b3c397dae4e63d9607dcd1807343e
2019-09-30 08:31:33 +02:00
jenkins-bot
925dcce960 Merge "API: Use ConvertibleTimestamp::setFakeTime for testing curtimestamp" 2019-09-27 12:01:55 +00:00
Translation updater bot
dfa75cf7ff Localisation updates from https://translatewiki.net.
Change-Id: Ic52edc08609d9b9d03b7173ae43810f0dad140c1
2019-09-27 08:24:47 +02:00
jenkins-bot
1175152a9f Merge "Fill GenderCache for used pages in action=query&prop=fileusage" 2019-09-26 17:03:04 +00:00
Brad Jorsch
995aad376a API: Use ConvertibleTimestamp::setFakeTime for testing curtimestamp
Mainly to avoid spurious test failures when CI is being extremely slow.

Bug: T233752
Change-Id: Ie2cdd84dc076a852fbdce52f661ef893f9a2d45b
2019-09-26 12:35:00 -04:00
Umherirrender
a8525d7201 Fill GenderCache for used pages in action=query&prop=fileusage
Add an utility function
ApiQueryBase::executeGenderCacheFromResultWrapper

GenderCache stops working when there are more than 1000 cache missed
and returning the default value (T200238)
Fill the cache with all needed users avoids this behaviour
and it saves one query per user page.

Change-Id: I911dcb160a7b169091b9e8f66fb3908d0f2a1ba4
2019-09-25 21:41:34 +02:00
Matěj Suchánek
75ff49a1ff Sort user groups when shown in drop-downs
This makes searching for them easier and makes their
order less arbitrary, especially when they are localized.
Replace one sort function wrongly chosen by me.

Change-Id: I231f28656333c5bf846bedfedb6ba5040a09f74e
2019-09-24 13:49:18 +02:00
Translation updater bot
0af10d0a1c Localisation updates from https://translatewiki.net.
Change-Id: I0c47f67f860aae41d794a2c4ec4d22527de83328
2019-09-23 08:24:36 +02:00
jenkins-bot
77f4ba1847 Merge "phan: Enable PhanTypeMismatchArgument issue" 2019-09-20 10:38:52 +00:00
Translation updater bot
b8d5b3b23a Localisation updates from https://translatewiki.net.
Change-Id: I66ff316a7d099f45e0cff71b7281117ea12a7db0
2019-09-20 08:22:19 +02:00
Umherirrender
268346e562 phan: Enable PhanTypeMismatchArgument issue
Bug: T231636
Depends-On: I5de4f8f32a47c3f41c990ffe2ebd091fc23d1a58
Change-Id: I34d65fe3ff1916f2af675f0b1f19641b0cdfadc0
2019-09-19 20:11:42 +02:00
jenkins-bot
7c2ad4cc23 Merge "Remove Revision::getRevisionText from ApiQueryDeletedrevs" 2019-09-19 16:47:51 +00:00
Petr Pchelko
9283760f34 Remove Revision::getRevisionText from ApiQueryDeletedrevs
This module is deprecated and is scheduled to be removed in T221869
but in order to unblock MCR work we can still remove the method call.

Bug: T198343
Change-Id: I4aed8aa0dedc7284925ce9ba48db71e6ca2db5f0
2019-09-19 08:43:55 -07:00
Translation updater bot
359df670e1 Localisation updates from https://translatewiki.net.
Change-Id: Ia5a76e28cc8a824370748cc719ad76dd7f9f0d02
2019-09-19 08:48:24 +02:00
Brad Jorsch
02d6dc2e4f API: Use ApiBlockInfoTrait in ApiQueryUsers and AllUsers
For efficient bulk querying, this means that
ApiQueryBase::showHiddenUsersAddBlockInfo() needs to return everything
needed by DatabaseBlock::newFromRow().

Since we're rewriting it anyway, we may as well also move
ApiQueryBase::showHiddenUsersAddBlockInfo() out into a trait of its own.

Bug: T232021
Change-Id: I9c5b17a232ecbfbffefc7e40608cf5684ce8a644
2019-09-18 19:44:01 +00:00
daniel
bdc6b4e378 LocalFile: avoid hard failures on non-existing files.
Some methods on LocalFile will fatal if called on a non-existing file.
ApiQueryImageInfo did not take that into account.

This patch changes LocalFile to avoid fatal errors, and ApiQueryImageInfo
to not try and report information on non-existing files.

NOTE: the modified code has NO test coverage! This should be fixed
before this patch is applied, or the patch needs to be thoroughly tested
manually.

Bug: T221812
Change-Id: I9b74545a393d1b7a25c8262d4fe37a6492bbc11e
2019-09-18 09:18:44 +00:00
Translation updater bot
629d8a2fe9 Localisation updates from https://translatewiki.net.
Change-Id: I5c4e2bd9d76c70622b408f870ac11af9739dad73
2019-09-17 08:23:10 +02:00
jenkins-bot
cfd56e52d9 Merge "Add namespace restrictions to meta=siteinfo&siprop=namespaces API result" 2019-09-16 22:47:52 +00:00
Translation updater bot
8def7a9fc3 Localisation updates from https://translatewiki.net.
Change-Id: Ic665f6f2f3f9ee34f2447d74e4c7c890b5ad0710
2019-09-16 09:08:56 +02:00
jenkins-bot
74da7f603f Merge "Update docblocks for methods potentially returning null" 2019-09-15 16:27:34 +00:00
Daimona Eaytoy
dddc912fd6 Update docblocks for methods potentially returning null
These were discovered by setting `null_casts_as_any_type` to true in
phan, and filtering by `PhanTypeMismatchReturnNullable`. Of course there
are others, some of which are false positives, but we cannot suppress
them now (or the UnusedSuppressionPlugin will complain).

Change-Id: Ia8443e575c22f47a6d8c63038f4e7ac36815fc27
2019-09-15 15:22:39 +00:00
Umherirrender
f74400487f phan: Disable enable_class_alias_support
It is enabled for b/c in extensions, but not needed in core

Change-Id: I51dca12be9c77049f77563d9bf0edd07928c2300
2019-09-15 08:26:52 +00:00
Daimona Eaytoy
3439c00073 Suppress PhanUndeclaredProperty for custom properties and phan bugs
And remove the issue from the exclusions list.

Bug: T231636
Change-Id: Iee73ddb554e354abe52d13dcfc453f9a15bb8877
2019-09-14 13:22:54 +00:00
Daimona Eaytoy
290ab29617 Declare dynamic properties
This is for classes with a single undeclared property - aside from
BlockManager: I3f51fd3579514b83b567dfe20926df2f0930dc85 removed the
declaration of $permissionManager without actually removing all uses.

Change-Id: Ic2a95f77071312041be6e0633ea9b5325e98de42
2019-09-14 15:21:26 +02:00
Timo Tijhof
c1ec8b95ab API: Add missing @ingroup API to a few Api-related classes
Bug: T232104
Change-Id: Iea6714bc2f77525d6e164df37ca8f453886e3ca8
2019-09-14 00:09:49 +01:00
Petr Pchelko
56c21d059c Remove usages of Title::get{Previous,Next}RevisionId
The methods were deprecated since 1.34.

Change-Id: Ib95ac1ba36a8ffd6b71ed67642d8abb2e3538bae
2019-09-13 09:49:13 -07:00
Translation updater bot
637ba6c7d0 Localisation updates from https://translatewiki.net.
Change-Id: Ieebc40ae9287950ee4ce61612e982d6e307bb2b3
2019-09-13 09:30:02 +02:00
DannyS712
c711cb207f Add namespace restrictions to meta=siteinfo&siprop=namespaces API result
Bug: T73952
Change-Id: I6b4484fa9170ce39953a37eae2ffb859118fd1e5
2019-09-12 16:40:12 +00:00
jenkins-bot
1af7f36b4f Merge "Replace usages of deprecated User::isAllowed. Step 2." 2019-09-12 12:33:03 +00:00
Translation updater bot
d57e20f41c Localisation updates from https://translatewiki.net.
Change-Id: Ie04c47bbaa02a23e152f48a35e62f0185054ef6b
2019-09-12 08:29:35 +02:00
Petr Pchelko
7b4eafda0d Replace usages of deprecated User::isAllowed. Step 2.
Bug: T220191
Depends-On: I509cd88355cfd0cc074f4135ec86399b4075f89f
Change-Id: I2341e6f1d108c92924620fba3c64ec090cb09918
2019-09-11 16:00:03 -07:00
jenkins-bot
1e2cce13ea Merge "Allow users who are partially blocked to delete revisions." 2019-09-11 08:24:11 +00:00
David Barratt
6b43064e5c Allow users who are partially blocked to delete revisions.
Currently, users who are partially blocked are prevented from deleting
revisions. The system should check to see if the user can edit the page.

Bug: T228486
Change-Id: Id08dfab9b0ebe9721d3552564ee9f9d1e1a4805a
2019-09-11 08:14:48 +01:00
jenkins-bot
5b8a12363d Merge "api: Make ApiQuery(All)DeletedRevisions accessible to everyone" 2019-09-10 19:55:28 +00:00
jenkins-bot
93f78d904d Merge "Fix property filter for ApiQueryStashImageInfo::getPropertyNames" 2019-09-10 19:55:22 +00:00
jenkins-bot
5a296a1113 Merge "Allow partially blocked users to tag unrelated revisions" 2019-09-10 19:00:47 +00:00
Umherirrender
0e4b763109 Fix property filter for ApiQueryStashImageInfo::getPropertyNames
The property filter in ApiQueryStashImageInfo was only applied on calls
from the class itself. The call from UploadBase does not applied the
filter and than after successful upload of a stashed file the attributes
like user or mediatype are shown, but empty and not needed.

Change-Id: I89b2a935bacea81b4c8807d7ee77021377c8635c
2019-09-10 18:14:49 +00:00
David Barratt
3224bdabc0
Allow partially blocked users to tag unrelated revisions
Currently, partially blocked users cannot add, modify, or remove tags from
revisions that they are not blocked from. This change allows them to modify
the tags on those pages.

Bug: T221444
Change-Id: I737ed82f9c5139b45922cb4ea9111b4fdc7c1c61
2019-09-10 11:54:05 -04:00
Translation updater bot
2831fc72e4 Localisation updates from https://translatewiki.net.
Change-Id: Ib122e0da175fc0a3c8ab85bc93c496ef4fb08ff9
2019-09-10 08:45:12 +02:00
jenkins-bot
6b89d180d9 Merge "Move callers away from Title::GAID_FOR_UPDATE" 2019-09-10 03:32:37 +00:00
Vincent Privat
9f58ae9d30 api: Make ApiQuery(All)DeletedRevisions accessible to everyone
Effectively removes the 'deletedhistory' requirement, as this API does
not expose more information than the public toolforge database replica.

Bug: T232389
Change-Id: I84dc138aa310b601423161d1140891d47f8c64d8
2019-09-09 22:58:05 +02:00
jenkins-bot
7f1b20d832 Merge "Mark passing non ObjectFactory spec to ApiModuleManager as deprecated" 2019-09-09 20:25:30 +00:00
jenkins-bot
5a451fd01b Merge "Fix use of GenderCache in ApiPageSet::processTitlesArray" 2019-09-09 20:20:13 +00:00
Aaron Schulz
a5c7fd0db2 Move callers away from Title::GAID_FOR_UPDATE
These callers just need to load some data from DB_MASTER.
Subsequent code needing that latest title data should also use the
required flags, rather than relying on flakey global cache state.

Change-Id: I53248ea4b5bf1cd953f956c41b8244831ec5ef04
2019-09-09 13:19:08 -07:00
mainframe98
7b2fb55711 Mark passing non ObjectFactory spec to ApiModuleManager as deprecated
With Iee04afc27283547dd68d6db93f44ac2e0ebf1258, passing both the $class
and $factory parameter is deprecated in favor of just passing an
ObjectFactory spec as the third parameter.

Change-Id: I7b04d82c9daba52f5dc5e6c528739336279c7550
2019-09-09 21:59:03 +02:00
Umherirrender
91fd689add Fix use of GenderCache in ApiPageSet::processTitlesArray
Title::getPrefixedText was called before the GenderCache was set up,
which lazy loads the cache for each title,
resulting in one query per user title

Splitted the foreach to fill the cache at a better location

Added a test for ApiPageSet to test that the gender cache is filled

Bug: T200238
Change-Id: I7972dd1bf3731a92328caab20e70d7b9b82c1f7c
2019-09-09 19:54:07 +00:00
jenkins-bot
ca3083c61e Merge "api: Update QueryFilearchive to provide information to everyone" 2019-09-09 19:29:48 +00:00
mainframe98
eb8823743c Use ObjectFactory to create API modules
This will allow constructing API modules that need services.

This overhauls some of the internals of the ApiModuleManager,
but the public interface remains unchanged.
The $class parameter of addModule, (now called $spec)
also allows passing an array with the spec of the module.
Note that this spec requires the attribute 'class' to be present,
even when 'factory' is specified. This is the same as before,
where $class was always required.

In a perfect DI world ObjectFactory would be injected into
ApiMain::__construct and ApiMain would pass that to its instance
of ApiModuleManager, but that is currently not possible, so for now
it is injected in ApiModuleManager by having ApiMain::__construct
call the service locator.

Bug: T222388
Change-Id: Iee04afc27283547dd68d6db93f44ac2e0ebf1258
2019-09-09 18:50:16 +00:00
Brad Jorsch
c29909e59f Mostly drop old pre-actor user schemas
This removes most of the pre-actor user and user_text columns, and the
$wgActorTableSchemaMigrationStage setting that used to determine
whether the columns were used.

rev_user and rev_user_text remain in the code, as on Wikimedia wikis the
revision table is too large to alter at this time. A future change will
combine that with the removal of rev_comment, rev_content_model, and
rev_content_format (and the addition of rev_comment_id and rev_actor).

ActorMigration's constructor continues to take a $stage parameter, and
continues to have the logic for handling it, for the benefit of
extensions that might need their own migration process. Code using
ActorMigration for accessing the core fields should be updated to use
the new actor fields directly. That will be done for in a followup.

Bug: T188327
Change-Id: Id35544b879af1cd708f3efd303fce8d9a1b9eb02
2019-09-09 11:38:36 -04:00
Translation updater bot
eee9f3b84f Localisation updates from https://translatewiki.net.
Change-Id: Ie7693a53321a045a50fca3d41b0c168717db7dd9
2019-09-09 08:27:07 +02:00
Fomafix
0477318014 API: Remove unused asignment to $titleProvided in ApiExpandTemplates
The variable $titleProvided is not used in the following code.

Change-Id: I879ecfb589616882ba7193943f843f9226277f3e
2019-09-08 03:46:13 +00:00
Daimona Eaytoy
23daef5c18 Remove dead properties
*LogPage::timestamp was introduced with r4919 back in 2004, and is unused
since then.
*ApiMain::mCommit was introduced in r33133, then removed in r33381 but that
line was forgotten.
*SpecialRecentChangesLinked::mResultEmpty was introduced in r36682, then 
removed at some point with this leftover.
*SpecialStatistics::hook, introduced in r54511 and unused since then.
*MergeMessageFileList::hasError introduced in Id4b16083435ef7f4fce31861c72889e664d07236
and removed in I3d9cf1d614dacaa91fb2092019ccf1d14d61ccab with a leftover

Change-Id: Ie15c148a3217ee8da62874840f3ef7739893f69e
2019-09-07 16:34:55 +00:00
Vincent Privat
4d2965cf72 api: Update QueryFilearchive to provide information to everyone
Wikimedia Commons needs the ability to quickly detect, given a SHA-1, if
a file has been previously uploaded but was deleted later. This is
currently not possible in an efficient manner because the fa_sha1
field of the public database replica is not indexed, and this API
requires the 'deletedhistory' user right.

Effectively removes the 'deletedhistory' requirement, as this API does
not expose more information than the public toolforge database replica.

Bug : T60993
Change-Id: I2e9e1d50b6db9fa17acaf14d0975b6e9145a411e
2019-09-06 22:21:58 +02:00
jenkins-bot
28d9e60182 Merge "Stop mangling $_GET and provide WebRequest::getQueryValuesOnly()" 2019-09-06 17:38:26 +00:00
Tim Starling
0c0676c34e Stop mangling $_GET and provide WebRequest::getQueryValuesOnly()
I doubt there was ever a good reason for mangling $_GET to add the
title, this was just b/c for the sake of b/c. It was formerly used in
core but that was so long ago that I doubt there was any usage in
extensions at the time. Now there is one usage of $_GET['title'] in an
unmaintained extension, but it was only added in 2017.

Also I added WebRequest::getQueryValuesOnly() which is an interface to
the unmodified $_GET. The motivation is allowing OAuth to work with the
REST API, since OAuth needs an unmangled view of $_GET for signature
generation. The Action API gets around the problem with a special hack
in interpolateTitle(), disabling it for the Action API only.

A review of callers of getQueryValues() suggests that many would
benefit from using getQueryValuesOnly() instead. But I only changed it for
callers in api.php and thumb.php since the effect of the change there is
certainly beneficial, whereas callers under index.php may possibly be using
the path parameters to construct self-links.

Rest\RequestFromGlobals uses $_GET directly, which means that this
change causes it to not return PathRouter matches as GET parameters
anymore.

Change-Id: Ic469577fae17c0b1ac69466df7bc9f03e61c74e3
2019-09-05 15:00:28 +10:00
jenkins-bot
209f2d220f Merge "Upgrade phan config to 0.7.1" 2019-09-04 16:21:12 +00:00
jenkins-bot
d4e0dbcf96 Merge "ApiBase: Always validate that 'limit' is numeric" 2019-09-04 15:15:43 +00:00
Daimona Eaytoy
b5cbb5ab3f Upgrade phan config to 0.7.1
This allows us to remove many suppressions for phan false positives.

Bug: T231636
Depends-On: I82a279e1f7b0fdefd3bb712e46c7d0665429d065
Change-Id: I5c251e9584a1ae9fb1577afcafb5001e0dcd41c7
2019-09-04 08:20:53 +00:00
Translation updater bot
39d5e7aa6e Localisation updates from https://translatewiki.net.
Change-Id: I1f3f259b07e4b7bd6ccd305af12fb8e9400a7407
2019-09-04 09:10:01 +02:00
Bartosz Dziewoński
a9199bf854 ApiBase: Always validate that 'limit' is numeric
Bug: T231582
Change-Id: I956d4d623bfeace1b542039283e04a970fd40121
2019-09-04 00:27:12 +02:00
jenkins-bot
31a987345d Merge "Better grouping for code adding elements to arrays" 2019-09-03 19:00:53 +00:00