Commit graph

19 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
Umherirrender
420e071271 Remove TemplateLinksSchemaMigrationStage config
Bug: T299417
Follow-Up: I906e069a63d1dae14924c72318b22b16244371d6
Change-Id: Ia5f730af82f904bd42552e6c6a5c4dadf2454d3a
2024-05-15 22:27:44 +02:00
Umherirrender
fea5c2f687 Use expression builder to avoid raw sql via BETWEEN operator
Replace BETWEEN with >= and <= operator

Change-Id: Ic21b6f4cc11c773c967d9d4c5f20e762c2ff9629
2024-04-21 14:24:21 +02: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
Alexander Vorwerk
0831905a45 Migrate some usages of Database::update() to UpdateQueryBuilder
Bug: T353219
Change-Id: I98bf4c2e2c3023fba226ac10826e52a1108b8aea
2024-01-17 15:24:45 +00:00
James D. Forrester
94ece673b2 Namespace TitleValue under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: I4c901d5c32696d8334ec30cede7d9b6f3d8d645e
2023-09-18 18:24:39 +01:00
Amir Sarabadani
d08010d6da migrateLinksTable: Also try to populate columns with zero
Currently, it only updates if the _target_id column is NULL which is not
the case for pagelinks (the default is zero) making this script not very
cooperative when I run it on pagelinks

Bug: T345733
Change-Id: I60d38fac96825ed479fd0c41fc35e70e5a6367df
2023-09-07 12:27:19 +02: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
Amir Sarabadani
6c4194e23e schema: Drop tl_title and tl_namespace fields from templatelinks
The day has gone. Still keeping the code as the schema changes are not
done in production but the data migration has been finished.

Bug: T299417
Change-Id: I906e069a63d1dae14924c72318b22b16244371d6
2022-09-06 19:53:15 +02:00
jenkins-bot
9c73f1a2f7 Merge "migrateLinksTable.php: Remove LIMIT from UPDATE query" 2022-07-28 12:09:36 +00:00
jenkins-bot
9f8abf2303 Merge "migrateLinksTable.php: BETWEEN is inclusive" 2022-07-27 22:06:49 +00:00
Kevin Israel
a74834e2b2 migrateLinksTable.php: Remove LIMIT from UPDATE query
On a live site configured for WRITE_NEW, no new templatelinks rows in
which tl_target_id IS NULL should be added. Assuming this is the case,
the conditions on PK fields (tl_from, tl_namespace, tl_title) should
suffice to limit the number of affected rows, since the range of page
IDs is limited and only one distinct target ID is filled at a time.

This avoids a needless "Updated 0 rows" query for every link target
within a batch.

Change-Id: I8af72ca8fe4c68da1603670d065a2b51ab96b79d
2022-07-13 01:41:21 -04:00
Kevin Israel
e8a6dc4352 migrateLinksTable.php: BETWEEN is inclusive
See, for example, MariaDB documentation:

https://mariadb.com/kb/en/between-and/

In part because of this, the code was including the first two page IDs
of an outer batch in the previous outer batch as well. Fortunately, this
was the case as opposed to failing to update those rows. In any case,
this commit corrects the calculation of $highPageId so the batching
works as expected.

Change-Id: Icb5eb5797d7a6cf992895224e091aad1da499724
2022-07-13 00:21:12 -04:00
Kevin Israel
f806426288 Improve wording of a few templatelinks migration messages
* Changed the message printed if the update is skipped to start with an
  ellipsis for consistency with other such messages.
* Replaced "migrate templatelinks" with wording that includes the actual
  name of the script to avoid any potential confusion over the absence
  of a script named "migrateTemplatelinks.php".
* Added "linktarget" to the error message printed if the linktarget
  table is missing. Otherwise, the error message would be easily
  misunderstood as saying the templatelinks table is missing.
* In migrateLinksTable.php, changed the wording of messages printed when
  the script starts and finishes for better grammatical correctness.

Change-Id: Id11a212d667cc2b5064eb0128f2db1888fb7324d
2022-07-12 20:53:24 -04:00
Amir Sarabadani
692dde00df Add support for write new for templatelinks migration
- schema change to allow tl_namespace and tl_title being empty
   This is done by removing them from primary key. They don't need to be
   nullable as they have default value.
 - Make sure with WRITE_NEW, updater avoids writing to the old columns

Bug: T306674
Change-Id: I2b8a29043e952060e7a79b6a7a3d647d48cd16fb
2022-07-12 14:46:54 +02:00
Amir Sarabadani
1ffc8233da MigrateLinksTable: Avoid dynamic loading of list columns to select
Currently, this errors out with
Error 1054: Unknown column 'TemplateLinksSchemaMigrationStage' in 'field list'

Bug: T299424
Change-Id: I3e86389ed1230b81267b8ad642dc22d658f7e999
2022-04-13 23:01:52 +02:00
Amir Sarabadani
6fd2843361 linker: Add LinksMigration service for read new
Bug: T304780
Change-Id: Ifdea1ef80c34831564fe12827c5c06ade6200df8
2022-04-07 16:54:38 +00:00
Amir Sarabadani
603569ab22 maintenance: Add migrateLinksTable.php
To populate tl_target_id and other tables in the future.

Bug: T299423
Change-Id: I067e861f95555bf7630f32a26c8f6a2284367897
2022-03-25 02:21:34 +01:00