Commit graph

17252 commits

Author SHA1 Message Date
jenkins-bot
7eaeffdbfe Merge "Test fixUserRegistration.php" 2024-08-30 20:14:20 +00:00
jenkins-bot
5984c36efd Merge "Start on tests for renameUser.php" 2024-08-30 20:14:09 +00:00
Dreamy Jazz
05c7a34fa6 Test fixUserRegistration.php
Why:
* Maintenance scripts in core are mostly untested and testing them
  will help to avoid regressions.

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

Bug: T371167
Change-Id: Ifb3594f7dc0055568431002a9180df7db4da9692
2024-08-30 17:39:11 +01:00
Dreamy Jazz
3bcf2cae8c Start on tests for renameUser.php
Why:
* Maintenance scripts in core have low test coverage, and
  increasing the test coverage will help avoid regressions and
  bugs.

What:
* Create RenameUserTest which tests the renameUser.php
  maintenance script for when invalid arguments are provided.

Bug: T371167
Change-Id: I778f45e74708d1ad25b8bda918f5c3ca03e4668d
2024-08-30 16:35:30 +00:00
Dreamy Jazz
62943e496f Start on tests for resetAuthenticationThrottle.php
Why:
* Maintenance scripts in core have low test coverage, and testing
  them is important to avoid regressions and bugs.

What:
* Create ResetAuthenticationThrottleTest which tests the script
  for invalid or missing options, as well as resetting the
  throttles for temporary account creation and name acquiration.

Bug: T371167
Change-Id: Ied9619f12f3f41040b1837e0923f8c7fb345175c
2024-08-30 16:35:24 +00:00
jenkins-bot
b5a1f97c2e Merge "Revision,Storage: Widen @covers tags in tests" 2024-08-30 12:08:24 +00:00
jenkins-bot
d7a2a2bf56 Merge "recentchanges: Move rcfeed/ to includes/recentchanges/RCFeed/" 2024-08-30 09:03:43 +00:00
Timo Tijhof
311b2d0e98 Revision,Storage: Widen @covers tags in tests
> Given all called same-class methods are de-facto and liberally claimed,
> and that we keep the coverage limited to the subject class, it maintains
> the spirit and intent by listing the class as a whole instead.
>
> PHPUnit offers a more precise tool when you need it (i.e. when testing
> legacy monster/god classes), but for well-written code, the
> class-wide tag is exactly what you want.
>
> We lose useful coverage and waste valuable time on keeping tags
> accurate through refactors, especially private functions (or worse,
> forget to update it).
> Tracking tiny per-method details wastes time in realizing (and
> fixing) when people inevitably don't keep them in sync, and time
> lost in finding uncovered code to write tests to realize it was
> already covered but "not yet claimed".

Ref https://gerrit.wikimedia.org/r/q/owner:Krinkle+is:merged+message:Widen

Change-Id: If90fc5285a067ec8f706d87b2ba1ae85020e2ba0
2024-08-30 04:23:11 +00:00
jenkins-bot
c3213fee6e Merge "phpunit: Replace trivial wfParseUrl use with parse_url()" 2024-08-29 23:27:07 +00:00
jenkins-bot
83a075b4fb Merge "Modify namespace translation for Mongolian (mn)" 2024-08-29 22:15:24 +00:00
jenkins-bot
3f154a6d63 Merge "Remove Y2K38 limit from reverse chronology pager" 2024-08-29 22:15:13 +00: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
Srishakatux
8a6567d159 Modify namespace translation for Mongolian (mn)
To be merged after the following change has been deployed: https://gerrit.wikimedia.org/r/1060893

Bug: T366271
Change-Id: I1dd9a91bc37e32bde15f52271fbea2580943ab99
2024-08-29 21:01:39 +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
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
57777e1c08 Merge "Test purgeOldText.php" 2024-08-29 18:41:51 +00:00
jenkins-bot
01abfbfcbd Merge "Add option to sort categories in OutputPage" 2024-08-29 17:03:13 +00:00
jenkins-bot
4474aaf440 Merge "Allow ApiParse to use the ArticleParserOptions hook" 2024-08-29 17:00:00 +00:00
C. Scott Ananian
493df826b9 Add option to sort categories in OutputPage
Some wikis treat the category list from ParserOutput as a /set/, others
as an /ordered list/.  For those who don't care about the order of
categories, provide the option for wikis to sort the categories
in OutputPage.

This can also be activated with a query parameter, `&sortcat=1`, which
is useful to the Parsoid team when doing visual diff testing to avoid
false positives caused by differences in category ordering.

Bug: T373480
Change-Id: Idd14650a1898c6a49c88441ef024ce3012903bbe
2024-08-29 12:20:19 -04:00
C. Scott Ananian
9dbce134c6 Allow ApiParse to use the ArticleParserOptions hook
Extensions can use the ArticleParserOptions hook to customize the
parser options used for article read views, and Visual Editor uses
ApiParse to regenerate the article read view HTML after edit.  In
order for VE to remain consistent with the original parse options,
provide a `usearticle` option to the parse API to allow it to invoke
the ArticleParserOptions hook.

