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
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
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
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
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
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
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
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
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
Remove the "target" column
Add a column "type" with fields "Blocked"/"Unblocked"
Add Jest test for TargetBlockLog
Bug: T368111
Change-Id: I3e9145df62046baaa3fe762a6f57c932a976508c
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
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
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
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
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
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
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
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