Commit graph

15 commits

Author SHA1 Message Date
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
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
69cabb628c maintenance: Migrate to expression builders
This was somehow left out

Bug: T210206
Change-Id: I70851b5b99fa865dbfd629caf2c1866c85418350
2024-01-17 20:27:08 +01:00
Amir Sarabadani
5a3e6564e4 maintenance: Migrate to DeleteQueryBuilder
Bug: T353219
Change-Id: Iecb55ab3f905ee9ed4e32e9cbb58c36f8cacf669
2024-01-02 13:13:49 +01:00
Derick Alangi
74033c50cd maintenance: Begin using Maintenance::getServiceContainer()
Maintenance class provides a method for getting a fresh reference
of the MW services container instance. Let's make use of these in
maintenance scripts now that we have it.

NOTE: There are still some static methods like in refreshLinks.php
that makes use of services that we can't use this method for now.

Change-Id: Idba744057577896fc97c9ecf4724db27542bf01c
2023-09-04 10:39:58 +00:00
Amir Sarabadani
b525884e11 maintenance: Use $this->waitForReplication()
This adds reconfiguring db pools in case a replica gets depooled

Bug: T298485
Change-Id: Id052ce8ed45c51e51b071778858d27b48605bf93
2022-10-24 21:11:53 +02:00
Derick Alangi
7ad8fae44e
maintenance: Use SelectQueryBuilder to construct queries
Part 2 of migrating files in `maintenance/` from IDatabase::select()
to SelectQueryBuilder.

Change-Id: I73eda0e4429016588bcfc6b3b490cb3fc0f5b711
2022-07-22 20:03:36 +01:00
Aaron Schulz
07036790cf Convert various callers to LoadBalancer::getConnectionRef()
Bug: T193565
Change-Id: I6dbeac4d5b11ded15263cfedfcae8cba170b5f18
2022-02-03 16:48:34 -08:00
Umherirrender
9dab0e0c1e Explicit order by primary key in DeleteAutoPatrolLogs maintenance script
While most rdbms working with this implicit order,
postgres can fail sometimes

Bug: T195807
Change-Id: I562a9324d846d8ca3c38914e1704d204db3172f4
2022-01-22 12:40:00 +01:00
Umherirrender
864068d000 Remove unneeded explicit true/false inside conditions
The non-strict conditions in if/while are true/false without the check.

In some situation the true/false is removed, because it is known to be a
bool (by is_bool check or type hint)

Change-Id: I5ca4c4771af25d2e785e82732df204a73653886e
2021-08-17 21:52:34 +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
Amir Sarabadani
0175c3b054 Enable deleteAutoPatrolLogs to delete pre-2011 autopatrol logs as well
Bug: T184485
Change-Id: I3f123ea0ae69f80beec7425be0f3e4c00a409c0d
2018-05-24 01:19:01 +02:00
Timo Tijhof
810614c886 maintenance: Fix autopatrols typo in deleteAutoPatrolLogs
Follows-up e1a23c9aad.

Change-Id: I43c00b2ac884a80f779be9eead50ad3de6d13fc6
2018-04-06 18:38:14 +01:00
Marius Hoch
40220100ad Add further test cases to deleteAutoPatrolLogsTest
Also make --batch-size work and make an if check nicer
(makes no functional difference AFAICT).

Bug: T189594
Change-Id: I3ce63386cb35441acfa226f313ec8aac1aa417a6
2018-04-03 07:53:53 +02:00
Amir Sarabadani
e1a23c9aad Introduce deleteAutoPatrolLogs maintenance script
It's useful to delete old patrol logs that are not useful

Bug: T189594
Change-Id: I605bb85f172eb25df45ed83ce50a3d1044f1c281
2018-04-03 03:42:04 +02:00