Commit graph

12515 commits

Author SHA1 Message Date
thiemowmde
52963bbcc0 tests: Make use of ?? and ??= operators in test code
I believe the more recent syntax is quite a bit more readable. The
most obvious benefit is that it allows for much less duplication.

Note this patch is intentionally only touching tests, so it can't
have any effect on production code.

Change-Id: Ibdde9e37edf80f0d3bb3cb9056bee5f7df8010ee
2024-08-08 15:51:20 +02:00
jenkins-bot
da40568027 Merge "Use a real user in SpecialPreferencesTest" 2024-08-08 11:16:22 +00:00
jenkins-bot
33aae1deec Merge "Hard deprecate various public or protected properties of OutputPage" 2024-08-08 11:08:57 +00:00
jenkins-bot
9f892bff5b Merge "Add namespace to ContentModelChange" 2024-08-08 10:38:33 +00:00
Dreamy Jazz
3d17b2d07f Use a real user in SpecialPreferencesTest
Why:
* The SpecialPreferencesTest::testLongUsernameDoesNotFatal test
  uses a mock user object to perform the test, but using this
  mock user causes test failures when the DiscussionTools
  extension is installed.
* Using a "real" test user will avoid this issue because methods
  such as User::getTalkPage will be defined as it's not a mock.

What:
* Use a test user instead of creating a mock User object to avoid
  test failures.

Bug: T372038
Change-Id: Ic2264d113b7e1cdccdf1bfdbb9e0a9e9525eba08
2024-08-08 10:23:58 +00:00
jenkins-bot
a03b19a19b Merge "ApiBase: Deprecate unused ApiBase::errorArrayToStatus()" 2024-08-08 10:10:20 +00:00
Ebrahim Byagowi
c586a7207c Add namespace to ContentModelChange
It adds MediaWiki\Content namespace to ContentModelChange

Bug: T353458
Change-Id: Ia9fbff3b7d25a83be58fffbfc01274c9fcc7a482
2024-08-08 11:14:45 +02:00
Ebrahim Byagowi
35867f0e21 Add namespace to FileContentHandler
It adds MediaWiki\Content namespace to FileContentHandler

Change-Id: I2db36de12a60c78524ea6ee2d8866ff901a48cac
2024-08-07 09:34:01 +03:30
jenkins-bot
6a909bce4e Merge "Add namespace to WikitextContent" 2024-08-07 04:03:24 +00:00
jenkins-bot
f2fb983c7d Merge "Use MediaWikiIntegrationTestCase::getConfVar in tests" 2024-08-06 15:52:23 +00:00
Ebrahim Byagowi
4c270a72ac Add namespace to WikitextContent
It adds MediaWiki\Content namespace to WikitextContent
and two classes related.

Change-Id: Ib74e4c5b3edac6aa0e35d3b2093ce1d0b794cb6d
2024-08-06 17:42:51 +03:30
Fomafix
594e9fb023 Use MainConfigNames in tests
Change-Id: I6f79b3a36ce6605b86604fa9a99d55e8b8e67f7b
2024-08-06 13:58:47 +00:00
Fomafix
f90af6c157 Use MediaWikiIntegrationTestCase::getConfVar in tests
Change-Id: I3a99f24da3d572281b49a8a8b92e006fde3eaa41
2024-08-06 12:52:34 +00:00
Thalia
077e3057ff Extend ContributionsSpecialPage from SpecialDeletedContributions
Why:

* Special:DeletedContributions is built entirely separately
  from Special:Contributions and lacks many of the features
  that Special:Contributions has, such as search form filters.
* As part of the temporary accounts project, a special page
  showing deleted contributions for temporary accounts was
  added via the CheckUser extension (T363362), which has
  feature parity with Special:Contributions. This was achieved
  by factoring out abstract base classes for contributions
  pages.
* SpecialDeletedContributions should be updated to make use of
  this shared functionality, to avoid confusion for users
  switching between these various pages.

What:

* Update SpecialDeletedContributions to extend
  ContributionsSpecialPage.
* Update ContributionsSpecialPage::getUserLinks to be a
  protected instance method instead of a public static method.
  This can just be done, since it was only made public to be
  called from SpecialDeletedContributions, and there are no
  other callers.
* Build a link to Special:Contributions instead of
  Special:DeletedContributions from SpecialDeletedContributions
  by overriding ::getUserLinks.

Bug: T370438
Change-Id: Ica817be5c5e078b88c9b3157b54d0dbf997e8893
2024-08-06 12:00:48 +01:00
Thalia
b65be1c0e1 Improve test coverage of SpecialDeletedContributions
Why:

