Commit graph

8767 commits

Author SHA1 Message Date
Thiemo Kreuz
e4b51a4aae Fix mismatching type hints in ChangesListSpecialPageTest
Some of these parameters are marked as optional and nullable,
but can never be null (the test would fail then), and are
never missing.

While I'm here I also add more strict type hints for
parameters and return types. Note this is only done in tests
and impossible to cause trouble in production.

Change-Id: I1c66325c97d5ea86d9822e789a36542faad1272b
2021-05-01 15:39:54 +00:00
James D. Forrester
64898405cb build: Upgrade mediawiki-codesniffer from v35.0.0 to v36.0.0
Change-Id: I8905d0d69738a1cd6997c104080fdf128d315e8b
2021-04-29 13:00:15 -07:00
jenkins-bot
23d5d441c9 Merge "Replace uses of DB_MASTER with DB_PRIMARY" 2021-04-29 19:04:17 +00:00
jenkins-bot
acb29985a2 Merge "Parser: remove Title from method signatures" 2021-04-29 18:28:28 +00:00
jenkins-bot
40a24ec274 Merge "RevisionStore: don't die on mismatching Titles" 2021-04-29 16:50:59 +00:00
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
daniel
4880a82555 Parser: remove Title from method signatures
Bug: T281068
Change-Id: I3280e38dd82d71845c343eeb911e71dd33bb380b
2021-04-29 18:11:46 +02:00
jenkins-bot
faade61437 Merge "Replace use of User::isWatched with WatchlistManager::isWatched" 2021-04-29 12:47:51 +00:00
jenkins-bot
5278aae042 Merge "Allow x-delete-at and x-delete-after expiry headers" 2021-04-29 07:41:35 +00:00
Cindy Cicalese
f1728cd6e9 Replace use of User::isWatched with WatchlistManager::isWatched
Change-Id: I67713c74f8beae9afd5210f7dff0f180c2cf691b
2021-04-28 18:59:41 -04:00
Daniel Kinzler
b4021ea484 Re-apply "PageProps: use PageIdentity instead of Title""
This re-applies I15cc5a64d7fcc3d09f9175a3ca8dd8180761f085
This reverts the revert in af71ce1864.

Reason for revert: should no longer fail with Title::assertProperPage no longer checking for fragments.

Change-Id: I60b8cd14c8304ad34a69e22b978fa476430a867c
2021-04-28 16:43:51 +00:00
jenkins-bot
9c269ae3b8 Merge "Add change tags for media additions/removals" 2021-04-28 15:13:34 +00:00
daniel
46e877d182 RevisionStore: don't die on mismatching Titles
When we find that a revision we loaded doesn't belong to the expected
title, log the error and continue, instead of failing hard.

This could happen if a caller to e.g. getRevisionById supplied a Title that is
plain wrong. In this case, we should ideally throw an IllegalArgumentException.
However, it is more likely that we encountered a race condition during a page
move (T268910, T279832) or database corruption (T263340). That situation
should not be ignored, but we can allow the request to continue in a reasonable
manner without breaking things for the user.

Note that this patch does not resolve the mentioend bugs. It only
reduces impact for users. We still need to find out when and why we are
gettign mismatching titles.

Bug: T259022
Bug: T268910
Bug: T263340
Bug: T279832
Change-Id: Ia64ad3b8a6e3c3348bc0a276d528ead127c6b0e0
2021-04-28 11:23:15 +02:00
Tim Starling
7c0c1ad9d0 In BlockListPager and ProtectedPagesPager use userLink() unconditionally
These two special pages showed the username in plain text if the user ID
is zero, avoiding a call to userLink and userToolLinks(). But those
functions actually have quite nice handling for zero user IDs, notably
interwiki links for external usernames.

So, just call userLink() and userToolLinks() always.

Change-Id: I62021464355127b32ccb388e7c29440fd19f490d
2021-04-28 16:29:04 +10:00
Tim Starling
44c76b8d9f Stop using legacy ActionMigration field "ipb_by"
Bug: T278917
Change-Id: I392b0bf23f23a2ca08664e4b49c9eeb26df348de
2021-04-28 16:29:04 +10:00
Tim Starling
83e184670c Stop using legacy ActorMigration field "log_user"
Bug: T278917
Change-Id: I1b78bad7e1fa43f5f82908567a7daad9c6cc79b9
2021-04-28 16:29:04 +10:00
Tim Starling
fd01c53778 Stop using legacy ActorMigration field "rc_user"
Bug: T278917
Change-Id: I4d6c175c637a2cb26c63e0b2b27d5ea8ce6b1e0d
2021-04-28 16:29:04 +10:00
jenkins-bot
aadbffb9ae Merge "rdbms: Move setLBFactoryTriggers from doMaintenance to service wiring" 2021-04-28 00:23:38 +00:00
jenkins-bot
a8196f5904 Merge "Introduce infrastructure for partial blocks for actions" 2021-04-27 23:57:33 +00:00
jenkins-bot
123a0e25e7 Merge "LinkBatch: replace Title with PageReference in method signatures" 2021-04-27 23:12:29 +00:00
Timo Tijhof
e9051b2b99 rdbms: Move setLBFactoryTriggers from doMaintenance to service wiring
This logic is not needed to run on every PHP process and was making
it difficult to run offline maintenance scripts without additional
complexity based on Maintenance::getDbType and DB_NONE.

