Commit graph

245 commits

Author SHA1 Message Date
Sam Smith
8b9fb65513 block: Stop passing list of blocks around by ref
Bug: T270318
Change-Id: I03a71964a12f3470ce68170f0bc6f669fc362929
2021-10-11 17:51:33 +01:00
Sam Smith
75808a6e31 block: Add BlockManager::getIPBlock()
The ::getIPBlock() method returns all current blocks affecting the IP
address.

Supporting changes:

* Extract ::getXffBlocks() from ::getAdditionalIpBlocks() and rename the
  latter to ::getSystemIpBlocks()

* Add ::getIpBlock(), which returns an AbstractBlock instance that
  represents all blocks affecting the IP, including range blocks and
  system blocks (using ::getSystemIpBlocks())

Additional changes:

* Update DocBlocks for all methods mentioned above

Bug: T270318
Change-Id: I2009c3a7143c10167461e1ce9d4b8efe81390ff6
2021-10-11 17:51:27 +01:00
Alexander Vorwerk
734b912d55 Only allow UserIdentity in DatabaseBlock::setBlocker()
Passing a string is deprecated since 1.36.

Change-Id: Ia1c5bde0815f860f8671e9acae73c69af0a0f96a
2021-10-04 14:03:29 +00:00
Roman Stolar
4af3d59f24 Remove DatabaseBlock 'byText' and 'by' with user ID
Bug: T283641
Change-Id: I5176b1cb388b9962baae3fb99ce8f677b614c4ae
2021-09-29 17:08:32 +03:00
Alexander Vorwerk
a622cf1229 Hard deprecate DatabaseBlock::purgeExpired()
Cleaning a bit up before doing some refactoring.

Soft-deprecated since 1.36 and unused.

Change-Id: I2c93049e6820afd446d284cf0ba756e26c2e50b3
2021-09-28 20:41:32 +00:00
Umherirrender
c7817fca44 docs: Remove wrong null types
Change-Id: I017ff1a7fea0119b2a864c5fefb002afa7535cad
2021-08-26 21:42:03 +02:00
Umherirrender
220fd020c4 Simplify if-then-else-return statements with explicit true/false
When both branches returns a bool, use the condition as return value

Change-Id: I59416aa021d0ada77d84fda4aaf7def0eea54009
2021-08-17 23:19:04 +02:00
jenkins-bot
a863646edd Merge "BlockUser: Restore blocking autoblocked IP addresses" 2021-08-11 13:22:32 +00:00
jenkins-bot
9ca808f577 Merge "Support fluent interface for StatusValue" 2021-08-11 04:23:17 +00:00
jenkins-bot
a7f8baa7bb Merge "BlockUser: Synchronize identical block retrieval" 2021-08-10 12:43:17 +00:00
jenkins-bot
d998eb09f4 Merge "BlockErrorFormatter: use Message::plain() if blocked without a reason" 2021-08-06 08:51:56 +00:00
Umherirrender
b4aa45f553 block: Use IDatabase::selectField in performRetroactiveAutoblock
Simplify database handling
No need for a loop, when known to have one entry

Change-Id: I5e53d5fee58fe1b885638d12419b96c0b60d5747
2021-08-06 01:02:47 +02:00
DannyS712
d8b69e2490 BlockErrorFormatter: use Message::plain() if blocked without a reason
Will make it easier to migrate away from using Message and use
MessageValue/TextFormatter if only a single type of formatting
is used - other messages in the class use plain() instead of text()

Change-Id: If2a7f5aa7aebedb2965ca6d3aa2b83d1b979bd37
2021-08-05 01:50:50 +00:00
Matěj Suchánek
1902efbcc7 BlockUser: Restore blocking autoblocked IP addresses
This seems to be a regression from 166ed5c.
DatabaseBlock::newFromTarget may return an autoblock for an IP
unless there is an existing manual block. If so, ignore it
because it is allowed to have an IP address both manually
blocked and autoblocked (see ipb_address_unique index).

Also add an integration test case.

Bug: T287798
Change-Id: I7c9a66ba0ffe759f43f4d0821c30fb94649d3dea
2021-08-03 14:49:41 +00:00
TChin
fa5d3dba51 Support fluent interface for StatusValue
Also refactored some calls to use it.

Bug: T287485
Change-Id: If9e96ce87dc3f3641e9b3ebe093f92d8fa49b9ee
2021-08-02 15:14:11 -04:00
Matěj Suchánek
b9fe32197f BlockUser: Synchronize identical block retrieval
Make both loads use primary. Deduplication is left
for a future refactoring.

Change-Id: I54431beae69fcdc7a2864ebb3e06f91240fa7a00
2021-08-01 09:36:12 +02:00
DannyS712
66d676f163 BlockErrorFormatter: clean up handling of link to blocker's user page
Current code fetches a User based on their id, and then retrieves
a Title object for that User's user page via User::getUserPage().
That Title object is then used to retrieve the text and prefixed text.

