Commit graph

15 commits

Author SHA1 Message Date
Tim Starling
a5372218b7 block: Deprecate and stop using $wgBlockTargetMigrationStage
* Deprecate and stop using $wgBlockTargetMigrationStage. Remove
  block_target migration code.
* Make the $schema parameters to DatabaseBlockStore methods default to
  SCHEMA_BLOCK. Avoid passing these parameters where possible.
* Remove cleanupBlocks.php
* Deprecate DatabaseBlock static methods which try to present the old
  schema for b/c.

Bug: T362133
Change-Id: I845bad8cc09a4528fef46a6f9d490ebdec881d99
2024-05-10 15:54:17 +10:00
Tim Starling
768fd92fc0 block: Clarify function of HideUserUtils aliases and use them consistently
* Add a comment explaining why we need table aliases in HideUserUtils
  subqueries.
* Use the table aliases consistently in inner field references. While
  this does not appear to be strictly necessary, since unprefixed fields
  refer to the inner query by default, it helps to improve the clarity
  of the code.

Change-Id: Id68684ea12060a259dc87e66edd63b925da2c3b1
2024-03-19 11:31:03 +11:00
Tim Starling
8606c00b52 block: Use a scalar subquery in HideUserUtils::getExpression
On en.wikipedia.org, MariaDB chooses to materialize the subquery,
copying about 810,000 rows to a temporary table.

So, use a dependent scalar subquery, which is not eligible for this
"optimisation".

Bug: T360163
Change-Id: I7819a6870871687ea96f92dfd3f8fe581b54cc24
2024-03-15 13:47:48 +11:00
Reedy
75640200fb tests: Namespace api tests
Bug: T357823
Change-Id: I0d7cc2c9b166d5e5b913c1305f7cee017fe377af
2024-02-18 15:47:04 +00:00
Reedy
85396a9c99 tests: Fix @covers and @coversDefaultClass to have leading \
Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
2024-02-16 22:43:56 +00:00
Umherirrender
c99e804f0b tests: Remove unused variable after ConvertibleTimestamp::setFakeTime
ConvertibleTimestamp::setFakeTime does not return a ScopedCallback,
which would need a local variable, it returns the old value.
The reset is part of MediaWikiTestCaseTrait.

Change-Id: Ic479ec810f3f75cbdd393f2d91afb7a311d798a0
2023-12-27 16:36:14 +01:00
Tim Starling
60911137ef Special:BlockList: Improve display of hidden users
With multiblocks the user might be hidden even if bl_deleted=0 in the
block row being formatted.

So:
* Add a subquery with a second block_target/block table which determines
  whether the user is deleted.
* When formatting each row, redact the name if it is deleted and the
  authority does not have permission to see it.
* Add a parameter to show which block is the one responsible for
  deleting the user.
* Similarly add a subquery in ApiQueryBlocks.

Change-Id: Id9900397618e1f626802ada6fe4ee4ad10f32495
2023-12-05 13:25:54 -05:00
Tim Starling
d6727856fd Support new block schema
Support migration stages when reading and writing blocks.

I tried to set it up for an easy next stage, in which support for the
old schema is removed. I tried to avoid factoring out of shared code
between the two schemas, so that the old schema cases can simply be
deleted without the need to revert unnecessary abstractions.

However, I added HideUserUtils to factor out ipb_deleted queries. Code
review showed that this was already quite complex, with multiple
approaches to the problem, so it benefits from refactoring even without
the schema abstraction.

HideUserUtils is a service rather than a standalone class to support
unit tests, since unit tests do not allow global config access. When
the migration stage config is removed, it will be a service with no
constructor parameters -- an unnecessary abstraction which should
ideally be resolved at that time.

When interpreting result rows, it is possible to share code by using
field aliases. But when constructing WHERE conditions, the actual field
names need to be used, so the migration is more intrusive in
ApiQueryBlocks and SpecialBlockList, where complex conditions are used.

Bug: T346293
Bug: T51504
Bug: T349883
Change-Id: I408acf7a57b0100fe18c455fc13141277a598925
2023-11-29 13:31:42 +11:00
Amir Sarabadani
cd2e19c050 tests: Use $this->getDb() instead of wfGetDB() in integration tests
Deprecated long time ago.

Bug: T330641
Change-Id: Ia57f12d350c3346029aafae25534c9ed262a7e98
2023-09-25 21:08:09 +02:00
Daimona Eaytoy
2a0de02aab phpunit: Avoid TestUser in non-database tests
TestUser creates the user and therefore needs the database. Avoid using
it in non-database tests.

Add ApiQueryBlockInfoTraitTest to the Database group because it needs
the database.

Add DeleteUserEmailTest to the Database group because since 3bedffa8
the default user is not created any more in non-database tests

Change-Id: Iff438964dde47a47a2fa4a314d55010bd8c7fee5
2023-07-29 14:26:50 +00:00
Umherirrender
160411d4cf Simplify WHERE conditions with field = '' OR IS NULL
Syntax supported since 26235c73

Change-Id: I397c76d4aba753a1629383559b95df86514f19ff
2023-07-01 22:17:42 +02:00
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.

Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.

Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
2023-03-24 02:53:57 +00:00
Cindy Cicalese
f6e1891c6f Use Authority and GroupPermissionLookup in Action API
Replaces calls directly to PermissionManager with calls to
the Authority object available from Context or the
GroupPermissionLookup service.

This patch does not address use of PermissionManager for
blocks.

Deprecations:
- ApiBase::checkUserRightsAny deprecated passing optional
User parameter
- ApiBase::checkTitleUserPermissions deprecated passing
LinkTarget as first parameter, takes PageIdentity instead

Bug: T271462
Bug: T271854
Change-Id: I5d7cac1c28a37e074750c46cda03283980a07fca
2021-02-23 14:31:14 +00:00
Umherirrender
a1de8b8700 Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208

Bug: T274036
Change-Id: I695873737167a75f0d94901fa40383a33984ca55
2021-02-09 02:55:57 +00:00
Aaron Schulz
815912062f Move ApiQuery* tests under the /query subdirectory
Consistency aside, this is useful for grouping more tests
into separate threads when using directory based suites.

Bug: T50217
Change-Id: Ife9acd5990c4ae4a5fc18371559e93d7d86fb57d
2020-10-30 03:31:12 +00:00
Renamed from tests/phpunit/includes/api/ApiQueryBlockInfoTraitTest.php (Browse further)