Instead of skipping this only for DB_NONE, and establishing a pattern
that may spread to other ad-hoc places throughout the codebase, instead
remove this entirely from the eager set up code for all PHP processes
and move it to the service wiring and dependency injection.

That way, it naturally doesn't happen until and unless the DB service
is actually called upon. Scripts and entry point that need to disable
the DB service, can continue to use
MediaWikiServices::disableStorageBackend.

== Impact on SiteStatsUpdate ==

With wgCommandLineMode no longer being read at run-time from a global,
but in service wiring, this means SiteStatsUpdateTest can't change
the behaviour between CLI-like and Web-like, unless it e.g. resets
the 'DBLoadBalancerFactory' service first. Unfortunately, while most
any reset is supported, a reset of the 'DBLoadBalancerFactory' would
be unsupported as that would lose the temporary db clone context and
such, bringing us to either the developer's live db, or a broken set
up altogether. If there is a strong need for toggling oppertunistic
updates off and on at run-time, this could be supported in the
DeferredUpdates class perhaps, but we already have numerous methods
there (incl db begin/commit being a good proxy already), which this
test already used, so for now I've just removed the extra assertion
for this as it wasn't essential to that test.

Bug: T228895
Bug: T238436
Change-Id: Icf29bc484c155f52b6d8f61e5902233a15ba0c6d
2021-04-27 23:35:20 +01:00
Thalia
c67f181dd4 Introduce infrastructure for partial blocks for actions
This adds a new type of block restriction for actions, which extends
AbstractRestriction. Like page and namespace restrictions, action
restrictions are stored in the ipblocks_restrictions table.

Blockable actions are defined in a BlockActionInfo service, with a
method for getting all the blockable actions, getAllBlockActions.

Action blocks are checked for in PermissionManager::checkUserBlock
using DatabaseBlock::appliesToRight. To make this work, this patch
also removes the 'edit' case from AbstractBlock::appliesToRight,
which always returned true. This was incorrect, as blocks do not
always apply to edit, so cases that called appliesToRight('edit')
were fixed before this commit. appliesToRight('edit') now returns
null (i.e. unsure), which is correct because it is not possible to
determine whether a block applies to editing a particular page
without knowing what that page is, and appliesToRight doesn't know
that page.

There are some flags on sitewide blocks that predate partial blocks,
which block particular actions: 'createaccount' and 'sendemail'.
These are still handled in AbstractBlock::appliesToRight, and are
still checked for separately in the peripheral components.

The feature flag $wgEnablePartialActionBlocks must set to true to
enable partial action blocks.

Bug: T279556
Bug: T6995
Change-Id: I17962bb7c4247a12c722e7bc6bcaf8c36efd8600
2021-04-27 21:53:13 +01:00
jenkins-bot
1d7e23e460 Merge "Add script for resolving class names to files" 2021-04-27 14:45:17 +00:00
jenkins-bot
e2abc63ac6 Merge "RecentChange: replace Title in method signatures" 2021-04-26 22:24:57 +00:00
jenkins-bot
d47ece1e62 Merge "Move AuthManager::checkAccountCreatePermissions to Authority." 2021-04-26 21:53:51 +00:00
Petr Pchelko
1f9c3a4566 Move AuthManager::checkAccountCreatePermissions to Authority.
Change-Id: I8d223508ccec7122eef5e0bf136964ad65d64ab7
2021-04-26 14:14:43 -07:00
jenkins-bot
390abb8627 Merge "Revert "PageProps: use PageIdentity instead of Title"" 2021-04-26 21:00:15 +00:00
Gergő Tisza
af71ce1864 Revert "PageProps: use PageIdentity instead of Title"
This reverts commit 07d885248b.

Reason for revert: breaks tests in weird and unexpected ways

