Commit graph

12 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
Dreamy Jazz
398ce66ff2 Test resetPageRandom.php
Why:
* The maintenance scripts in core are mostly untested and testing
  the less complex scripts will improve the test coverage in core.

What:
* Add integration tests for resetPageRandom.php
* Update resetPageRandom.php to indicate that both the --to and
  --from parameters are required, as this is checked for in
  ::execute.

Bug: T371167
Change-Id: Ieb46edf2b2e1571e2bec50a0d79bed4085da8894
2024-08-09 14:21:11 +00:00
Umherirrender
8018e157e8 maintenance: Migrate to IDatabase::newUpdateQueryBuilder
Bug: T353219
Change-Id: Ic278c8534dad40a3f34674db2d5fbfbca5984da8
2024-04-14 18:47:55 +00: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
2df0c99fe0 Migrate several subqueries to use SQB
Bug: T344971
Change-Id: I278a6efb7efefadd5db7b52490300811669372df
2023-10-31 15:54:55 +01: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
Ammarpad
a599adb217 resetPageRandom.php: Avoid undefined variable warning
Change-Id: Iafcaaa3c137f8cfc159f7f99741969a1d9929017
2022-02-18 19:45:47 +01:00
Jayprakash12345
fbb9e2e809 resetPageRandom.php: Fix --from and --to options
These options weren't actually reading the option values, just
returning `1`, which would turn into `"19700101000001"`.

Bug: T291331
Change-Id: I93e11f18dc81b3875e0d3797e67553f7365ce963
2022-01-23 21:19:26 +00: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
Umherirrender
5a318bd5bf Pass function name to database functions (maintenance scripts)
Useful for logging

Change-Id: I79fe037abcd74f56c935abc118d706bef0198124
2020-06-07 17:24:10 +00:00
Piotr Miazga
4c73c8a676 Provide a script to reset the page_random column
Bug: T208909
Change-Id: I914ff44d1212c565e08ff17effbd682dfe7f70fb
2018-11-09 15:07:48 -07:00