* In T370438 we are refactoring SpecialDeletedContributions to
  extend ContributionsSpecialPage, a parent class shared with
  other special pages showing contributions. Ahead of this, we
  should ensure good test coverage to reduce the risk of these
  changes introducing bugs.

What:

* Add some tests for the main functionality of the
  Special:DeletedContributions page.
* Coverage is not 100% becuase there are a some blocks of code
  that will be removed from SpecialDeletedContributions that
  are the same as code that will now be run from the parent
  instead, and are already covered by existing tests.

Bug: T370438
Change-Id: I4d5bda9beb25f4b355a6013159363eb5be4d13a3
2024-08-06 11:56:32 +01:00
Thalia
106155e0a4 Extend ContributionsPager from DeletedContribsPager
Why:

* Special:DeletedContributions is built entirely separately
  from Special:Contributions and lacks many of the features
  that Special:Contributions has, such as search form filters.
* As part of the temporary accounts project, a special page
  showing deleted contributions for temporary accounts was
  added via the CheckUser extension (T363362), which has
  feature parity with Special:Contributions. This was achieved
  by factoring out abstract base classes for contributions
  pages.
* SpecialDeletedContributions and DeletedContribsPager should
  be updated to make use of this shared functionality, to
  avoid confusion for users switching between these various
  pages.

What:

* Update DeletedContribsPager to extend ContributionsPager.
* Two hooks were run from DeletedContribsPager:
    - DeletedContribsPager__reallyDoQuery
    - onDeletedContributionsLineEnding
  Run both from ContributionsPager instead, when in archive
  mode, similar to their normal-mode counterpart hooks.
* Add a basic test to ensure that Special:DeletedContributions
  doesn't encounter an error while building the pager.
* SpecialDeletedContributions will be updated in a separate
  patch.

Bug: T370438
Change-Id: Ifa266898781449a1ebd99bcf3e72182899c2452d
2024-08-06 11:56:32 +01:00
Amir E. Aharoni
c14bbf4e2f Consistent spelling of "subpage"
Also:
1. Other minor fixes in comments touched by this patch.
2. Add a separate test for subpage with spaces.

Change-Id: I267f19027098e5778b1cd491826e1741fc7ee794
2024-08-06 04:01:02 -04:00
jenkins-bot
46659139e2 Merge "Improve test coverage of DeletedContribsPager" 2024-08-05 12:37:31 +00:00
jenkins-bot
843089ecda Merge "Replace gettype() with get_debug_type() in debug/log/test output" 2024-08-04 22:07:46 +00:00
jenkins-bot
c434d89688 Merge "Replace gettype() with get_debug_type() in exception messages" 2024-08-04 21:18:48 +00:00
jenkins-bot
771be6c7aa Merge "Restore password reset invalid email message" 2024-08-04 16:58:25 +00:00
jenkins-bot
d5027398e5 Merge "ChangesListSpecialPage: Add another query test case" 2024-08-02 23:58:39 +00:00
jenkins-bot
933b055285 Merge "ChangesListSpecialPage: Simplify tests using setFakeTime()" 2024-08-02 23:22:03 +00:00
jenkins-bot
3cdc217282 Merge "authmanager: Make some tests more robust" 2024-08-02 12:40:11 +00:00
Thalia
f6222ec9a7 Improve test coverage of DeletedContribsPager
Why:

* In T370438 we are making extensive changes to DeletedContribsPager.
  Ahead of this, we should ensure good test coverage.

What:

* Add some integration tests to DeletedContribsPagerTest.
* Also update coverage annotations to use the recommended style.

Bug: T370438
Bug: T354968
Change-Id: I6538b787c784efcd0f13dd1d55d38907d80c9f5c
2024-08-02 13:22:36 +01:00
jenkins-bot
0a2bad1e59 Merge "ContributionsPager: Fix date link in archive mode" 2024-08-02 11:44:34 +00:00
Bartosz Dziewoński
c07f720ee8 ChangesListSpecialPage: Add another query test case
The 'learner' query is quite different from the other ones.

Change-Id: Ibff54518e335389c120451cca7cb78f79c7e42cf
2024-08-02 01:01:26 +02:00
Bartosz Dziewoński
52c572924b ChangesListSpecialPage: Simplify tests using setFakeTime()
Instead of using these terrible regexp assertions to match any SQL
query regardless of current time, set a fake time instead and use
simple string assertions like in the other tests.

