Commit graph

21638 commits

Author SHA1 Message Date
jenkins-bot
0b45e77a8b Merge "Language: Introduce getContentLanguageCode() service" 2024-10-16 14:15:12 +00:00
jenkins-bot
0909ede4fd Merge "tests: Use namespaced ParserOptions" 2024-10-16 11:32:26 +00:00
Amir Sarabadani
c65e133f18 Language: Introduce getContentLanguageCode() service
And use that as much as possible. This makes bootstraping services much
faster since Language object is extremely heavy (specially to
initialize) and that's why in LanguageFactory it's behind a cache (see
LanguageFactory::getRawLanguage)

At the same time, most uses of Language object only need the language
code (after normalization and mapping and validation) and this allows
such change to happen fast and way more decoupled from Language object
that has more than 100 methods.

Bug: T376565
Change-Id: I1c3d94454896842939dfaad8cbf742e5a3ae5438
2024-10-16 11:02:01 +02:00
jenkins-bot
5579e0647c Merge "[JsonCodec] Use wikimedia/json-codec to implement JsonCodec" 2024-10-16 00:54:33 +00:00
Reedy
7a1f0dff6d tests: Use namespaced ParserOptions
Change-Id: Id7b04b61d22ab6ef8980897f1f2e2eb3eee4e619
2024-10-16 01:35:06 +01:00
C. Scott Ananian
3bc172d0e4 [JsonCodec] Use wikimedia/json-codec to implement JsonCodec
This adds support for serializing/deserializing objects which
implement the JsonCodecable interface from the wikimedia/json-codec
library used by Parsoid.  JsonCodecable allows customizing the encoding
of objects of a given class using a class-specific codec object, and
JsonCodecable is an interface which is defined and can be used outside
mediawiki core.

In addition json-codec supports deserialization in the presence of
aliased class names, fixing T353883.

Backward and forward compatibility established via the mechanism
described in
https://www.mediawiki.org/wiki/Manual:Parser_cache/Serialization_compatibility

Test data generated by this patch was added in
I109640b510cef9b3b870a8c188f3b4f086d75d06 to ensure forward
compatibility with the output after this patch is merged.

Benchmarks:
                        PHP 7.4.33          PHP 8.2.19          PHP 8.3.6
                      BEFORE    AFTER     BEFORE    AFTER     BEFORE    AFTER
Serialize:            926.7/s  1424.8/s   978.5/s  1542.4/s  1023.5/s  1488.6/s
Serialize (assoc):    930.2/s  1378.6/s   974.6/s  1541.9/s  1022.4/s  1463.4/s
Deserialize:         1942.7/s  1961.3/s  2118.8/s  2175.9/s  2129.8/s  2063.5/s
Deserialize (assoc): 1952.0/s  1905.7/s  2107.5/s  2192.1/s  2153.3/s  2011.1/s

These numbers definitely do not have as many significant digits as
written here.  But they should be sufficient to demonstrate that
performance is not impaired by this patch and in fact serialization
speed improves slightly.

Bug: T273540
Bug: T327439
Bug: T346829
Bug: T353883
Depends-On: If1d70ba18712839615c1f4fea236843ffebc8645
Change-Id: Ia1017dcef462f3ac1ff5112106f7df81f5cc384f
2024-10-15 20:09:51 -04:00
James D. Forrester
a5387c7c20 Namespace all remaining classes in includes/parser
Bug: T353458
Change-Id: If02cc9b1ff78e26c1cf8c91ee4695845eb133829
2024-10-15 23:54:32 +01:00
jenkins-bot
23ec5ff94e Merge "Add namespace to maintenance/includes classes" 2024-10-15 22:50:33 +00:00
jenkins-bot
346bf0c8ee Merge "Test findDeprecated.php" 2024-10-15 17:41:25 +00:00
jenkins-bot
e6494a917f Merge "Add tests for deleteEqualMessages.php" 2024-10-15 17:41:06 +00:00
Dreamy Jazz
e2b6281d6d Test findDeprecated.php
Why:
* Maintenance scripts in core have low test coverage
* This can cause issues such as the findDeprecated.php maintenance
  script not working, as described in T374832
* Testing the broken script after fixing it will avoid the script
  breaking again.

