Commit graph

10944 commits

Author SHA1 Message Date
jenkins-bot
3925b14ffb Merge "Move update-keys.sql to a PHP array" 2024-09-16 10:27:53 +00:00
jenkins-bot
dbb28b2699 Merge "Fix old autoblock unblock log entries with namespace in log_title" 2024-09-13 18:38:31 +00:00
jenkins-bot
ced29cfbe0 Merge "maintenance: Add missing documentation to class properties" 2024-09-13 18:15:35 +00:00
jenkins-bot
a27ade70ee Merge "Use const keyword for constant list of strings or ints" 2024-09-13 18:08:57 +00:00
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
44cad41d03 Fix old autoblock unblock log entries with namespace in log_title
Why:
* The logging table on en.wikipedia.org contains an entry from
  2005 which is an unblock of an autoblock. However, the log_title
  contains the namespace, which makes the code that looks for
  logs which target an autoblock fail (because it checks for the
  first character being '#').
* Fixing the log_title to remove the 'User:' prefix from rows which
  are autoblocks (i.e. searching for log_titles which start with
  'User:#') should address the exceptions seen on Special:Log for
  these rows.
** The search can be limited to rows which have the 'unblock'
   log_action, as this has only been seen for this type of log.

What:
* Create fixAutoblockLogTitles.php which searches for the entries
  and then updates the log_title value to no longer include the
  'User:' prefix
** The queries to search are split, such that the expensive LIKE
   query is performed on batches of row IDs. If the LIKE query is
   applied directly to all rows in the table, the query takes 30s
   to run on WMF production.
* Add this maintenance script to update.php. It will be run once
  as the class extends LoggedUpdateMaintenance.
* Test the newly added maintenance script to ensure it works.

Bug: T373929
Change-Id: Ia62db56eda456bb764303b5f4b5a29be8f2d8fff
2024-09-13 12:18:32 +00:00
jenkins-bot
1ce05c306e Merge "Specify caller in DB queries" 2024-09-13 06:29:11 +00:00
Tim Starling
7b909408fc Move update-keys.sql to a PHP array
Improve maintainability of update-keys.sql by moving the list from an
SQL file to a PHP array in the same file as the updates it is disabling.

It was apparently an SQL file for the convenience of third parties
wishing to install MediaWiki by manually sourcing tables.sql. Support
this use case by adding an option to update.php which inserts the update
keys. Users should source tables-generated.sql and then run
update.php --initial

The array is the same for each DB type, but it's correct for it to have
the same scope as getCoreUpdateList(). Factoring out common parts of
getCoreUpdateList() and this new array is a separate project.

Bug: T167924
Change-Id: I404ee29aadcc2f3f24f78d1111090395129cd021
2024-09-13 12:02:07 +10:00
jenkins-bot
70fcffb795 Merge "Use $this->getServiceContainer() in maintenance" 2024-09-12 20:31:11 +00:00
Umherirrender
465777f188 Use const keyword for constant list of strings or ints
Also changed visiblity of some to private

Change-Id: I113b040321d27c84fe9b807c162736909e96fb20
2024-09-11 23:16:24 +02:00
jenkins-bot
41e428a0a5 Merge "Fix broken deleteSelfExternals.php and test it" 2024-09-11 18:57:37 +00:00
jenkins-bot
2f38506886 Merge "Test grep.php" 2024-09-11 18:36:23 +00:00
jenkins-bot
3c9691ea24 Merge "Start on tests for userOptions.php" 2024-09-11 18:30:43 +00:00
Dreamy Jazz
4a6de09299 Fix broken deleteSelfExternals.php and test it
Why:
* The deleteSelfExternals.php maintenance script is broken on
  my local wiki as the SQL generated by the script errors out
  when run on MariaDB.
* This script should be fixed, updated to use the query builders,
  and tested to ensure that any future breakages do not go
  unnoticed.

What:
* Fix the deleteSelfExternals.php script to use a DELETE query
  that works, by generating it using the query builder.
* Create DeleteSelfExternalsTest to test that the script now
  works.

Bug: T371167
Change-Id: Id423fa5c1bfe666f57a38e733334342ac1ad2cea
2024-09-11 18:23:40 +00:00
Bartosz Dziewoński
ecb8b0d689 Specify caller in DB queries
Found warnings about this in WMF production logs.

