Commit graph

6712 commits

Author SHA1 Message Date
Translation updater bot
8a16a35bd1 Localisation updates from https://translatewiki.net.
Change-Id: Ib7f360fdd6ed83c3b0b643a09af3592e2d776091
2020-07-22 08:25:11 +02:00
Translation updater bot
7fc1db3e76 Localisation updates from https://translatewiki.net.
Change-Id: I15e0bbb562ae3cea7474e48499a6d8490ce3cefa
2020-07-21 09:09:44 +02:00
Translation updater bot
7734929815 Localisation updates from https://translatewiki.net.
Change-Id: I984eec1d8974a2f4c818b5aa2f2bb29987036d22
2020-07-20 08:59:48 +02:00
Umherirrender
c74cfb7c46 Ensure return value is declared in api param info
Change-Id: I0259d576e60c2a3b577d446d9edf1c5f85843dd6
2020-07-17 23:02:01 +02:00
Translation updater bot
59aac0fd62 Localisation updates from https://translatewiki.net.
Change-Id: I23a388e326a9ef2faaa0657e4f88b7e74cd9fdd0
2020-07-17 08:27:41 +02:00
Translation updater bot
d09d90b362 Localisation updates from https://translatewiki.net.
Change-Id: I560c33260d4cb920165eaca3ff72f8420a83f3a2
2020-07-16 08:20:25 +02:00
Translation updater bot
2c7ec50bdb Localisation updates from https://translatewiki.net.
Change-Id: I6e6d193b3a4bafee578e602d94725e6e0acf17cf
2020-07-15 09:02:45 +02:00
jenkins-bot
28f0b2cfc8 Merge "EditPage: handle undoafter param properly" 2020-07-14 13:23:04 +00:00
jenkins-bot
e9ad97eead Merge "Add watchlist expiry support to applicable APIs" 2020-07-14 04:37:44 +00:00
MusikAnimal
6a898faed2 Add watchlist expiry support to applicable APIs
This introduces an ApiWatchlistTrait that refactors out common code
across APIs that allow you to watch pages. Some methods have been
migrated from ApiBase and changed completely, but codesearch suggests
they aren't being used outside the API modules in this patch.

Bug: T248512
Bug: T248514
Change-Id: Ia18627b9824dca81f44f0571e8420d89b7626cf6
2020-07-13 18:18:15 -04:00
jenkins-bot
a5f4732261 Merge "Replace "@stable for implementation" with "@stable to implement"" 2020-07-13 09:31:44 +00:00
jenkins-bot
39705eb311 Merge "Replace "@stable for subclassing" with "@stable to extend"" 2020-07-13 09:31:38 +00:00
jenkins-bot
0270990f0b Merge "Replace "@stable for calling" by "@stable to call"" 2020-07-13 09:27:04 +00:00
daniel
e6e0ad2472 Replace "@stable for implementation" with "@stable to implement"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: I17e5e92e24c708ffc846945a136347670a3a20c7
2020-07-13 11:05:49 +02:00
daniel
3c50afa46b Replace "@stable for subclassing" with "@stable to extend"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: Ie32c1b11b3d16ddfc0c83a757327d449ff80b2e4
2020-07-13 11:00:30 +02:00
daniel
f7116bb3a2 Replace "@stable for overriding" with "@stable to override"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: I5ffbb91882ecce2019ab644839eab5e8fb8a1c5f
2020-07-13 10:57:12 +02:00
daniel
272db6afde Replace "@stable for calling" by "@stable to call"
For compliance with the new version of the table interface policy
(T255803).

This patch was created by an automated search & replace operation
on the includes/ directory.

Bug: T257789
Change-Id: If560596f5e1e0a3da91afc36e656e7c27f040968
2020-07-13 08:55:28 +00:00
jenkins-bot
acf5e4e5b6 Merge "Validate name for async uploads" 2020-07-09 12:17:12 +00:00
Ostrzyciel
5bf2cf380b EditPage: handle undoafter param properly
This is to fix issues with reverts being marked incorrectly,
especially when using the undoafter param which, until this patch,
wasn't really supported.