What:
* Fix the findDeprecated.php maintenance script to actually
  show when code is hard-deprecated.
* Modify the script to allow mocking of the MediaWiki install
  path in PHPUnit tests
* Create FindDeprecatedTest which tests that the script produces
  an expected output, without being specific about how the
  code finds the methods (to allow the method to be changed
  as discussed in T243403)
** To do this, create a folder in the data folder for the PHPUnit
   tests that has a mock file structure allowing the test to
   use a fixed list of soft and hard deprecated methods.

Bug: T374832
Bug: T371167
Change-Id: Ic4933cef95ef1af7fa3939625ac1747106c71230
2024-10-15 17:08:23 +00:00
jenkins-bot
deba2439b7 Merge "REST: Allow specifying param descriptions as MessageValue objects" 2024-10-15 15:24:56 +00:00
Dreamy Jazz
6cf9cb8ff3 Add tests for deleteEqualMessages.php
Why:
* Maintenance scripts in core are mostly untested. Adding tests
  will help increase this test coverage and make them more
  reliable.

What:
* Create DeleteEqualMessagesTest which covers most of the
  deleteEqualMessages.php maintenance script.

Bug: T371167
Change-Id: Idec3d7181767fc067f62b62b0bbf86b7e84eebbb
2024-10-15 14:26:05 +00:00
jenkins-bot
f23cd7a7d4 Merge "Test purgePage.php" 2024-10-15 14:03:52 +00:00
jenkins-bot
d521558b09 Merge "Test patchSql.php" 2024-10-14 22:15:57 +00:00
Dreamy Jazz
72df672dab Test purgePage.php
Why:
* Most maintenance scripts in core are currently untested
* Testing these scripts will help improve the reliability of
  maintenance scripts in core

What:
* Create PurgePageTest which fully tests purgePage.php

Bug: T371167
Change-Id: I3120f49669c17cc2f853efc63e409221d54480f9
2024-10-14 12:31:04 +00:00
Reedy
fc2852f44f Remove MediaWikiVersionFetcher
Change-Id: I3a44557ed5e4ab06dde0eb8aaaba2be785faff27
2024-10-14 12:00:08 +00:00
Dreamy Jazz
9335784571 Test patchSql.php
Why:
* patchSql.php is currently untested, but ensuring that it works
  as intended will avoid problematic writes to the DB

What:
* Create PatchSqlTest.php which tests that an insert query in
  an SQL file works as intended.

Bug: T371167
Change-Id: I7b3a90a2a34fddb1e127d353238ef81f8b2d16c0
2024-10-14 11:29:49 +00:00
jenkins-bot
6ac66f9e3f Merge "tests: Validate Resources.php against ResourceModules schema" 2024-10-14 11:14:48 +00:00
jenkins-bot
3e9707adfa Merge "tests: Mock IContextSource in RestStructureTest" 2024-10-14 10:52:59 +00:00
jenkins-bot
55c4bb3cac Merge "statslib: Add MetricInterface::setLabels() convenience method" 2024-10-14 10:14:39 +00:00
jenkins-bot
f17105e864 Merge "tests: Remove global state from Rest Handler tests" 2024-10-13 15:44:44 +00:00
jenkins-bot
17d6efe4c3 Merge "objectcache: Add support for sister keys in SqlBagOStuff" 2024-10-12 14:04:18 +00:00
Umherirrender
e10ca69c78 tests: Mock IContextSource in RestStructureTest
This avoids creation of session leaking into other tests
Also avoids that the session backend stores the session and
consuming memory until the end of the tests

Change-Id: Ib7a0a5df0f16bb25a6111a4a3f7cfadc489e7e25
2024-10-11 23:16:53 +00:00
jenkins-bot
26a696ecdd Merge "ParserTestRunner: consistent normalization of "known failure" output" 2024-10-11 22:12:54 +00:00
Umherirrender
97e55f4795 tests: Remove global state from Rest Handler tests
Functions provided by the HandlerTestTrait and used in other rest tests

Reduce session leaking from global state within the rest test

