Commit graph

22 commits

Author SHA1 Message Date
Aryeh Gregor
7b791474a5 Use MainConfigNames instead of string literals, #4
Now largely automated:

VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \
  tr "\n" '|' | sed "s/|$/\n/;s/'//g")
sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \
  $(grep -ERIl "'($VARS)'" includes/)

Then git add -p with lots of error-prone manual checking. Then
semi-manually add all the necessary "use" lines:

vim $(grep -L 'use MediaWiki\\MainConfigNames;' \
  $(git diff --cached --name-only --diff-filter=M HEAD^))

I didn't bother fixing lines that were over 100 characters unless they
were over 120 and triggered phpcs.

Bug: T305805
Change-Id: I74e0ab511abecb276717ad4276a124760a268147
2022-04-26 19:03:37 +03:00
Timo Tijhof
fb7e47fd5a block: Use $wgUpdateRowsPerQuery for purgeExpiredBlocks()
Follows-up I052735edbfac.

Bug: T301742
Change-Id: Iec989945f4c592d7569e62199dd8190c535acae7
2022-03-04 22:40:53 +00:00
jenkins-bot
e876068ee9 Merge "block: Add a limit to DatabaseBlockStore::purgeExpiredBlocks" 2022-02-28 08:42:33 +00:00
Amir Sarabadani
d344b90f59 block: Add a limit to DatabaseBlockStore::purgeExpiredBlocks
Making it run without limit can easily cause a read-only by creating a
massive transaction choking the replication. It's fine if the values
stay there until the next couple of blocks.

Bug: T301742
Change-Id: I052735edbfaca8821bf6dcbf62737890d3855822
2022-02-28 09:21:47 +01:00
Umherirrender
ba2c15abb2 block: Avoid use of null block id and blocker
Use a local variable to allow phan to track the not-null part

Found by phan strict checks

Change-Id: I32e023d3dbd70e987c79527a6936209d62deffcf
2022-02-26 10:35:10 +01:00
Umherirrender
72ea37795f block: Use local variable for null checks
This helps phan to understand that the value is not-null after the check

Change-Id: I38eddb2c403bb44f33754ee1bd57efa964e674d5
2022-02-18 22:52:44 +01:00
Alexander Vorwerk
283763c893 DatabaseBlock: assert the blocker to be from the correct wiki
If the wiki to which the blocker belongs does not match the wiki to
which the block belongs, things can go wrong.

Bug: T274817
Change-Id: Iab88ff2106932dffeb8b6da193e5a5e12f686cc3
2022-01-26 00:26:31 +01:00
Alexander Vorwerk
b6793e47de Make Block objects aware of which wiki they belong to
Bug: T274817
Depends-On: I1c46c712a3afefce56238108cb2e78382dd41956
Change-Id: I8ae8133f7e232cc75aae6b72fcd7feaeb313cba7
2022-01-17 21:49:20 +01:00
Umherirrender
c7817fca44 docs: Remove wrong null types
Change-Id: I017ff1a7fea0119b2a864c5fefb002afa7535cad
2021-08-26 21:42:03 +02: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
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
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
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
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
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
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
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
Tim Starling
57ce83d73a Stop using legacy ActorMigration fields in DatabaseBlockStore
Stop using ipb_user and rc_user fields in calls to ActorMigration.

Bug: T278917
Change-Id: I45a214a8647a21146b6f1de4a75ec53faeb3409c
2021-04-19 10:51:03 +10:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
Aryeh Gregor
a24e8a06b5 Mark CONSTRUCTOR_OPTIONS as internal
These were never meant to be part of the public interface and should not
ever have been marked with @since. They're only useful for constructing
the respective objects, which no outside users should be doing.

Change-Id: I86e01272d46fc72af32172d8a12b9180971d4613
2020-08-21 00:18:45 -04:00
DannyS712
23c3c70d7f Add a DatabaseBlockStore service
The new service replaces the following public DatabaseBlock methods:
* ::delete
* ::insert
* ::update
* ::purgeExpired

Bug: T221075
Change-Id: I5f95db14b1189fd62d2c2bd5dae2cab0a368f401
2020-07-29 15:55:09 +01:00