Commit graph

6 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
Kosta Harlan
efcc1015fa expireTemporaryAccounts: Provide support for overriding the expiry period
Why:

- When disabling temporary accounts, the wiki operator may wish to also
  expire active temporary accounts.

What:

- Provide an override of the config setting for 'expireAfterDays' in the
  maintenance script. Setting a value of "--expiry=0" will expire all
  temporary accounts

Bug: T356524
Change-Id: I7313ce947d7d4de340418d145a9bdd15910403e8
2024-06-14 15:26:44 +00:00
Kosta Harlan
20638462a7
[temp accounts] Make use of isKnown config flag
Why:

- A few places in core should check the isKnown
  flag (I4ce534a847461230f7fa276a565bdc1d6c9857e1) rather than isEnabled

What:

- Update ChangesListSpecialPage, UserGroupManager,
  UserSelectQueryBuilder, WatchedItemQueryService,
  ApiQuerySiteInfo, maintenance/expireTemporaryAccounts and
  maintenance/userOptions to used the isKnown() config check

Bug: T356524
Change-Id: I5a88808c7297752c60f6e7ffe16cf6543d783269
2024-06-14 17:26:30 +02:00
James D. Forrester
54a934e24d maintenance: Use getServiceContainer() when in instances of Maintenance
Change-Id: I00caa744deb805f4156eebee92068025f2aea2a4
2024-02-13 19:25:23 +00:00
Martin Urbanec
99650b86cd expireTemporaryAccounts: Only process temporary accounts
Bug: T351428
Change-Id: Ic170f4d901a520cf65b61b522f75998705eface6
2023-11-16 17:12:39 +01:00
Martin Urbanec
c9908da103 IP Masking: Expire temporary accounts in 1 year
Why:
Temporary accounts (introduced as part of IP Masking)
are supposed to expire 1 year after their registration.
Automatic account expiration can be done via a maintenance
script, which would be periodically executed via cron / systemd.

Make it possible for extensions to provide their own logic
for generating a list of temporary accounts to invalidate.
This is used in CentralAuth to base registration timestamp
on the global registration timestamp.

The default behavior is "temporary accounts do not expire",
given the feature requires a maintenance script to run
periodically, which will not be the case on third party
instances.

What:
* Add `expireAfterDays` to $wgAutoCreateTempUser, controlling
  how many days temporary accounts have.
* Add UserSelectQueryBuilder::whereRegisteredTimestamp(),
  filtering accounts based on user_registration.
* Add ExpireTemporaryAccounts maintenance script, which is
  @stable to extend.

Bug: T344695
Change-Id: If17bf84ee6620c8eb784b7d835682ad5e7afdfcc
2023-11-09 15:11:48 +01:00