Bug: T376970
Change-Id: Ie0dc52441c6a6ca408812c5d0cc6d791834780e5
2024-10-11 23:18:22 +02:00
jenkins-bot
51f30d1687 Merge "SpecialBlock.setup.js: mock blockTypePreset to prevent Vue warnings" 2024-10-11 19:52:47 +00:00
jenkins-bot
4220cc9fe8 Merge "mediawiki.special.block: Add "See full log" link" 2024-10-10 18:38:40 +00:00
jenkins-bot
4e30474a7c Merge "SpecialBlock: Hard-deprecate deprecated functions" 2024-10-10 18:14:16 +00:00
MusikAnimal
498063486a SpecialBlock.setup.js: mock blockTypePreset to prevent Vue warnings
Change-Id: Ibdbb04ef23ed1ad1a4d2a33facb721998eb74e93
2024-10-10 14:04:17 -04:00
jenkins-bot
7390cb8993 Merge "Introduce minimal OTEL tracing library" 2024-10-10 17:33:42 +00:00
jenkins-bot
3147d3ef8f Merge "Expand CreateAndPromoteTest" 2024-10-10 17:19:13 +00:00
Fomafix
3f1e249b00 SpecialBlock: Hard-deprecate deprecated functions
processForm, parseExpiryInput and canBlockEmail are deprecated since
1.36.
getSuggestedDurations is deprecated since 1.42.

Depends-On: I5931525f95ff6eb76a2b30aa7a852cc86075276f
Depends-On: I6a570e503fee6676e7c54beb6f37575058a57339
Depends-On: I6890763dbe30cc33b2715e93c59cee331d8967b1
Depends-On: I99f49dd3f20032848cc7a191a6b46c5816f3bff2
Change-Id: Ibbf51d9de168d97c0ed3c827f02a356c8a579987
2024-10-10 15:52:57 +00:00
jenkins-bot
4570f1bc3a Merge "mediawiki.special.block: Modify TargetBlockLog behaviour" 2024-10-10 12:22:19 +00:00
TheresNoTime
c41eae4b17 mediawiki.special.block: Add "See full log" link
Add a "See full log" link to TargetBlockLog
Add Jest test to TargetBlockLog

Bug: T376742
Change-Id: Ibf1ef088c23fa67c1710ea037cc5838977113007
2024-10-10 12:27:41 +01:00
TheresNoTime
816baee019 mediawiki.special.block: Modify TargetBlockLog behaviour
Remove the "target" column
Add a column "type" with fields "Blocked"/"Unblocked"
Add Jest test for TargetBlockLog

Bug: T368111
Change-Id: I3e9145df62046baaa3fe762a6f57c932a976508c
2024-10-10 11:47:45 +01:00
Dreamy Jazz
8b905fac0e Expand CreateAndPromoteTest
Why:
* createAndPromote.php is partly tested, with the code that
  creates new accounts and sets a password not tested.
* Testing this code will ensure consistent test coverage

What:
* Expand CreateAndPromoteTest to improve test coverage for
  createAndPromote.php

Bug: T371167
Change-Id: Ie5dd3650b0562301f7d9861677e944daa5c4e3f3
2024-10-10 10:32:10 +01:00
jenkins-bot
ae3afe014b Merge "Remove meaningless @var documentation from constants" 2024-10-09 22:03:23 +00:00
jenkins-bot
54e0eb2226 Merge "user: Add recursion guard to APCOND_BLOCKED check in UserGroupManager" 2024-10-09 17:22:19 +00:00
Voidwalker
8c9473ee07 user: Add recursion guard to APCOND_BLOCKED check in UserGroupManager
This is to prevent infinite recursion when checking APCOND_BLOCKED due
to potentially repeated calls to user->getBlock.
UserGroupManager::checkCondition now throws a LogicException when
recursive behavior is detected during the APCOND_BLOCKED check.

Bug: T349608
Change-Id: Ia55a4d27be0f583c3bc826661579cbb4e7c47881
2024-10-09 16:51:08 +00:00
C. Scott Ananian
8a650d5d48 ParsoidParser: ensure magic variable expansion uses pageLanguageOverride
This patch adds tests for the caching fix in
Ie76020dc4fa3545f827e1674051530b479f01f31, but these tests also revealed
that the recursive invocation of the legacy parser to expand magic
variables like {{PAGELANGUAGE}} wasn't using the pageLanguageOverride,
aka ParserOptions::getTargetLanguage().

