Commit graph

2762 commits

Author SHA1 Message Date
jenkins-bot
0b45e77a8b Merge "Language: Introduce getContentLanguageCode() service" 2024-10-16 14:15:12 +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
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
deba2439b7 Merge "REST: Allow specifying param descriptions as MessageValue objects" 2024-10-15 15:24:56 +00:00
jenkins-bot
55c4bb3cac Merge "statslib: Add MetricInterface::setLabels() convenience method" 2024-10-14 10:14:39 +00:00
jenkins-bot
17d6efe4c3 Merge "objectcache: Add support for sister keys in SqlBagOStuff" 2024-10-12 14:04:18 +00: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
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
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
a37de059aa Merge "ParserOutput: ensure all created ParserOutputs have a "start of parse" time set" 2024-10-07 23:13:54 +00:00
jenkins-bot
a4a53d00ac Merge "status: Log getMessage()/getWikiText() calls on good Statuses" 2024-10-06 09:53:02 +00:00
C. Scott Ananian
1e2af489ae ParserOutput: ensure all created ParserOutputs have a "start of parse" time set
*Most* implementations of ContentHandler::fillParserOutput() ensure
that the returned ParserOutput has had
ParserOutput::resetParseStartTime() called on it at an appropriate
time -- but not *all*.  This is a belt-and-suspenders fix that ensures
that every code path which creates a ParserOutput has *some* "start
time" defined.  This could be misleading if the parsing is done first
and the parser output is created at the very end of the parse, but in
all the code that I've looked at the ParserOutput is the first thing
created and so this default should be reasonable.

While we're at it, remove the parseStartTime from the serialized form
of the ParserOutput, because it is useless after the object is
unserialized.

Bug: T376433
Change-Id: I3bdf3996401a7d5ac4d8e1e5e6afb7ca410cbe6c
2024-10-04 19:14:37 -04:00
Yiannis Giannelos
fec9daae4e Use statslib for metrics emitted by HtmlOutputRendererHelper
Bug: T359476
Change-Id: If8bc5a7f7383dcb67dadf1f4c02d1b69d7c8fa53
2024-10-04 14:52:30 -04:00
Máté Szabó
a5049b481f status: Log getMessage()/getWikiText() calls on good Statuses
Why:

- Calling getMessage()/getWikiText() with a good Status is a logic error
  that converts the Status being operated on into a fatal one.
- However, this error is never logged anywhere, which can make it
  difficult to diagnose such cases, as seen in
  I17166e988bf389a5b03d4a74f539f7bec7f5997f.

What:

- Add a warning-level log for the case when getMessage() or
  getWikiText() is invoked with a good Status.

Bug: T374436
Change-Id: I3efae5c4c336156924f1c9b4186fa9142aaed9ca
2024-10-04 18:32:24 +02:00
James D. Forrester
91a37f53b4 Switch over a bunch of class_alias uses to actuals
Change-Id: Id175a83e71cc910eaee5d5890a9106872a3ca3b8
2024-10-03 17:09:36 +00:00
jenkins-bot
4627fe60af Merge "Add namespace to remaining parts of Wikimedia\Mime and Wikimedia\Stats" 2024-10-03 14:16:24 +00:00
jenkins-bot
db7ee3db99 Merge "Add namespace to remaining parts of Wikimedia\ObjectCache" 2024-10-03 14:02:47 +00:00
Aaron Schulz
9508801cc7 rdbms: avoid pcre.backtrack_limit in QueryBuilderFromRawSql::generalizeSQL()
Add some unit tests for this method.

Bug: T366640
Change-Id: I466c83a8d2b8fabcd4c30eb079273dfd52a31b71
2024-10-01 12:00:44 -07:00
jenkins-bot
0b58fa9602 Merge "installer: Consistently use double quotes when outputting settings" 2024-09-28 10:50:24 +00:00
James D. Forrester
cc28acc455 Add namespace to remaining parts of Wikimedia\Mime and Wikimedia\Stats
Bug: T353458
Change-Id: If0137003ab625017d322d57870448a02569668c3
2024-09-27 16:19:10 -04:00
James D. Forrester
53b67ae0a6 Add namespace to remaining parts of Wikimedia\ObjectCache
Bug: T353458
Change-Id: I3b736346550953e3b2977c14dc3eb10edc07cf97
2024-09-27 16:19:10 -04:00
James D. Forrester
9e5c1e8ac7 Add namespace to IDBAccessObject and DBAccessObjectUtils
Bug: T353458
Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
2024-09-27 16:19:10 -04:00
Máté Szabó
3263182512 installer: Consistently use double quotes when outputting settings
Why:

- The installer feeds several user-provided values, such as the site
  name, directly into LocalSettingsGenerator.