Honestly, EditPage is such a mess that I'm not sure if this is good
or not, but I did a lot of manual testing and it seems to work fine.

WikiPage::doEditContent() now checks whether the provided original
revision really has the same content as the new revision. This was
previously the task of callers, but that doesn't make much sense to
me because:
* This task would fall on EditPage otherwise and it should be more
focused on the UI side of things, without too much worrying about
backend details.
* This would require adding another parameter to WikiPage::
doEditContent(), $undoAfterId. It would be only useful for multiple-
revision undos that are not top revisions. In all other cases it
would be the same as $originalRevId.
* An extra sanity check before applying the value to the PageUpdater
won't hurt. Who knows what crazy ideas extensions might have.

The test cases are almost identical to those written for
McrUndoAction, so I decided to group them in a single file.
This should cover most undo cases.

Bug: T256915
Change-Id: I78641b3de0a012af932ea38265b695362f1f8491
2020-07-08 21:46:04 +02:00
daniel
102c9573b3 Mark exceptions as @newable
Exceptions classes are nearly always value objects, and should in most
cases by newable.

Bug: T247862
Change-Id: I4faa8ec6ea8bc44086cfc8075b32d10eea61e9df
2020-07-08 17:51:38 +00:00
jenkins-bot
267a2f6125 Merge "Mark additional classes as newable for now." 2020-07-08 16:42:33 +00:00
daniel
128565505c Mark additional classes as newable for now.
The following glasses are marked as newable per the
Stable Interface Policy, even though logically, they should not be
newable. This is done for classes that are currently instantiated
by extensions, and lack an alternative.

A better way for obtaining an instance of these classes should be
created in the future. At that point, direct instantiation should
be deprecated and replaced.

- includes/ApiMain.php - needs factory
- includes/media/BitmapMetadataHandler.php - should become a stateless service or use handler pattern
- includes/GitInfo.php - should become a stateless service
- includes/logging/LogPage.php - should become a stateless service or use command pattern
- includes/logging/ManualLogEntry.php - should become a stateless service or use command pattern
- includes/poolcounter/PoolCounterWorkViaCallback.php - needs a factory
- includes/context/RequestContext.php - needs to be narrowed down, and should use a factory
- includes/search/SearchHighlighter.php - should have a factory
- includes/TitleArrayFromResult.php - should perhaps be part of TitleFactory
- includes/user/User.php - should at least get a factory method for anons
- includes/diff/Diff.php: needs a TextDiffGenerator service or a factory
- includes/EditPage.php: needs a factory

Bug: T247862
Change-Id: I033158e693c98630ee167d9528fc8c9936f978d4
2020-07-08 18:06:12 +02:00
daniel
948123e589 Mark API base classes as extensible
This marks API base classes as stable for extending per the
Stable Interface Policy.

Bug: T247862
Change-Id: I164192ba3d013d8bc98a8b9c6db10e3dd1e58b23
2020-07-08 14:14:54 +00:00
Translation updater bot
9bd02a03d3 Localisation updates from https://translatewiki.net.
Change-Id: I514f9c63d39cf4773db6c5b6405097e5c6835f81
2020-07-08 09:10:05 +02:00
daniel
442fb30ce1 Stability annotations for interfaces.
Per the Stable Interface Policy, PHP interfaces should not be
directly implemented by extensions, unless they are marked to be safe
for that purpose.

Bug: T247862
Change-Id: Idd5783b70fc00c03d57f5b1a887f0e47c4d7b146
2020-07-07 22:01:29 +00:00
jenkins-bot
35e26a8d0e Merge "Annotate newable classes" 2020-07-07 18:46:12 +00:00
Matthias Mullie
82458c0ce0 Validate name for async uploads
If we don't validate the name, we risk running into PHP
notices if the name turns out to be invalid: later code
will check the title for warnings (e.g. duplicate), but
that title will not exist (though it is assumed to be)