Change-Id: If88e0f1487f79e2126d75a5123872d1f75c48403
2024-08-02 01:01:14 +02:00
jenkins-bot
2d3c0375d1 Merge "Drop writeapi userright" 2024-08-01 21:06:33 +00:00
Thalia
c6bc185226 ContributionsPager: Fix date link in archive mode
Why:

* ContributionsPager::formatRow creates the same date link for
  normal and archive mode. This links to the revision, which is
  deleted when in archive mode.
* Instead, it should do what DeletedContribsPager does, and link
  to Special:Undelete.

What:

* Handle the date links the same in ContributionsPager (archive
  mode) as in DeletedContribsPager.
* Also rename the variable $lang to $language for clarity.

Bug: T371518
Change-Id: Ied2282d06e7c2be0735203c132c605e3d7f40857
2024-08-01 18:15:26 +01:00
C. Scott Ananian
2a5a1ba6c2 Hard deprecate various public or protected properties of OutputPage
These were soft deprecated in 1.38, it's time to emit deprecation warnings
so we can complete their removal from the public API.

Change-Id: I437ab7dc8af4eb5d336e8074a42a0a54b4c00a4b
2024-08-01 15:00:54 +01:00
jenkins-bot
9c80f489cf Merge "resourceloader: Add ResourceLoaderModifyStartupSourceUrls hook" 2024-08-01 03:25:14 +00:00
Thalia
7f40a85966 Don't show 'latest' field in archive mode on contributions search form
Why:

* ContributionsSpecialPage builds a search form for filtering
  contributions. Subclasses can show different types of contributions,
  from the revision or the archive table.
* When searching the archive table, the filter for showing only
  contributions that are the latest version of a page don't make any
  sense, since the page gets deleted when the revisions are moved to
  the archive table. Therefore it should be removed in archive mode.

What:
* Add isArchive method to ContributionsSpecialPage for subclasses to
  define whether they search the revision or archive table. Default
  to true, to avoid needing to update SpecialContributions.
* Only add the filter for showng latest page revisions if not in
  archive mode.

Bug: T371495
Change-Id: If1c5772ec4693300e770e34faae9197fe6138fe4
2024-07-31 18:59:15 +01:00
Bartosz Dziewoński
df4cbf5ac6 Replace gettype() with get_debug_type() in debug/log/test output
get_debug_type() does the same thing but better (spelling type names
in the same way as in type declarations, and including names of
object classes and resource types). It was added in PHP 8, but the
symfony/polyfill-php80 package provides it while we still support 7.4.

Also remove uses of get_class() and get_resource_type() where the new
method already provides the same information.

For reference:
https://www.php.net/manual/en/function.get-debug-type.php
https://www.php.net/manual/en/function.gettype.php

In this commit I'm only changing code where it looks like the result
is used only for some king of debug, log, or test output. This
probably won't break anything important, but I'm not sure whether
anything might depend on the exact values.

Change-Id: I7c1f0a8f669228643e86f8e511c0e26a2edb2948
2024-07-31 19:33:57 +02:00
Bartosz Dziewoński
c045fa0291 Replace gettype() with get_debug_type() in exception messages
get_debug_type() does the same thing but better (spelling type names
in the same way as in type declarations, and including names of
object classes and resource types). It was added in PHP 8, but the
symfony/polyfill-php80 package provides it while we still support 7.4.

Also remove uses of get_class() and get_resource_type() where the new
method already provides the same information.

For reference:
https://www.php.net/manual/en/function.get-debug-type.php
https://www.php.net/manual/en/function.gettype.php

To keep this safe and simple to review, I'm only changing cases where
the type is immediately used in an exception message.

Change-Id: I325efcddcb58be63b1592b9c20ac0845393c15e2
2024-07-31 19:24:39 +02:00
Gergő Tisza
31f614f732 resourceloader: Add ResourceLoaderModifyStartupSourceUrls hook
Add a hook to StartUpModule that can modify the source URLs
that get embedded into the startup module JS in the form of
mw.loader.addSource() parameters.

The intended use case is preserving relevant URL information,
especially in the case of the 'local' source which is a
relative URL, when the URL pattern of the load.php URL
that generates the startup module code is different from the
URL pattern of the page that loads that load.php URL.

(E.g. $wgLoadScript is set to a different domain than the
current page, to canonicalize load.php URLs for a site
that's reachable via multiple domains, but then by default
the local source is a relative URL which would be
interpreted relative to the URL of the page that executes
the startup module code, so it would result in calls to
non-canonical load.php URLs).