- There, these get passed through escapePhpString(), the output of which
  is safe when rendered into a double-quoted string, but fails if the
  input string contained single quotes and was rendered into a
  single-quoted string.

What:

- Consistently output all strings in LocalSettingsGenerator as
  double-quoted strings.

Bug: T372569
Change-Id: I27bb3c31d8e9957b4880d0faba8b79d121126a11
2024-09-27 14:53:46 +02:00
James D. Forrester
984076f98e Add namespace to includes/api classes
Bug: T353458
Change-Id: I3ea6b08c5018ba03ba45c5766e1f46e12f6b8597
2024-09-25 19:31:14 +00:00
jenkins-bot
ef41dedbd4 Merge "objectcache: Add regression test for MultiWrite dependency injection" 2024-09-24 04:38:56 +00:00
Timo Tijhof
70f9eb8f91 objectcache: Add regression test for MultiWrite dependency injection
Follows-up 4e596f5112 (I59266726ad), which fixed bug T318272, but
did not add a regression test for it.

Bug: T318272
Bug: T327158
Change-Id: Ia8af6671887d3914fdc761d8e5d10fd33fb40f88
2024-09-23 15:07:23 -07:00
jenkins-bot
b145754452 Merge "tests: Use ::class for class name resolution" 2024-09-21 13:48:10 +00:00
Umherirrender
8e039f2101 tests: Use ::class for class name resolution
Also use namespaced version of the class

Change-Id: Idce009e4d0a8e77f95244d95db008d64a2025c5f
2024-09-20 21:19:22 +02:00
daniel
84fe1b9ccd REST: Introduce discovery endpoint
The discovery endpoint provides basic information about accessing the
wiki's APIs, as well as a directory of available modules.

Bug: T365753
Change-Id: I161aa68566da91867b650e13c8aadc87cd0c428c
2024-09-20 17:02:59 +00:00
C. Scott Ananian
fe929a33e7 statslib: Add MetricInterface::setLabels() convenience method
This avoids repetition when you wish to have two different metrics
(say, a timer and a counter) use the same labels.

Change-Id: Ifb51bca3b8762e97e349d2868e42789494f262cb
2024-09-19 14:40:15 -04:00
jenkins-bot
a335696207 Merge "build: Remove exclude of MediaWiki.Commenting.PropertyDocumentation" 2024-09-19 05:34:38 +00:00
Umherirrender
f09beca7ca build: Remove exclude of MediaWiki.Commenting.PropertyDocumentation
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Enable the sniff to avoids that new code is missing type declarations.