Instead, retrieve the UserIdentity from the block directly,
and then create the PageReference manually. Use TitleFormatter to retrieve
the text and prefixed text.

Change-Id: Ic44bfb882523595566031a0fd788be4f15ef19e9
2021-07-27 22:13:28 +00:00
jenkins-bot
96f08fa709 Merge "Convert AbstractBlock::$target to UserIdentity" 2021-07-27 15:30:20 +00:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
Alexander Vorwerk
96896bb0db Convert AbstractBlock::$target to UserIdentity
Change-Id: Ida1ad099e9716b55b64011f882fd5ca79ba9dd22
2021-07-21 22:40:17 +02:00
jenkins-bot
7a79548ac7 Merge "Convert BlockUtils::parseBlockTarget to UserIdentity" 2021-07-20 21:54:33 +00:00
Alexander Vorwerk
825ac0232c Convert BlockUtils::parseBlockTarget to UserIdentity
Bug: T286490
Change-Id: Ice96180690828bcf2efd60faf6ad10d64307713d
2021-07-20 22:12:26 +02:00
jenkins-bot
f838ad7a27 Merge "BlockUser: Provide correct information to the post-block hook" 2021-07-20 02:29:25 +00:00
Matěj Suchánek
166ed5cd95 BlockUser: Provide correct information to the post-block hook
Previously, BlockUser::placeBlockInternal attempted to insert
the new block with possible failure due to an existing block.
Regardless of the result, it would then retrieve the current
block which could be the just now inserted block. This one
was treated as the prior block and incorrectly provided to
the hook as such.

Refactor the method a little by retrieving the prior block
before attempting to insert a new one to make it more
efficient and to ensure the hook will have the correct value
for the prior block.

Change-Id: I70480ce32545f28f8317bb58f9c724d64cc54ccf
2021-07-17 12:26:14 +02:00
Alexander Vorwerk
bae3a25e6a Remove AbstractBlock::parseTarget()
deprecated since 1.36 and unused

Change-Id: I9d67d7f4294d175b536a518b2c89cd620773f7b9
2021-07-16 01:00:08 +02:00
daniel
b3b70624c9 Authority: expose user block info
Expose info about user blocks from Authority. This allows calling code
to provide more detailed information to the user about why they are
denied some action on the wiki.

Bug: T271494
Change-Id: Ia84e469888866d72752aad355292666c31e12bad
2021-06-30 13:42:21 +02:00
vladshapik
e991dff925 Hard-deprecate AbstractBlock::getTargetAndType() and getTarget()
Replace all uses of AbstractBlock::getTarget with
Block ::getTargetName and ::getTargetUserIdentity.
Create AbstractBlockTest and two test cases for
AbstractBlock::getTarget and ::getTargetAndType.
It tests triggering of the deprecation warning.

Bug: T282247
Depends-On: I0543f363af66c57f5763b91320d87a69f23f9466
Change-Id: Iaeca824cac30172178de72f3cf7b7ae4cdd6f880
2021-06-22 16:59:00 +03:00
Matěj Suchánek
90b47f0077 Fix deprecation warnings in DatabaseBlock
The admin should see what is deprecated, not the actual value provided.

Change-Id: Ie09d2124ea40ba460feff7cb846514a89587fac7
2021-06-04 15:44:59 +00:00
Roman Stolar
4613e36b97 Hard deprecated DatabaseBlock options 'byText' and 'by' with user ID
Bug: T283641
Change-Id: Id1444253b26605f4c68b4cbeb61dc2299ed8ac34
2021-06-04 17:33:48 +03:00
jenkins-bot
590874012a Merge "Make BlockManager::getUserBlock take UserIdentity" 2021-06-02 09:31:41 +00:00
jenkins-bot
28c34c539a Merge "Remove DatabaseBlock::forcedUserId feature" 2021-06-02 09:31:35 +00:00
DannyS712
f76d30ee83 UnblockUserFactory: document accepting UserIdentity
Implementation in UserBlockCommandFactory only needs
a UserIdentity, no need to document a full User object

Change-Id: I39dcb48bff9f5de8ff964f7ed8f9f2c7da4e4046
2021-05-29 03:52:43 +00:00
Petr Pchelko
47b1065bb8 Make BlockManager::getUserBlock take UserIdentity
Change-Id: Ifb405196fbe8e4809f05049bf4ab806d9ef29498
2021-05-26 19:29:47 -07:00
Petr Pchelko
e5083b79ee Drop hard-deprecated and unused DatabaseBlock::chooseBlock
Change-Id: Ifc04faefc590404e30b509850b67073e1b1d64c0
2021-05-25 16:52:05 -07:00
Petr Pchelko
a3b4881f6f Remove DatabaseBlock::forcedUserId feature
This used to be needed when we couldn't pass a cross-wiki
user target correctly. Now that UserIdentity is cross-wiki-aware,
we can.