Change-Id: I3ba973c320d672604c0c0ffa1c229a32231261b9
2024-09-11 15:20:47 +02:00
jenkins-bot
15bfd2e9f8 Merge "Remove ParserOutput::getText() calls from core (runOutputPipeline)" 2024-09-06 19:39:11 +00:00
jenkins-bot
36573588b0 Merge "Hard deprecating wfGetServerUrl" 2024-09-06 19:09:50 +00:00
Isabelle Hurbain-Palatin
ce2bccc0a8 Remove ParserOutput::getText() calls from core (runOutputPipeline)
This is the fourth patch of a series of patches to remove
ParserOutput::getText() calls from core. This series of patches should
be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e.

Here we replace calls to getText where a ContentRenderer is available
close by by temporary ParserOutput::runOutputPipeline that will
eventually be replaced by a call to (probably) ContentRenderer
 (T371004). Doing this work in stages allows us to separate the work of
"bring ParserOptions to the call site" from the work of "bringing
ContentRenderer(ish) to the call site", since both need to be done for
to make ParserOutput a value object (T293512).

Change-Id: Ib4f9357293dc230df6e0ca2379a1e2a4cc1b91b7
Bug: T293512
2024-09-06 19:07:49 +00:00
jenkins-bot
9cbb9f46f9 Merge "Clarify documentation of Maintenance::runChild" 2024-09-06 16:47:38 +00:00
Ebrahim Byagowi
ab136421a8 Hard deprecating wfGetServerUrl
wfGetServerUrl is deprecated since 1.39, let's remove the
only use and turn it into a hard deprecation.

Change-Id: I82be851fe411cd002c9c5847fe3924a6c0a4ba50
2024-09-06 16:54:31 +03:30
Fomafix
266e757627 Use $this->getServiceContainer() in maintenance
Change-Id: I67af274ad60fab7ffeee2cbff6c0720665886c98
2024-09-04 13:03:09 +00:00
jenkins-bot
2a9b9675e2 Merge "build: Use inline ignore for Generic.CodeAnalysis.AssignmentInCondition" 2024-09-04 11:07:40 +00:00
jenkins-bot
1db5d0fca6 Merge "Mark FakeMaintenance as excluded for test coverage" 2024-09-03 09:28:03 +00:00
Dreamy Jazz
af4117bbdd Clarify documentation of Maintenance::runChild
Why:
* The Maintenance::runChild method is named in a way which makes
  it easy to assume that calling the method will directly
  execute the passed maintenance script
** The documentation does not help either, with it also implying
   that the script will be run once the method is called.
* Instead callers are expected to run the maintenance script by
  calling ::execute on the returned object
* The method name should be changed to make this clearer and
  the documentation improved.

What:
* Rename Maintenance::runChild to ::createChild, which makes it
  clearer that the maintenance script has not been run
** Leave ::runChild as an alias to ::createChild, as ::runChild
   was marked as stable to override.
* Improve the documentation for Maintenance::createChild to
  make it clear that callers need to call ::execute on the returned
  Maintenance object.

Bug: T371789
Change-Id: I7d0914ebaaa3ff5da05bccebb57cc76aad120dd5
2024-09-02 15:05:25 +00:00
Dreamy Jazz
18285ec027 Test grep.php
Why:
* Maintenance scripts in core have low test coverage
* Improving this will reduce the chances of regressions and bugs

What:
* Fix grep.php to batch requests for rows from the page table,
  as it currently selects all rows in one go.
** Doing this on large wikis would result in millions of rows
   being returned in one query.
* Create GrepPagesTest

Bug: T371167
Change-Id: I4c9a55257ee64609fece776ca15c4219764d5266
2024-09-02 11:53:46 +00:00
Dreamy Jazz
887af5edcd Start on tests for userOptions.php
Why:
* Maintenance scripts in core have low test coverage
* Improving this will reduce the chances of regressions and bugs

What:
* Create UserOptionsMaintenanceTest which starts on tests for this
  script.

Bug: T371167
Change-Id: I51374a96a0dd73f5a155278f5a48c5b59c44d055
2024-09-02 10:10:20 +00:00
Dreamy Jazz
754bf8b550 Mark FakeMaintenance as excluded for test coverage
Why:
* The FakeMaintenance class contains no code execept for an
  empty definition of ::execute