Depends-On: I4b182fda29e9cb9719c26fd01a609de2453be56d
Depends-On: I1106dd167dc2188ed91d1884e979b5cea303f722
Depends-On: I2606072015d71b4bdda70a7c149d9f55ac205a3c
Depends-On: I90ecf85cb6f639af4be1947ccfbfb16d5b84cab3
Depends-On: Ib0402017e602ad3e79b7ffbb5b02bcedae1fab6b
Depends-On: I29bc609c5148668e533a9ed9f72b29f780f00dba
Depends-On: Ib6081f5519d2294bb14f81bf399f9c45315f2b69
Depends-On: Ifbc2ce0c68865c5d32689e56c6215a5099f7478b
Depends-On: I72c7dab67ef12d229fb232311e404467260d742d
Depends-On: Id994553eaeac181775ac782423ff53928ad45466
Depends-On: Id08ee260e320d8c97c2c3576d998af1b70952f27
Depends-On: I65636f2b97b44387c4320ebfb4be6c81d6f771b9
Depends-On: I897106d15c9e43f75eb006c35a14ac49edeb3ecd
Depends-On: I39ce744ee4f4a9356b0788b6e38ece9635a5ca49
Depends-On: I8a45487483c54b50576c8cbef3f8ea7b3b19969a
Depends-On: Id7ccd48e3bf626095e2d3929831b5d87ed0be948
Depends-On: I07ce1f37d1bfb18d6e73dd008a712b3ca60a80e9
Depends-On: Id75cb2e5fbee0fe7600f92473d876f23730d46b7
Depends-On: I217b9c906972c1f335e8e7d2b340e86a4d92c5a1
Depends-On: Ia1302c9c0528691436a0411ca62b651471811c98
Depends-On: I45c62ed8b6c2893b66f12dc60580c0267b475945
Depends-On: Ia8bbdc4dee59dfb487582dd514486ec8542951be
Depends-On: I9e5330601ded043ad24a99932fe3fa0ea6c427aa
Depends-On: I67bb532efff05b7fb01abec540620239cb4031b2
Depends-On: Ia205d578b9620960d967e2cbeb418e7e5af94dd4
Depends-On: Idf17719c875466810313f0fbbf16bc67f3e40059
Depends-On: I8b33b5f4d91c1935228e7010327dbc6ce138fc00
Depends-On: I3afaba387663320187c49ff1cdb2ff3ae01681ad
Depends-On: I48014b6464f3e7e2b7f083e67f517af0b1a9367e
Depends-On: I6ff2b1e91f28340f8f467a1d5e50cc132e142b95
Depends-On: I113b040321d27c84fe9b807c162736909e96fb20
Depends-On: I7dec01892a987a87b1b79374a1c28f97d055e8fa
Depends-On: I921c5cbe5b811c5ade9d9fad56ad3499ef8373e0
Depends-On: I46f46f1855ca32c89a276b06f4e2051ff541886e
Depends-On: I41ad89cc3112a2911ad40c55583bff2d7787da68
Depends-On: I1f306a3925d6768209a06e70082598b2f70cd319
Depends-On: Ifc27750207edc09e94af030d882b6f1a5369cf98
Depends-On: I81544e367543846654b4d03fcad5adad71e23751
Depends-On: I56a1d27ba2dfbcdd929a0e0c96664bc2a31e38f2
Depends-On: I6dd402a5bca0c2136595faedae315959bbcf17d9
Depends-On: I82b4f543ed004fc960b6b1f8ac718db2a63a40fe
Depends-On: I1da4b272a6b28c419cc8e860d142dae19ca0bbcf
Depends-On: I6087dcdac761916359009548beb5210671a32ee5
Depends-On: I73c413727a63d14efb5028b27128784c98724110
Depends-On: Ifddb6a95d0d81fef4c480ef96dbc1fc9cbb93401
Change-Id: I97a8b6fbe17a24ddffcc6a3fd4ea4451b59ba790
2024-09-18 17:27:01 +00:00
Umherirrender
41f6d9eee4 tests: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: Ifc27750207edc09e94af030d882b6f1a5369cf98
2024-09-18 17:25:42 +00:00
jenkins-bot
82b7b8469f Merge "language: Add missing documentation to class properties" 2024-09-17 22:58:47 +00:00
Umherirrender
eb28edd84e language: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: I73c413727a63d14efb5028b27128784c98724110
2024-09-17 18:25:25 +00:00
bpirkle
90494183bb REST: add restbase compat error handling mode
In order to replace certain /api/rest_v1 endpoints, we
need to have something in MediaWiki that generates a compatible
responser. The MediaWiki REST API error format does not match
RESTbase. So the easiest approach seemed to be to
add a compatibility mode, triggered using the x-restbase-compat
header. This can be set via the gateway when rerouting the request.

Bug: T374136
Change-Id: I73934940d367be52941bd27861c248ab5bcfb5d2
2024-09-16 18:09:12 -05:00
jenkins-bot
634373a3cf Merge "REST: add restbase compat mode for some endpoints" 2024-09-16 19:21:57 +00:00
jenkins-bot
102ab8b972 Merge "htmlform: Add missing documentation to class properties" 2024-09-16 13:35:00 +00:00
daniel
602f0ab595 REST: add restbase compat mode for some endpoints
In order to replace the /api/rest_v1/page/title/{title} endpoints, we
need to have something in MediaWiki that generates a compatible
responser. The v1/page/{title}/bare and v1/revision/{id}/bare endpoints
are functionally equivalent, so the easiest approach seemed to be to
add a compatibility mode to them. The compatibility mode is triggered
using the x-restbase-compat header, which can be set via the gateway
when routing the request from /api/rest_v1/page/title/.

Bug: T374136
Change-Id: I4af7ff5325660ae30faebb24753b9dc1c3acb2b3
2024-09-15 16:41:21 -05:00
Umherirrender
aed646001c htmlform: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: I1f306a3925d6768209a06e70082598b2f70cd319
2024-09-14 11:49:05 +00:00
jenkins-bot
df07b07b4a Merge "libs: Add missing documentation to class properties" 2024-09-14 02:38:58 +00:00
jenkins-bot
a27ade70ee Merge "Use const keyword for constant list of strings or ints" 2024-09-13 18:08:57 +00:00
Umherirrender
da63db52af libs: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: I46f46f1855ca32c89a276b06f4e2051ff541886e
2024-09-13 17:24:12 +00:00
jenkins-bot
ab14c236cd Merge "rdbms: Add missing documentation to class properties" 2024-09-12 23:25:03 +00:00
Umherirrender
465777f188 Use const keyword for constant list of strings or ints
Also changed visiblity of some to private

Change-Id: I113b040321d27c84fe9b807c162736909e96fb20
2024-09-11 23:16:24 +02:00
Umherirrender
e38e3d1c49 rdbms: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: I9e5330601ded043ad24a99932fe3fa0ea6c427aa
2024-09-11 21:24:59 +02:00