Bug: T283642
Depends-On: I6f57357d3a73e753e018986e6af6245c29468875
Depends-On: Ie48ee3fcbf3fa7a285e80caf627be0b726b757c2
Change-Id: I3c21e55022c5fb316a390027f7c28211b29c3d62
2021-05-25 15:41:34 -07:00
DannyS712
e6c6a525cb Add return typehints to Block interface and classes implementing it
Change-Id: I422895aca72cb34ceaee9e741b2b988786ebbfdc
2021-05-14 21:16:59 +00:00
James D. Forrester
f2f9345e39 Replace uses of DB_MASTER with DB_PRIMARY in documentation and local variables
This is just a start.

Bug: T254646
Change-Id: I9213aad4660e27afe7ff9e5d2e730cbf03911068
2021-05-14 12:40:34 -07:00
daniel
69945139da DatabaseBlockStore: clarify cross-wiki access
This is an attempt to avoid confusion about which wiki database a given
Block belongs to.

Eventually, Block and DatabaseBlockStore should become fully cross-wiki
aware.

Change-Id: I93a8e953e2c7b21ea14b1119820cdaccea1060fc
2021-05-11 22:03:50 +02:00
jenkins-bot
8aa57b1d26 Merge "Introduce Block interface and replace AbstractBlock." 2021-05-11 18:13:54 +00:00
daniel
753b1bcaff Introduce Block interface and replace AbstractBlock.
In order to allow Authority to know about user blocks,
we need a narrow interface to represent such blocks.

This deprecates some methods on AbstractBlocks in favor
of new methods on the Block interface that avoid binding to
the User class.

Bug: T271494
Change-Id: I7bb950533970984a014de0434518fbbefb695131
2021-05-11 11:36:11 +02:00
jenkins-bot
dcfcd708de Merge "GetAllBlockActionsHook: Document avoiding blockable action ID conflicts" 2021-05-10 18:39:50 +00:00
Thalia
d85a4124e2 GetAllBlockActionsHook: Document avoiding blockable action ID conflicts
Change-Id: I2975d646f44a5dc1443d22a685565f14fdee614d
2021-05-10 18:35:58 +01:00
jenkins-bot
b6fea99341 Merge "DatabaseBlockStore: fetch correct ActorNormalization" 2021-05-10 09:13:12 +00:00
James D. Forrester
d13b4678a6 DatabaseBlock: Hard-deprecate calls to isWhitelistedFromAutoblocks()
Bug: T277987
Change-Id: Ic14f38e0e60bd156d1ff04392e65eeceb3ba77b2
2021-05-08 11:40:56 -07:00
James D. Forrester
f121d0fbde DatabaseBlock::isExemptedFromAutoblocks: Drop fallback message load
This is no longer needed in Wikimedia production. Third
party users will have had a release to adjust to one of
the three called-out migration issues. It's time.

Bug: T277987
Change-Id: Ia4a797afc71441ed9a7a90ff4f1e72cc4495cf63
2021-05-08 11:39:28 -07:00
jenkins-bot
50ed27feac Merge "Throw if action codes in getAllBlockActions aren't unique" 2021-05-05 21:30:49 +00:00
STran
4d9d73819a Throw if action codes in getAllBlockActions aren't unique
Duplicate action codes (eg. extensions assign colliding action ids)
will caused unexpected partial blocking behavior. This lets someone
know that there's a duplicate by throwing before that happens.

Bug: T281915
Change-Id: I34cab4360d40805a9259cf6f2b4cbf05cee6184c
2021-05-05 12:56:33 -07:00
tsepothoabala
b4a60fecdf Allow action blocks to be logged via block log parameters
Bug: T279560
Change-Id: Icd6ba193a2ce7af83a074cd135470a5097638791
2021-05-05 19:45:52 +02:00
Petr Pchelko
7ba9cbcac7 DatabaseBlockStore: fetch correct ActorNormalization
DatabaseBlockStore is capable of inserting cross-wiki
DatabaseBlock, which works via passing non-local IDatabase.
Ideally, we'd want to make Block a WikiAwareEntity, have
cross-wiki DatabaseBlockStore, etc. But as a quick-fix for
a regression we can just fetch correct ActorNormalization

Bug: T281972
Change-Id: I796f54b7b7303b8c442d5b9ba1926b76d3805fb5
2021-05-05 13:13:20 +02:00
Thalia
6cb1016594 Allow partial action blocks to be made via ApiBlock
Bug: T280522
Change-Id: I114e3c76cfb6dd2f79b5217aee4b3da34df00850
2021-05-04 17:48:21 +01:00