The page language override is used when parsing new context which
doesn't currently exist in the database and therefore doesn't have a
page language set by its title (which doesn't yet exist).

Bug: T376783
Follows-Up: Ie76020dc4fa3545f827e1674051530b479f01f31
Change-Id: If6fe7cf00be6e78ef46181b17f01138383e95e46
2024-10-09 12:28:23 -04:00
James D. Forrester
9f02d18eac Add namespace to maintenance/includes classes
Also a few other fixes of PHP class aliases spotted by phan.

Bug: T353458
Change-Id: Ie79d65722c47c24f8f20f1293355cfd3c2e8c2ad
2024-10-09 11:02:09 -04:00
Máté Szabó
16ec1a3703 Introduce minimal OTEL tracing library
In T340552, the official PHP OpenTelemetry client was effectively
rejected for inclusion in MediaWiki due to its size. Implement a minimal
tracing library instead that eschews conformance with the OTEL client
specification in favor of simplicity, while remaining capable of
emitting trace data in OTLP format and thus retaining compatibility with
any ingestion endpoint capable of handling OTLP.

In its current state, the library supports a basic feature set that
should be sufficient for basic tracing integration:

* Span creation, inclusive span activation and automatic parent span
  assignment,
* Span attributes and span kinds,
* Basic resource (process/request)-level metadata generation,
* Data export over OTLP.

Additional functionality, such as trace propagation, can then be
incrementally added to the library.

Bug: T340552
Change-Id: Ibc3910058cd7ed064cad293a3cdc091344e66b86
2024-10-09 15:55:31 +02:00
jenkins-bot
dd4f8bcad1 Merge "Expand tests for rename user maintenance scripts" 2024-10-09 13:11:42 +00:00
Amir Sarabadani
990c4c984f objectcache: Add support for sister keys in SqlBagOStuff
This would allow us to force parsercache idhash and idoptions keys next
to each other so when e.g. depooling 1 of 4 hosts in a parser cache cluster,
the amount of cache misses due to rehashing will be ~25% instead of ~%50.

This is similar to the implementation in WANCache and the same structure
has been used to make it consistent.

Bug: T373037
Change-Id: I920fe76e45298aeee6acf725324a5e1ed2b57a37
2024-10-09 12:15:52 +02:00
thiemowmde
b1c9ec74fa Remove meaningless @var documentation from constants
A constant is not a variable. The type is hard-coded via the value
and can never change. While the extra @var probably doesn't hurt much,
it's redundant and error-prone and can't provide any additional
information.

Change-Id: Iee1f36a1905d9b9c6b26d0684b7848571f0c1733
2024-10-09 09:33:12 +02:00
Timo Tijhof
b18121d98c rdbms,objectcache: Replace wgChronologyProtectorStash with MicroStash
Bug: T336004
Change-Id: I2f769aa703ce98b15fa0fe98eda092ff19c27d0a
2024-10-09 01:52:55 +01:00
C. Scott Ananian
1c3078b96c ParserTestRunner: consistent normalization of "known failure" output
Improve the output when a parser test fails because the "known failure"
output differs from the actual output, and use the same normalization
function which Parsoid's test runner does for this comparison.

Previously it would display the actual/expected output from the test,
which had no relationship to the "real" reason the test was failing.

Depends-On: I7ff5b27415d98e45d1364161ed6cdaac2d156a81
Change-Id: I0d56b60abb78e37d539267f744afb52c092cb997
2024-10-08 17:59:21 -04:00
bpirkle
27b5faf93b REST: Allow specifying param descriptions as MessageValue objects
Previously, parameter descriptions could only be specified as
strings. We want OpenAPI specs generated from parameter
definitions to be internationalizable, so allow specifying
descriptions as MessageValue objects, which can be translated
using normal MediaWiki mechanisms.

Associated improvements to ResponseFactory.

Bug: T376493
Change-Id: If1cbe4f7bfd5c375e64b802b666c0247d65b1ee0
2024-10-08 16:42:52 -05:00
jenkins-bot
121559810b Merge "ParserOutput::setPageProperty(): emit deprecation warnings for non-strings" 2024-10-08 21:17:48 +00:00