Bug: T365162
Bug: T371530
Change-Id: I199ab779abd0596b836ae43dcc5f2f2a489c9274
2024-07-31 17:02:35 +00:00
jenkins-bot
848b9fa281 Merge "Use real type hints for services etc. in includes/Permissions/" 2024-07-31 12:08:58 +00:00
jenkins-bot
2830bab5a5 Merge "Use real type hints for services etc. in includes/block/" 2024-07-31 11:42:25 +00:00
Reedy
b52a8addf5 Drop writeapi userright
Bug: T294397
Depends-On: Ib34228a18917e404517d45e539bd786419d9c401
Change-Id: Ifad2edc782b36d21c8c67fecde7f011dce02c11b
2024-07-31 11:10:50 +00:00
jenkins-bot
e032f1d183 Merge "HandleParsoidSectionLinks: also run this pass if COLLAPSABLE_SECTIONS" 2024-07-31 11:02:31 +00:00
Bartosz Dziewoński
3781349e27 Use real type hints for services etc. in includes/Permissions/
Mostly used find-and-replace:

Find:
/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|)
Replace with:
\3 \1 \4

More could be done, but to keep this patch reasonably sized, I only
changed the most obvious and unambiguously correct cases.

In some cases, I also removed redundant doc comments on the
constructor, and re-ordered the properties to match the constructor.

Change-Id: I3f8427ae4f5d55177ae18986ef15d84d0e7bf6f4
2024-07-31 08:56:17 +00:00
Bartosz Dziewoński
13289a1269 Use real type hints for services etc. in includes/block/
Mostly used find-and-replace:

Find:
/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|)
Replace with:
\3 \1 \4

More could be done, but to keep this patch reasonably sized, I only
changed the most obvious and unambiguously correct cases.

In some cases, I also removed redundant doc comments on the
constructor, and re-ordered the properties to match the constructor.

Change-Id: I819ed771c915293663856c577a481d607b76ed80
2024-07-31 08:54:31 +00:00
C. Scott Ananian
b3ac045497 HandleParsoidSectionLinks: also run this pass if COLLAPSABLE_SECTIONS
Bug: T371336
Change-Id: Ieccddc229c39f65de6f2bba6364f933592686ade
2024-07-30 17:22:55 -04:00
Bartosz Dziewoński
6f82b91873 Restore password reset invalid email message
This mostly reverts commit 28ad29ea0f.

Checking the validity of the provided email doesn't reveal any
information about any users, and it could help catch genuine mistakes,
e.g. if someone inputs the username in the email field.

Previously if an invalid email was provided, we showed a success
message that is an obvious lie (saying we sent an email to something
that isn't an email address).

Change-Id: Idec437b29b22e5b1e5aaff3846632fbc413a3dcb
2024-07-30 14:19:13 +00:00
Umherirrender
eef1ff2556 logging: Hard-deprecate LogFormatter::newFromRow/newFromEntry
Depends-On: Icd3316b7f475a09390be8787fae6a8b63dcd6418
Depends-On: I007a318135db35fc82011540b3b2baf6f358b753
Change-Id: Id2c48651e1ca28146ab6bcb57c789fae69e5c251
2024-07-29 20:29:25 +00:00
Umherirrender
07db7102cc Replace deprecated LogFormatter::newFromRow/newFromEntry
Change-Id: I453ce3148a46fcb9cc5c685cee92274e0cb4f98a
2024-07-29 22:26:41 +02:00
jenkins-bot
674cd4ea18 Merge "Extract LintErrorChecker out of SignatureValidator" 2024-07-29 19:05:52 +00:00
Kunal Mehta
4d49a4a59e Extract LintErrorChecker out of SignatureValidator
This code was partially copied into MassMessage and will hopefully
enable more places that accept arbitrary wikitext to check lint errors.

It also hides the internal details of checking with the Linter
extension's configuration in one place until it can be refactored into
something more acceptable (T360809).

Bug: T368690
Change-Id: Iaeb3ccbd61a2a8cb0d8b3dc8b06a3a10bc8fa653
2024-07-29 14:35:40 -04:00
jenkins-bot
2134c3ef12 Merge "OutputPage: Inline getCdnCacheEpoch() into checkLastModified()" 2024-07-29 14:03:12 +00:00
STran
311774c033 Filter temporary accounts as anonymous in ApiQueryRecentChanges
Edits from temporary accounts are considered anonymous edits.
ApiQueryRecentChanges doesn't correctly reflect this and needs to be
updated to correctly return temporary account edits as anonymous (and
similarly, not to return them when requesting !anon)

- Update the anon|!anon query to accomodate temporary accounts

Bug: T370803
Change-Id: Ica5225422ea53d2aa3a84b86d9c2f14832a34ed4
2024-07-29 11:00:22 +01:00