Bug: T373212
Change-Id: I906affc8d2335b7bb48dff3a4b061fcf86b71cee
2024-08-29 11:33:35 -04:00
Timo Tijhof
8fb118cb8b recentchanges: Move rcfeed/ to includes/recentchanges/RCFeed/
It is part of the component at
https://phabricator.wikimedia.org/tag/mediawiki-recent-changes/
and
https://www.mediawiki.org/wiki/Developers/Maintainers
and
since Ifac20da51f7e809f under the same "Recent changes" doc group.

The Maintainers list oddly enough lists only rcfeed and completely
forgets the majority of it under /includes/changes (or now,
/includes/recentchanges).

Bug: T364652
Change-Id: I94e6705672c1e2821bdc726aa7a383d9e7c1f7b5
2024-08-29 03:51:40 +01:00
Timo Tijhof
5943b6e691 phpunit: Replace trivial wfParseUrl use with parse_url()
Follows-up changes I57a8e7ea1b3, I1e76d2f5ae, I98ea4670e8, and
more in a search for "parse_url" in Codesearch (WMF Deployed).

Bug: T319340
Change-Id: I2b389612f4d591080f7e6235ddfc72f832b31143
2024-08-29 03:15:36 +01:00
jenkins-bot
e201b5414f Merge "PasswordReset: remove $wgAllowRequiringEmailForResets feature flag" 2024-08-29 02:13:46 +00:00
MusikAnimal
ef14cd41c3 PasswordReset: remove $wgAllowRequiringEmailForResets feature flag
Update a few tests that relied on the feature flag to ignore
the 'requireemail' preference on "User1" to instead use "User2",
who doesn't have the preference set.

Bug: T242406
Change-Id: I996d3996272d704a071d1d2094c3568247b80f98
2024-08-28 00:55:43 +02:00
C. Scott Ananian
3739467256 Deprecate OutputPage::setCategoryLinks()
This method has a weird behavior where it resets the category *link* list
while not resetting the category *list*.  It turns out that no one actually
needs that weird behavior; in fact no one needs this method at all, since
the only external user is the Translate extension, which could use the
OutputPage::addCategoryLinks() method instead, which has existed since
2014 (Id25041a7891f588ffa787fdd2c092342eecd30c8).

Deprecate this method with warnings.

Bug: T373480
Depends-On: Id25041a7891f588ffa787fdd2c092342eecd30c8
Change-Id: I7b07d761eb8cd5ad1e6da2dd836e969a0d492c2b
2024-08-27 22:42:09 +00:00
jenkins-bot
7415ff9e0b Merge "CodexModule: Also print dev mode warning when loading full library" 2024-08-27 16:23:08 +00:00
jenkins-bot
3abfedbcbb Merge "auth: Add AuthManagerVerifyAuthentication hook" 2024-08-27 01:16:31 +00:00
jenkins-bot
8cf23d37ef Merge "auth: Add AuthManagerFilterProviders hook" 2024-08-27 01:16:14 +00:00
Gergő Tisza
e3cea8e11f auth: Add AuthManagerVerifyAuthentication hook
Add a new hook that can be used to prevent authentication just
before AuthManager takes the main action (writing the session
for login, creating the local user account for account creation).

The driving use case is a wiki which supports both a local and
a central (wiki-farm-level) login or signup flow - various
security options (such as 2FA) are needed during local login
but unnecessary during central login (which will have those
security features centrally), so we need to skip much of the
security when the user is taking the central route, and a bug
in how that's done could result in circumvention of security
features during local login. The hook makes it easy to inspect
and potentially interrupt login near the end, when we know for
sure what route it took. (Specifically, we know which primary
provider was used. The hook doesn't expose other details,
such as the list of preauth or secondary provders that were
invoked, because they were not needed for the immediate use
case, but they are easy to add in the future.)

The hook is called after the secondary providers for login
and before them for account creation, since secondaries can
interrupt login but cannot interrupt account creation.

A shortcoming is that since the hook is called after a primary
provider succeeded, it cannot prevent the primary provider from
doing work, ie. it cannot prevent creation of the remote account
during account creation (although it will prevent the creation
of the local account). This is not great but acceptable, since
creating a new account isn't very security-sensitive.
This also means the hook would not be useful during account
linking, as AuthManager does not do anything there, all the work
happens in the primary provider. This is even less great but
few authentication extensions implement account linking.

The hook is not called for authentication happening via
CreatedAccountAuthenticationRequest, which is a weird internal
hack hook handlers should not have to know about.

Also rename a confusingly named variable.

Change-Id: I835b2fe2f43e6e81f23348165cbb9c93832e6583
2024-08-26 23:57:31 +00:00
Gergő Tisza
cde00b5585 auth: Add AuthManagerFilterProviders hook
Allow disabling authentication providers. This allows for
extensions to replace core providers with their own.