* Testing this class would therefore only involve checking that
  constructing it and calling ::execute does nothing
* Instead, ignoring the file for test coverage should be
  sufficent.

What:
* Mark FakeMaintenance as excluded for test coverage.

Bug: T371167
Change-Id: I7da4791d231fa7e2c4f514d3cf6ca7c492594f25
2024-09-02 10:07:58 +00:00
Pppery
6c3de9d41e CleanupTitles: Check if title exists from primary database
It's possible for multiple invalid titles to normalize to the same
title. The script tries to catch this, but it uses a replica database
for it, which might not have picked up an earlier change in the same
maintenance script. This caused the cleanupTitles run on ptwiki to crash
(and somehow escaped notice until now)

Bug: T195546
Change-Id: I2a4a34ce99067986d7c44605c796323c4d77dc4e
2024-09-01 11:35:52 -04:00
Umherirrender
be39a18332 build: Use inline ignore for Generic.CodeAnalysis.AssignmentInCondition
Avoid that new code contains this pattern.

Depends-On: I7a9b5c89129fe4b555d03861f2c3ce3e9e2b2446
Depends-On: Ic2bcc7eeb16d3333dcd019bd209bd7fde843dab9
Depends-On: If20eddd8376ae2e8e29c4e56cd51f7b8eb6642b0
Depends-On: I3414f7e17f4bcb801857bc986bae8eb97aa2bfb8
Depends-On: I38b2729418e8389c681c6cd84858f5e5ed25bd3e
Change-Id: I7cfd2e027edd327cf8be6471e348c137fefacda0
2024-09-01 00:15:10 +02:00
jenkins-bot
332310d7a1 Merge "maintenance: Replace deprecated Maintenance::$mOptions" 2024-08-30 21:32:39 +00:00
jenkins-bot
750aa11700 Merge "Start on tests for install.php" 2024-08-30 20:17:55 +00:00
Dreamy Jazz
bcb2112850 Start on tests for install.php
Why:
* Maintenance scripts in core are mostly untested and testing them
  will help to avoid regressions.

What:
* Create CommandLineInstallerTest.

Bug: T371167
Change-Id: Ia9ef03326d7c25b7eb310c191034932fffcbff8c
2024-08-30 19:44:52 +00:00
Dreamy Jazz
a805898fa1 Fully test createBotPassword.php
Why:
* Maintenance scripts in core have low test coverage
* Improving this will reduce the chances of regressions and bugs

What:
* Create CreateBotPasswordTest which fully tests
  createBotPassword.php maintenance script.
* While doing this, address a PHP warning that appears when the
  user does not specify the 'grants' option.

Bug: T371167
Change-Id: I8256c278b8397de896906e5714d478883b518ba0
2024-08-30 19:18:23 +01:00
jenkins-bot
e544e3b279 Merge "Test jsparse.php" 2024-08-29 22:11:03 +00:00
jenkins-bot
86513d046b Merge "Test moveBatch.php" 2024-08-29 21:45:13 +00:00
jenkins-bot
c146b77a12 Merge "Test checkComposerLockUpToDate.php" 2024-08-29 21:42:44 +00:00
Dreamy Jazz
05e6bdce58 Test jsparse.php
Why:
* Maintenance scripts in core are mostly untested and testing them
  will help to avoid regressions.

What:
* Create JSParseHelperTest that fully tests the associated
  maintenance script.

Bug: T371167
Change-Id: I6ae5d9722169518dd19fd5136b12b7ecd6a22798
2024-08-29 20:51:56 +00:00
Dreamy Jazz
276d4d0092 Test moveBatch.php
Why:
* Maintenance scripts in core are mostly untested and testing them
  will help to avoid regressions.

What:
* Create MoveBatchTest that fully tests the associated maintenance
  script.

Bug: T371167
Change-Id: I2244f46e34e81c98a2647e00b229ca68bc3d3568
2024-08-29 20:51:19 +00:00
Dreamy Jazz
b380904c66 Test checkComposerLockUpToDate.php
Why:
* Maintenance scripts in core are mostly untested and testing them
  will help to avoid regressions.
* Doing this for frequently run scripts is important, as they
  may fail in ways not caught by running them in CI.

