aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api/query/ApiQueryBlockInfoTraitTest.php
Commit message (Collapse)AuthorAgeFilesLines
* block: Fix HideUserUtils error when user is hidden twiceTim Starling2025-01-101-2/+4
| | | | | | | | | | | * Add a limit to the HideUserUtils subqueries to avoid error "Subquery returns more than 1 row". We really want to know if at least one row exists. * Fix outdated doc comment * Add tests. Bug: T382399 Change-Id: Ib3bc22e0b3080b3ae6e1d2591ac7f2a1ef57c6b3
* Add namespace to includes/api classesJames D. Forrester2024-09-251-3/+3
| | | | | Bug: T353458 Change-Id: I3ea6b08c5018ba03ba45c5766e1f46e12f6b8597
* block: Deprecate and stop using $wgBlockTargetMigrationStageTim Starling2024-05-101-33/+3
| | | | | | | | | | | | | * 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
* block: Clarify function of HideUserUtils aliases and use them consistentlyTim Starling2024-03-191-6/+6
| | | | | | | | | | | * 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
* block: Use a scalar subquery in HideUserUtils::getExpressionTim Starling2024-03-151-4/+4
| | | | | | | | | | | 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
* tests: Namespace api testsReedy2024-02-181-0/+5
| | | | | Bug: T357823 Change-Id: I0d7cc2c9b166d5e5b913c1305f7cee017fe377af
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-161-1/+1
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* tests: Remove unused variable after ConvertibleTimestamp::setFakeTimeUmherirrender2023-12-271-1/+1
| | | | | | | | 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
* Special:BlockList: Improve display of hidden usersTim Starling2023-12-051-8/+8
| | | | | | | | | | | | | | | | 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
* Support new block schemaTim Starling2023-11-291-45/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* tests: Use $this->getDb() instead of wfGetDB() in integration testsAmir Sarabadani2023-09-251-2/+3
| | | | | | | Deprecated long time ago. Bug: T330641 Change-Id: Ia57f12d350c3346029aafae25534c9ed262a7e98
* phpunit: Avoid TestUser in non-database testsDaimona Eaytoy2023-07-291-0/+1
| | | | | | | | | | | | | 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
* Simplify WHERE conditions with field = '' OR IS NULLUmherirrender2023-07-011-2/+2
| | | | | | Syntax supported since 26235c73 Change-Id: I397c76d4aba753a1629383559b95df86514f19ff
* tests: Make some PHPUnit data providers staticTim Starling2023-03-241-1/+1
| | | | | | | | | | | | | 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
* Use Authority and GroupPermissionLookup in Action APICindy Cicalese2021-02-231-4/+1
| | | | | | | | | | | | | | | | | | | 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
* Tests: Mark more more closures as staticUmherirrender2021-02-091-4/+4
| | | | | | | Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208 Bug: T274036 Change-Id: I695873737167a75f0d94901fa40383a33984ca55
* Move ApiQuery* tests under the /query subdirectoryAaron Schulz2020-10-301-0/+77
Consistency aside, this is useful for grouping more tests into separate threads when using directory based suites. Bug: T50217 Change-Id: Ife9acd5990c4ae4a5fc18371559e93d7d86fb57d