This is using the $wgAuthManagerAutoConfig keys instead of
AuthenticationProvider::getUniqueId() as the keys to filter.
This makes it more useful for site administrators, and also
it's probably the better known of the two identifiers so
more intuitive.

No effort is made to prevent the hook from filtering
differently in different steps of the same authentication
process.

Bug: T369180
Change-Id: If5435b54a4fc08f685c04fc10eb44c6d72cd78fa
2024-08-26 23:56:49 +00:00
jenkins-bot
d5bacc16f2 Merge "Make ContentDOMTransformStage not Parsoid specific" 2024-08-26 22:13:20 +00:00
jenkins-bot
672f5d7e6b Merge "parser: Avoid cache stampede on pages which use {{CURRENTYEAR}}" 2024-08-26 16:00:08 +00:00
Dreamy Jazz
36e06c9f70 Test purgeOldText.php
Why:
* Maintenance scripts in core are mostly untested and testing them
  will help to avoid regressions.

What:
* Create PurgeOldTextTest that tests the maintenance script
  by mocking the ::purgeRedundantText method.
** Mocking this method is done because it should be tested
   directly instead of indirectly through this maintenance
   script
** Using this method of mocking avoids the need for a database
   test, which speeds up the execution of this test class.

Bug: T371167
Change-Id: I0a79fa79f151ff4102f746becaea2c800a7cd064
2024-08-26 09:48:48 +00:00
Derk-Jan Hartman
6d2c0119af Remove Y2K38 limit from reverse chronology pager
Y2K38 is 14 years from now. Past experience shows that some installs
survive well over 14 years.

Windows 32bit is 0.04% and those systems are very unlikely to ever run a
2025 version of MediaWiki.

Bug: T122660
Change-Id: I45274f639159de83413e05aa498539f7be5f0e05
2024-08-24 23:33:54 +02:00
Dreamy Jazz
8e947c005f Test removeInvalidEmails.php
Why:
* Maintenance scripts in core are mostly untested and testing them
  will help to avoid regressions.

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

Bug: T371167
Change-Id: I0c269e6d581c6da63d67c869d29f6f7b59033fd4
2024-08-24 19:13:41 +00:00
jenkins-bot
82e123f2d1 Merge "Provide previous parse results to parser when rendering" 2024-08-24 03:37:10 +00:00
jenkins-bot
1673aa6cd7 Merge "Remove ParserOutput::getText() calls from core (direct pipeline)" 2024-08-24 01:22:34 +00:00
jenkins-bot
fda1db3f96 Merge "Test invalidateBotPasswords.php" 2024-08-24 01:09:15 +00:00
Roan Kattouw
5842c2c487 CodexModule: Also print dev mode warning when loading full library
We were only showing the development mode warning when Codex was used in
code splitting mode, but not when the full library was being loaded.

Bug: T314507
Change-Id: I22e9707b659b004ef1059f8b13feaf3f61b7ca28
2024-08-23 16:49:22 -07:00
C. Scott Ananian
a0503debb0 Provide previous parse results to parser when rendering
This patch lays the groundwork for incremental/selective parsing in
Parsoid by ensuring that we can pass previous cached parses through
the parse pipeline to Parsoid.  We do this by adding a new render
hint type, `previous-output`, and ensuring it is passed along.

Because revisions can contain a ParserOutput which is the combination
of separate ParserOutput objects for each of their slots, RenderedRevision
also contains a method to unsplit the combined ParserOutput to reconstruct
an original ParserOutput for use in incremental parsing.  Currently this
is mostly a stub, but illustrates how slot combination and splitting can
work, assuming those transformations are reversible.

Extra calls to ParserCache::getDirty() are added to some code paths
in order to ensure that any previously-cached ParserOutput is available
for selective update.  In order to mitigate any performance concerns,
these are only done for the Parsoid parser at the moment.  Future
patches will add additional metrics to quantify the cost/benefit ratio
of the additional cache lookups on these paths.

Bug: T363421
Bug: T371713
Change-Id: I440884f1d7e09c1ff9806f848b7b53a636367690
2024-08-23 17:41:55 -04:00
jenkins-bot
aef156e925 Merge "Migrate ParserOutputAccess metrics to statslib" 2024-08-23 21:39:21 +00:00
jenkins-bot
516450947b Merge "Codex: Allow a local development version to be used" 2024-08-23 21:16:16 +00:00
jenkins-bot
5a0901ee8f Merge "deferred: Hard-deprecate LinksUpdate::getAddedLinks/getRemovedLinks" 2024-08-23 21:11:33 +00:00
jenkins-bot
6dfbace5d7 Merge "PasswordReset: Code quality improvements" 2024-08-23 21:11:26 +00:00
Yiannis Giannelos
fa3e92db5e Migrate ParserOutputAccess metrics to statslib
Bug: T359372
Change-Id: I5450251dff31d55a9a46b7fe885c27cd6ba083bf
2024-08-23 21:06:34 +00:00
jenkins-bot
d8b1cdb8bc Merge "maintenance: Fix rollbackEdits.php with uncanonicalised names" 2024-08-23 18:03:59 +00:00