Bug: T279796
Bug: T281180
Change-Id: Iedc12256c8cd17498bcc12e184a12acbe5f2ac3b
2021-04-26 20:30:43 +00:00
daniel
c829bfc8dd LinkBatch: replace Title with PageReference in method signatures
Bug: T278459
Change-Id: I7ed97f868f2a8a505ca4e529036d7efce6eea3ae
2021-04-26 19:54:24 +02:00
jenkins-bot
bc46ba2de9 Merge "Hard deprecate User ::isIP, ::getOptions" 2021-04-26 17:06:00 +00:00
jenkins-bot
7c26a783d9 Merge "Regression tests for ApiRollback and RollbackAction" 2021-04-26 16:12:35 +00:00
vladshapik
9cc797695b Hard deprecate User ::isIP, ::getOptions
Bug: T275602
Change-Id: Id4be13751ca0a900e51214c1855a4624077a5a62
2021-04-26 16:10:24 +00:00
jenkins-bot
b1f51795bb Merge "PageProps: use PageIdentity instead of Title" 2021-04-26 16:07:54 +00:00
jenkins-bot
2d203cdb42 Merge "Implement injecting of dependencies to an AuthenticationProvider" 2021-04-26 16:04:25 +00:00
jenkins-bot
3380e6e468 Merge "Check for line breaks in user signatures" 2021-04-26 16:03:20 +00:00
daniel
c7eca76241 RecentChange: replace Title in method signatures
Bug: T278459
Change-Id: I144ea130f29ec437302649d86494034af044c524
2021-04-26 17:48:02 +02:00
kalle
a646366e7c Allow x-delete-at and x-delete-after expiry headers
From:
https://docs.openstack.org/swift/latest/overview_expiring_objects.html

The swift-object-expirer offers scheduled deletion of objects.
The Swift client would use the X-Delete-At or X-Delete-After
headers during an object PUT or POST and the cluster would
automatically quit serving that object at the specified time
and would shortly thereafter remove the object from the system.

Bug: T280496
Change-Id: I886f3cea51f80d820841f8548941ca02a0a514c3
2021-04-26 17:41:30 +02:00
Petr Pchelko
bf6d3c5cf3 Regression tests for ApiRollback and RollbackAction
Bug: T280655
Change-Id: I933b80bbe9bd33ffda68f9a5ab84424cb531abff
2021-04-26 07:58:44 -07:00
vladshapik
3a150275de Implement injecting of dependencies to an AuthenticationProvider
init() method was added to AuthenticationProvider. It helps to inject
dependecies. Overridable postInitSetup() method was added to
AbstractAuthenticationProvider. A provider can override this to do
any necessary setup.
AbstractAuthenticationProvider ::setLogger(), ::setManager(), ::setConfig(),
::setHookContainer() were soft deprecated. Now developers must use
AbstractAuthenticationProvider::init().

Bug: T275030
Change-Id: I6ca63eddac1b177eeadbdcce992e71c44a480160
2021-04-26 15:17:34 +03:00
jenkins-bot
6727f4eafc Merge "Create the content-links (and -external) ResourceLoaderSkinModule feature" 2021-04-26 10:26:10 +00:00
Matthias Mullie
dab7b16741 Add change tags for media additions/removals
This introduces 2 new tags to track changes in media usage
across articles. These tags are both hidden & disabled by
default.

Bug: T266067
Change-Id: Ia230eadf7dcf6f52facab17b92293f25de38bb1c
2021-04-26 12:22:21 +02:00
Tim Starling
a3b7ea6732 Stop using legacy ActorMigration fields img_user/oi_user/fa_user
Bug: T278917
Change-Id: If7dd7d2198bd79636fdfb8b5644fb7cd8ae2901f
2021-04-26 12:23:59 +10:00
daniel
07d885248b PageProps: use PageIdentity instead of Title
Bug: T279796
Change-Id: I15cc5a64d7fcc3d09f9175a3ca8dd8180761f085
2021-04-24 17:40:06 +02:00
jenkins-bot
5041330ec4 Merge "PageStoreTest: add missing parent::setUp() call" 2021-04-24 08:11:45 +00:00
jenkins-bot
0a62fb5ce8 Merge "NamespaceInfoTest: remove outdated comment about globals" 2021-04-24 08:07:48 +00:00
jenkins-bot
adb08649b9 Merge "Convert MWBasicRequestAuthorizerTest to a unit test" 2021-04-24 03:33:09 +00:00
jenkins-bot
68a6512ad3 Merge "Reduce mocking LoggerInterface" 2021-04-24 03:33:03 +00:00
jenkins-bot
d7dac1bf4a Merge "RevisionStoreFactoryTest: Clean up and convert to unit test" 2021-04-24 03:32:57 +00:00
jenkins-bot
758c0e03d9 Merge "ClassicInterwikiLookup: inject load balancer" 2021-04-24 03:12:35 +00:00
jenkins-bot
7ae12627a6 Merge "Convert SlotRoleRegistryTest to unit tests" 2021-04-24 03:07:56 +00:00