Commit graph

13 commits

Author SHA1 Message Date
Umherirrender
c8ec25a961 maintenance: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: I7dec01892a987a87b1b79374a1c28f97d055e8fa
2024-09-13 19:29:24 +02:00
Dreamy Jazz
e7393b3cc7 Exclude boilerplate maintenance code from code coverage reports
Why:
* Maintenance scripts in core have bolierplate code that is
  added before and after the class to allow directly running
  the maintenance script.
* Running the maintenance script directly has been deprecated
  since 1.40, so this boilerplate code is only to support a now
  deprecated method of running maintenance scripts.
* This code cannot also be marked as covered, due to PHPUnit
  not recognising code coverage for files.
* Therefore, it is best to ignore this boilerplate code in code
  coverage reports as it cannot be marked as covered and also
  is for deprecated code.

What:
* Wrap the boilerplate code (requiring Maintenance.php and then
  later defining the maintenance script class and running if the
  maintenance script was called directly) with @codeCoverageIgnore
  comments.
* Some files use a different boilerplate code, however, these
  should also be marked as ignored for coverage for the same
  reason that coverage is not properly reported for files.

Bug: T371167
Change-Id: I32f5c6362dfb354149a48ce9c28da9a7fc494f7c
2024-08-27 13:22:29 +01:00
Umherirrender
bf82200fff maintenance: Migrate to IReadableDatabase::newSelectQueryBuilder
Bug: T344971
Change-Id: Iacd0d77ee4ec747bd810b48e236637ee081debe6
2024-04-27 22:28:20 +00:00
Taavi Väänänen
9553121e2a
maintenance: Fix PSR2.Classes.PropertyDeclaration.Multiple errors
Change-Id: I9eb336837b21aa37327f571aad4f973592bdddf7
2024-04-21 23:06:00 +03:00
Amir Sarabadani
d9370003fb maintenance: Introduce getReplicaDB() and getPrimaryDB()
And start using them instead of wfGetDB(), LB/LBF connection methods or
worse, $this->getDB().

$this->getDB() reuses the database object regardless of whether you're
calling a replica or primary, leading to returning a replica on a
primary and other way around.

Bug: T330641
Change-Id: I9e2cf85ca277022284fc26b9f37db57bd12aaa81
2024-01-18 15:12:04 +01:00
Amir Sarabadani
310333906a maintenance: Switch simple calls of Database::select to SQB
Done semi-automatically via a php parser written on top of ANTLR4.

Bug: T311866
Change-Id: I33f5b6703c0aa9c80c907a21c2a770e30642edd3
2023-07-19 17:42:23 +02:00
Amir Sarabadani
4bb2886562 Reorg: Migrate WikiMap to WikiMap/ out of includes
And WikiReference

Bug: T321882
Change-Id: I60cf4b9ef02b9d58118caa39172677ddfe03d787
2023-02-27 05:19:46 +01:00
Daimona Eaytoy
73ab1552f7 Replace usages of MWException
Bug: T328220
Change-Id: Iba938843cf8d4a9c966fb3856fe659346eeb8bfe
2023-01-29 15:06:26 +01:00
Bartosz Dziewoński
ec79aa3943 SQLPlatform: Introduce buildComparison()
Builds a condition comparing multiple values, for use with indexes
that cover multiple fields, common when e.g. paging through results
or doing batch operations. Can also be to generate a simple comparison
without writing raw SQL (see T210206).

Update a few manually constructed conditions to use this method.
There are more maintenance scripts and API classes that use the
same patterns, but this is a start.

As you can see by the code I'm replacing, there are many ways to do
this. I picked the one used by maintenance/TableCleanup.php, since
I found it the easiest to understand.

Change-Id: Ic368a87fb5ce4c13608b03206cd68518ec9732d4
2022-09-10 04:22:19 +02:00
Umherirrender
6caf78c2c8 phan: Remove PhanPossiblyUndeclaredVariable suppression
Make phan stricter about conditional variable declaration
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T259172
Change-Id: I1f200ac37df7448453688bf464a8250c97313e5d
2022-03-30 19:47:15 +00:00
DannyS712
e156a2f078 TableCleanup: stop writing to $wgUser
This class is not stable to extend, nor does codesearch reveal
any classes extending it outside of core, so we can just evaluate
if $wgUser needs to be set for this class and subclasses in core.

TableCleanup is not set up to be run directly, it requires that it
be subclassed and the subclass run as a maintenance script. Within
TableCleanup itself, nothing depends on $wgUser. Looking at the
subclasses in core:
* CleanupCaps overrides the execute method, so the code to set
$wgUser in TableCleanup::execute() is not being run
* CleanupImages, TitleCleanup, and ClenupWatchlist do not
appear to have any code that relies on anything related to the
current user or context

Since nothing is using the user in any form, simply remove the
write to $wgUser, no need to replace it with setting the context
user

Bug: T243708
Change-Id: I1a22f2ebab028822e663ab1fdcbd6c7b02331fef
2021-06-02 07:04:23 +00:00
DannyS712
cf5fd868cd Reduce some references to $wgUser
Should be a no-op

Bug: T243708
Change-Id: I7b204cdc629c6c33e6a84b5c7a4e0e7ac321f19d
2020-10-13 15:07:27 +00:00
James D. Forrester
74ee16732e maintenance: Move cleanupTable from .inc to .php
… and fix the name.

Bug: T184782
Change-Id: I670af00baed690ef57413e721b8f5f615ea46502
2020-09-25 17:36:39 +01:00
Renamed from maintenance/cleanupTable.inc (Browse further)