Commit graph

24 commits

Author SHA1 Message Date
Umherirrender
06947613d7 maintenance: Use namespaced classes
This does not include use of MediaWiki\Maintenance\Maintenance,
assuming the maintenance scripts going into the same namespace

Change-Id: I488f95b537ce86eb5e463be7bce3653610dd13d9
2024-10-21 19:08:08 +02: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
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
James D. Forrester
1d0b7ae1e2 Namespace User under \MediaWiki\User
Bug: T166010
Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
2023-09-19 19:18:16 +00: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
James D. Forrester
ad06527fb4 Reorg: Namespace the Title class
This is moderately messy.

Process was principally:

* xargs rg --files-with-matches '^use Title;' | grep 'php$' | \
  xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1'
* rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \
  xargs rg --files-with-matches 'Title\b' | \
  xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1'
* composer fix

Then manual fix-ups for a few files that don't have any use statements.

Bug: T166010
Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a
Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
2023-03-02 08:46:53 -05:00
Matěj Suchánek
884efbe0e3 Remove WikiRevision::downloadSource
It has been deprecated since 1.31 and it is unused.

Change-Id: I695e7f5d253076829ba9b58bccd7bfc77624c393
2022-11-04 09:24:15 -04:00
Gergő Tisza
926cfa3b3d Use a constant for 'Maintenance script' username
The user 'Maintenance script' is often used to perform various
automated tasks. Providing it everywhere as a string literal is
error-prone, and errors can be somewhat disruptive (e.g. with
User::newSystemUser with steal=true it can erase the credentials
of a legitimate account). Provide a constant instead.
Also replace existing uses for consistency.

Change-Id: I685a5bfe56bbf1a47f35072f7f7c8be320ee27db
2021-05-03 23:34:26 +02:00
Ammar Abdulhamid
c0cbed665a importTextFiles.php: Replace deprecated WikiRevision:setText()
Bug: T267558
Change-Id: I23d2af6bdeb84b782e70cedc0f57f08efd879eb7
2020-11-10 01:35:41 +01:00
Reedy
41f12dbece importTextFiles: Don't get the content and not use it
Change-Id: I909ffcee705460720ce8e0f72c99c3b7dd56f9c4
2020-10-07 23:43:08 +01:00
daniel
7ffacacc6b MCR import
Bug: T220525
Change-Id: I7d41a8af12e33aed802526eb39a0880292c4f534
2020-07-18 20:34:16 -04:00
DannyS712
fecea89998 importTextFiles: Remove use of Revision objects
Bug: T249021
Change-Id: Iac794db42c0aeabfe0dc645bc0fbcb5d2203aaca
2020-06-03 00:03:27 +00:00
Reedy
c7eb28aac9 Fix various MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment
Change-Id: I50c7c93f1534e966224f98a835ca01f93eb9416d
2020-05-21 01:06:05 +00:00
Derick Alangi
2dca5bbbf5 Remove unnecessary semi-colons
Change-Id: I9eb65bdfbd3aa581effc14ead801b9e89b0359c3
2019-06-12 14:35:59 +01: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
Bryan Davis
9e34eeff23 Maintenance: add fatalError() method
Deprecate the second argument to Maintenance::error() in favor of a new
Maintenance::fatalError() method. This is intended to make it easier to
review flow control in maintenance scripts.

Change-Id: I75699008638f7e99b11210c7bb9e2e131fca7c9e
2017-11-21 21:34:16 -07:00
addshore
b12086b618 Get ConfigFactory & MainConfig from MediaWikiServices
Change-Id: Iafdd7e00747060572463ffb05aae4543f3a06163
2016-11-23 00:12:38 +00:00
This, that and the other
628e3ce69c Fix importation of weird file names in importTextFiles.php
When importing a file whose name contains a #, the script would call
e.g. Title::newFromText( '#foo' ), which succeeds (because titles
are allowed to contain fragments) but causes problems when trying
to create the revision.

Also avoid fatals on actual invalid titles.

Bug: T142675
Change-Id: I6b4c8fd8dd09db14c0704c74137e112b292c964a
2016-09-21 12:32:22 +08:00
This, that and the other
b84905bb85 Make importTextFiles.php work with wildcards on the Windows shell
The Windows command line doesn't automatically expand wildcards, unlike
Unix shells. So the script tried to run function calls like
file_get_contents( '*.txt' ), which do not work. This patch uses glob()
to simulate the behaviour of the Unix shell.

This was reported at https://www.mediawiki.org/wiki/Topic:T7hf8bz8u2p4ryol

Change-Id: I002344a19cb08cc8ac8ee75214339b2379b04dbe
2016-07-16 12:29:11 +00:00
Bartosz Dziewoński
c6defb358d Fix typo in 'log-action-filter-suppress-block'
And some other instances of 'ppp'.

Bug: T137960
Change-Id: I3926873a79f297e0369d3c6c3300c29d2196d68f
2016-06-16 15:10:30 +02: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
Andrew H
0202c55e3a Add parameters to importTextFiles.php
- Add --bot to mark edits as bot edits when --rc is specified
- Add --overwrite to overwrite existing pages with changes.
This respects the --use-timestamp option by only overwriting if
the file is newer than the latest revision on the destination page.
- Add --prefix for specifying a prefix
- Add --rc to add an edit entry to Special:RecentChanges

This is a GCI task.

Change-Id: I5acf829409853e2b311ae6c1c75a009fef91ceeb
2016-01-12 02:25:13 +00:00
Andrew H
c812fa3cb3 Add maintenance script importTextFiles.php
importTextFiles.php can be used to import pages from text files
containing wikitext.

Also, added $userObj to WikiRevision so that it can accept a User
object instead of just a username.

This is a GCI task.

Change-Id: I20eaf2005bdd3d041f55d8c0b108f001c064d638
2016-01-08 00:57:11 +00:00