If we'd also validate the file, we'd end up running into
errors where the file being verified doesn't yet exist
(because it's being assembled in a background job)

Bug: T208539
Change-Id: I8e35fe54e8a6356b6670c2a5c88c3e97b0a3ba00
2020-07-07 16:06:12 +00:00
daniel
bd5c3d06a2 Annotate newable classes
This annotates classes that can safely be instantiated by
extensions, per the Stable Interface Policy.

Bug: T247862
Change-Id: Ia280f559874fc0750265ddeb7f831e65fd7d7d6a
2020-07-07 15:38:57 +02:00
Translation updater bot
0679746f33 Localisation updates from https://translatewiki.net.
Change-Id: I31794bf42efb85b1aa7ff977b9a90a59f87adf1a
2020-07-07 09:30:25 +02:00
Translation updater bot
7402801bcb Localisation updates from https://translatewiki.net.
Change-Id: Ia829a152081287e1ab43964e3cfa03044333e8d7
2020-07-06 09:47:51 +02:00
Translation updater bot
703ea43d86 Localisation updates from https://translatewiki.net.
Change-Id: I23392f116a48fadcb0f122ae0294cd594893a8a5
2020-07-02 08:38:45 +02:00
jenkins-bot
8b2f44b6e7 Merge "phan: Enable redundant_condition_detection" 2020-07-02 00:28:10 +00:00
Umherirrender
bc5cb7ae64 phan: Enable redundant_condition_detection
Remove duplicate casts
Suppress false positives

Bug: T248438
Change-Id: I2f89664a4bcd3b39b15e7cf850adda2f0c90ae6f
2020-07-01 20:13:07 +00:00
Translation updater bot
7a05e214a9 Localisation updates from https://translatewiki.net.
Change-Id: Ic639e8503a930d6faaa4645fe69f6fe374c2300c
2020-07-01 08:42:45 +02:00
jenkins-bot
95b5b72543 Merge "ApiQueryRevisions::getRollbackToken - pass RevisionRecord" 2020-07-01 03:44:11 +00:00
jenkins-bot
3d038f349b Merge "Introduce $wgForceHTTPS" 2020-07-01 00:12:02 +00:00
Translation updater bot
1913d1b4c5 Localisation updates from https://translatewiki.net.
Change-Id: Ie087e764d78e816e1ac37028dcbd0cd51443d295
2020-06-30 08:33:08 +02:00
Tim Starling
c75eef91bf Introduce $wgForceHTTPS
Add $wgForceHTTPS. When set to true:

* It makes the HTTP to HTTPS redirect unconditional and suppresses the
  forceHTTPS cookie.
* It makes session cookies be secure.
* In the Action API, it triggers the existing deprecation warning and
  avoids more expensive user/session checks.
* In login and signup, it suppresses the old hidden form fields for
  protocol switching.
* It hides the prefershttps user preference.

Other changes:

* Factor out the HTTPS redirect in MediaWiki::main() into
  maybeDoHttpsRedirect() and shouldDoHttpRedirect(). Improve
  documentation.
* User::requiresHTTPS() reflects $wgForceHTTPS whereas the Session
  concept of "force HTTPS" does not. The documentation of
  User::requiresHTTPS() says that it includes configuration, and
  retaining this definition was beneficial for some callers. Whereas
  Session::shouldForceHTTPS() was used fairly narrowly as the value
  of the forceHTTPS cookie, and injecting configuration into it is not
  so easy or beneficial, so I left it as it was, except for clarifying
  the documentation.
* Deprecate the following hooks: BeforeHttpsRedirect, UserRequiresHTTPS,
  CanIPUseHTTPS. No known extension uses them, and they're not compatible
  with the long-term goal of ending support for mixed-protocol wikis.
  BeforeHttpsRedirect was documented as unstable from its inception.
  CanIPUseHTTPS was a WMF config hack now superseded by GFOC's SNI
  sniffing.
* For tests which failed with $wgForceHTTPS=true, I mostly split the
  tests, testing each configuration value separately.
* Add ArrayUtils::cartesianProduct() as a helper for generating
  combinations of boolean options in the session tests.

Bug: T256095

Change-Id: Iefb5ba55af35350dfc7c050f9fb8f4e8a79751cb
2020-06-30 15:38:11 +10:00
jenkins-bot
0e3be14e45 Merge "Hook: Mark abortable=false hooks as void" 2020-06-25 06:49:24 +00:00
DannyS712
4de1be2eb0 ApiQueryRevisions::getRollbackToken - pass RevisionRecord
Not actually used, but need to deprecate passing Revision

Bug: T249561
Change-Id: Ic4ce2fce64a2f3c8a0c70490599be2022b9f8903
2020-06-25 03:38:06 +00:00
jenkins-bot
a4fd6ef060 Merge "Hard-deprecate UserGroupMembership methods replaced by manager" 2020-06-24 18:35:42 +00:00
jenkins-bot
e400c88027 Merge "WikiPage::commitRollback - also return a RevisionRecord" 2020-06-23 23:54:48 +00:00
Translation updater bot
ec76e14be6 Localisation updates from https://translatewiki.net.
Change-Id: I0cbc414f58f15cc4bfbc0ef277e68106b4b6fde4
2020-06-23 08:49:05 +02:00
jenkins-bot
a7dae830b3 Merge "Introduce wfDeprecatedMsg()" 2020-06-22 22:30:49 +00:00
Timo Tijhof
01f3efe4ff Hook: Mark abortable=false hooks as void
* Remove the mention of 'return true' being legal.
  This is only allowed for compat with code from before MW 1.21,
  when I added hook aborting as well as tolerance for null to
  be the same as true.

  Since then, there is no reason to return null or return true.
  For early returns, an explicitly void 'return;' should be used
  instead. Returning anything else like null/true serves no purpose
  other than to confuse the reader.

* Mark the interfaces as natively 'void' with return type hints.

  This means in core code that runs the hook, static analysis
  like Phan and in IDEs, it will be known that these onFoo()s
  never return a value, thus allowing them to detect if its
  return value is assigned or used in a conditional for any
  reason, which can be an easy mistake.

  It also means that in the future when extensions start using
  these interfaces in 'implements' statement, they will be
  required to mark their hooks as void.

  That migration is opt-in and still up ahead. This is not
  a breaking change even for all existing extensions where
  a return true/null may exist in an abortable hook since this
  only applies to code directly typed against the interface.
  The internal run() method doesn't care.

Change-Id: Ib79289bd486ac97cec492e72f9a8dee70cf2f6c2
2020-06-22 19:07:35 +00:00
Translation updater bot
6c579760b7 Localisation updates from https://translatewiki.net.
Change-Id: I88a918275744305a67113417be036edb31d1699e
2020-06-22 08:41:20 +02:00
Tim Starling
d459add63d Introduce wfDeprecatedMsg()
Deprecating something means to say something nasty about it, or to draw
its character into question. For example, "this function is lazy and good
for nothing". Deprecatory remarks by a developer are generally taken as a
warning that violence will soon be done against the function in question.
Other developers are thus warned to avoid associating with the deprecated
function.

However, since wfDeprecated() was introduced, it has become obvious that
the targets of deprecation are not limited to functions. Developers can
deprecate literally anything: a parameter, a return value, a file
format, Mondays, the concept of being, etc. wfDeprecated() requires
every deprecatory statement to begin with "use of", leading to some
awkward sentences. For example, one might say: "Use of your mouth to
cough without it being covered by your arm is deprecated since 2020."

So, introduce wfDeprecatedMsg(), which allows deprecation messages to be
specified in plain text, with the caller description being optionally
appended. Migrate incorrect or gramatically awkward uses of wfDeprecated()
to wfDeprecatedMsg().

Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
2020-06-22 14:34:39 +10:00
jenkins-bot
daff5b8e5a Merge "API: Use MediaWikiServices::getAuthManager in various Api classes" 2020-06-20 23:23:07 +00:00
Umherirrender
3d45f17398 API: Use MediaWikiServices::getAuthManager in various Api classes
Change-Id: I0af2e5fe91097077eeaf83027494065a0c1a6c04
2020-06-20 23:04:17 +00:00
DannyS712
fc04afa971 WikiPage::commitRollback - also return a RevisionRecord
Still need to return a Revision until 1.36, but the Revision returned
shouldn't be used in core

Bug: T251965
Change-Id: Ie227c9449da2da2fdf99d595c08e80a15a78f5d5
2020-06-20 09:40:16 +00:00