What:
* Create CheckComposerLockUpToDateTest that fully tests the
  associated maintenance script.
** Move test case composer JSON files used by the LockFileCheckerTest
   class into the 'phpunit/data' folder instead of placing them
   in the same directory to allow the new test class to use these
   files too.

Bug: T371167
Change-Id: Id473ef440c6b7f8ecbb1c869f9cc0cf98705a0e9
2024-08-29 20:18:39 +00:00
Umherirrender
76719d8425 maintenance: Replace deprecated Maintenance::$mOptions
Change-Id: I1b48b3c0b0e4bda5b61307725a2f08bbb5bbaaa9
2024-08-29 22:08:23 +02:00
Dreamy Jazz
06ccac8c49 Test deleteOldRevisions.php
Why:
* Maintenance scripts in core are mostly untested and testing them
  will help to avoid regressions.
** For example, in testing the script a bug is found where the
   Maintenance::purgeRedundantText method will throw an
   unexpected exception if no valid rows exist in the
   content_address table.

What:
* Create DeleteOldRevisionsTest that fully tests the associated
  maintenance script.
* Update Maintenance::purgeRedundantText to not attempt to
  use an empty list as the value provided to
  IReadableDatabase::getExpr.
** Add a regression test for this.

Bug: T371167
Change-Id: Id0c3c5d6fe56bc9fe5d5347c82dab9ab61137f58
2024-08-29 18:54:19 +00:00
jenkins-bot
f78d2f950d Merge "docs: Set SORT_GROUP_NAMES=YES in Doxyfile" 2024-08-29 15:20:20 +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
jenkins-bot
6e32ed22d1 Merge "installer: Support MW_SKIP_EXTERNAL_DEPENDENCIES in update.php" 2024-08-26 17:23:36 +00:00
jenkins-bot
356e1709fa Merge "Make use of the ??= and ?? operators where it makes sense" 2024-08-26 17:16:23 +00:00
Timo Tijhof
4c41313130 installer: Support MW_SKIP_EXTERNAL_DEPENDENCIES in update.php
This environment variable is already checked in TestSetup.php for
PHPUnit runs by Quibble, when the job is running for a patch to
the mediawiki/vendor repository.

Right now, Quibble sets this var, but then has to separately pass
`--skip-external-dependencies` to update.php as well.

Remove the need for that by supporting the same environment variable
so that Quibble can set it once for that run, and naturally applies
by any commands where it makes sense.

Bug: T370380
Change-Id: Iad7c8d4be9e81af0a0de11019a98804b232efa8b
2024-08-26 16:49:42 +00:00
Dreamy Jazz
feba425a10 Remove fixDefaultJsonContentPages.php
Why:
* The fixDefaultJsonContentPages.php maintenance script was added
  in 2986d47c90 which was MW 1.27
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove fixDefaultJsonContentPages.php

Bug: T373335
Change-Id: Ie20f55c6a8723573aa7e9acd67766af9dfb67269
2024-08-26 13:17:04 +00:00
Dreamy Jazz
21fae91b4a Remove populatePPSortKey.php
Why:
* The populatePPSortKey.php maintenance script was added in
  993ce4d411 which was in at
  least MW 1.34.
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove populatePPSortKey.php

Bug: T373334
Change-Id: Iaa86bb193bf8feae9f5e2fe33255182e864d2e4f
2024-08-26 13:16:48 +00:00
Dreamy Jazz
30668e638f Remove populateBacklinkNamespace.php
Why:
* The populateBacklinkNamespace.php maintenance script was
  added to update.php in MW 1.24 in
  b8c038f678
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove populateBacklinkNamespace.php

Bug: T373333
Change-Id: Ia70fdd5c5ae087d7f5bdf4499185701bbb106c1f
2024-08-26 13:16:04 +00:00
Dreamy Jazz
de1f704035 Remove addRFCandPMIDInterwiki.php
Why:
* The addRFCandPMIDInterwiki.php maintenance script last had
  it's update key modified in MW 1.23 in commit
  bd38435848.
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove addRFCandPMIDInterwiki.php

Bug: T373331
Change-Id: Ie6791c0cc2cfab5e09aa0b1c7ddcea1099cd1f79
2024-08-26 13:15:41 +00:00