Commit graph

24 commits

Author SHA1 Message Date
Umherirrender
9653fc56ad maintenance: Fix paging in findMissingFiles.php
When there are more files as the batch size,
the script loops as the where condition is not changed.

Bug: T401088
Change-Id: Ic52ea24de0bd68db9e7d84e2f1b1067b20c2836d
(cherry picked from commit 9a162bff8add74a1b797cf0769b8601d440cc231)
2025-08-06 19:10:54 +00: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
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
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
7432b21816 Migrate more calls of Database::select* to SelectQueryBuilder
Using a php parser written on top of ANTLR4, done semi-automatically.

I checked everything and made adjustments.

Bug: T311866
Change-Id: I6150c6909bce8f3dbd745a26380cc0af9d9c547f
2023-07-26 13:01:28 +02: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
Reedy
c7eb28aac9 Fix various MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment
Change-Id: I50c7c93f1534e966224f98a835ca01f93eb9416d
2020-05-21 01:06:05 +00:00
Derick A
e7493e35bd maintenance: Avoid deprecated usage of RepoGroup::singleton()
Change-Id: I694cf124a5f90f368309b04f8ae0b843a98816eb
2020-02-18 21:28:17 +00:00
Brad Jorsch
b26248235b Add string casts when using array_keys() with SQL query conditions
Until I70473280, integer literals were always quoted as strings, because
the databases we support all have no problem with casting
string-literals for comparisons and such.

But it turned out that gave MySQL/MariaDB's planner problems in some
queries, so we changed it to not quote actual PHP integers.

But then we run into the fact that PHP associative arrays don't preserve
the types of keys, it converts integer-like strings into actual
integers. And when those are passed to the DB unquoted for comparison
with a string-typed column, MySQL/MariaDB screws up the comparison while
PostgreSQL simply throws an error. Sigh.

This patch adds string casting to direct uses of array_keys() to supply
values for such query conditions. It doesn't change uses where the field
being compared is a numeric field.

If anyone knows of a good way to find indirect uses of array_keys() for
passing as $conds to IDatabase methods, please do so!

Change-Id: Ie72ee33437d492904e1495b3f4ebb1fcf0118f49
2019-12-16 16:05:18 -05:00
Umherirrender
7363e38ddf Set public for override of Maintenance functions
The following function are set to public in the parent class and cannot
have another visibility in subclasses
Maintenance::__construct
Maintenance::execute
Maintenance::getDbType
Maintenance::validateParamsAndArgs
Maintenance::setDB

Change-Id: I0cd6514642d479aca20f1221bf673b0713c21631
2019-10-09 20:41:33 +02:00
Aaron Schulz
cb15755e92 Normalize use of "INNER JOIN" to "JOIN" in database queries
The ANSI SQL default join type is INNER and this might save
some line breaks here and there.

Change-Id: Ibd39976f46ca3f9b71190d3b60b76ca085787a00
2019-03-06 09:17:30 -08:00
Umherirrender
ad776c7d5f Use ::class to resolve class names in maintenance scripts
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I1d4567f47f93eb1436cb98558388e48d35258666
2018-01-23 17:40:16 +00:00
Max Semenik
dac20d0ffa Introduce Maintenance::getBatchSize()
Just to isolate the internals. Fix most of usages in the core.

Change-Id: I8b3e9ca1f42b7c49ee57f17b88ca2fc7b404f342
2017-11-05 13:26:12 -08:00
Aaron Schulz
82e2c924e4 Remove "@author Aaron Schulz" annotations
Bug: T139301
Change-Id: Ib5248e8e27d60611c7373bce4b29dd5e85aa3489
2017-06-27 15:24:14 -07:00
Aaron Schulz
f525c72590 Rename getSlaveDB() FileRepo method to getReplicaDB()
The old name is left as an alias.

Change-Id: I60ab2cd5ce05df4247d5e25b017d2debee56554e
2016-11-18 07:42:39 -08:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Max Semenik
59db24e90b Use addDescription() instead of accessing mDescription directly
Change-Id: I0e2aa83024b8abf5298cfea4b21bf45722ad3103
2016-01-30 01:28:32 -08:00
Aaron Schulz
914b408577 Avoid the page join when not really needed
* That sometimes triggered a filesorts when the title for the
  inequality has certain (seemingly long) values.
* Also made the continuation queries use > instead of >=.

Change-Id: I912df77ad43f025918e52d1494300d487a9deea1
2014-10-02 17:23:51 +00:00
Aaron Schulz
5f38add271 Avoid stupid mariadb filesort in findMissingFiles.php
Change-Id: I6267cfaf375fcc0eea8291fd7a2a0f7daa05a941
2014-10-01 14:21:26 -07:00
Aaron Schulz
97b3057c91 Use a less confusing column alias in findMissingFiles.php
Change-Id: I9c0a948e6a0dc2ed604fb8c2828fc6e5a94fec9f
2014-09-23 11:27:16 -07:00
Aaron Schulz
7afa123d39 Made findMissingFiles inspect the destination title for moves
Change-Id: I865f5575bc41bc85a09c9429d70e526c093961ee
2014-08-29 11:26:53 -07:00
Aaron Schulz
d71efc78bf Made findMissingFiles use preloadFileStat() on old versions too to speed it up
Change-Id: I03133c146f5a4f07f27b26dd033d6c93b72aea04
2014-08-29 17:50:41 +00:00
Aaron Schulz
f2fc6b1f1f Made findMissingFiles support scanning files changed in a time range
Change-Id: Ic69249cc3646a04a885ca3b12ea426f1eb2cd171
2014-08-28 13:48:30 -07:00
Aaron Schulz
0fe26747dd Added a script to find missing LocalRepo files
Change-Id: I507bd43c6a74568ce94844146c9e20a4d8d17d46
2014-08-07 15:25:16 +00:00