Commit graph

16 commits

Author SHA1 Message Date
Bartosz Dziewoński
c03cb71796 Use real type hints for services etc. in api/ApiQuery*.php
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

Followed by some manual review to make sure I'm not changing too much,
omitting some changes that looked too complicated and anything that
caused test failures, and some whitespace fixes.

Change-Id: Ie78be1c614985d7c2964156e454cc9266515dc18
2023-08-29 01:02:40 +00:00
Martin Urbanec
80bf808bb6 ApiQueryLanguageinfoTest: Do not pass a float to setFakeTime
ConvertibleTimestamp::setFakeTime is documented to
only take callbacks returning an int. ApiQueryLanguageinfoTest
violated this expectation, resulting in test breakage
(see I06c625abe351b2f189f5dbf6f331d34bb56004b2).

To get some integers to chose from, bump MAX_EXECUTE_SECONDS
to three.

Bug: T329609
Change-Id: I82d49a5e3a52c14dbd7e5324eb4c75cf7c33f3d2
2023-02-14 11:53:42 +00:00
Umherirrender
ade5816751 Use LanguageNameUtils::AUTONYMS/SUPPORTED instead of hard coded value
Easier to spot the documentation what happen with this option

Change-Id: I6764dff8f79a6e667a0f4f61336f6280c7f13ed2
2022-12-29 13:47:29 +01:00
thiemowmde
70aa9c8e35 Make use of ?:, ?? and ??= operators in mostly trivial cases
The motivation is to make the code less confusing. I hope this is the
case.

?? is an older PHP 7.0 feature.
??= was added in PHP 7.4, which we can finally use.

Change-Id: Id807affa52bd1151a74c064623b41d950a389560
2022-12-05 21:37:13 +01:00
Func
b5f3400c27 ApiQueryLanguageinfo: Allow fetching variant names from API
Variant names is stored in 'variantname-xx' messages and different from
language names.

Bug: T302200
Change-Id: If1b16f12a6867de7caa9a28e0370745780006bec
2022-10-05 14:35:40 +00:00
Reedy
f45fefec0e api: Replace numerous more deprecated constants
Change-Id: I498a315b8b4b56d5e2f939e797adbe0487cd7d07
2022-06-06 02:24:41 +01:00
Umherirrender
3f08cd753a Replace deprecated Language::fetchLanguageNames
Change-Id: Iecd5481edb4dae6c7911157e24c32a51f4438ab2
2021-12-05 21:11:49 +01:00
Umherirrender
9b41241cc8 api: Use fake timer to test ApiQueryLanguageinfo
The difference is that previously we used microtime(), which provides a
float, and now time() is used, which provides an int, but there is no
difference for the comparison.

Change-Id: If1463e0fc2a2526ab4d2af64830b73ae3bf330f6
2021-08-04 02:27:04 +00:00
Tim Starling
9c3c0b704b Use array_fill_keys() instead of array_flip() if that reflects the developer's intention
array_fill_keys() was introduced in PHP 5.2.0 and works like
array_flip() except that it does only one thing (copying keys) instead
of two things (copying keys and values). That makes it faster and more
obvious.

When array_flip() calls were paired, I left them as is, because that
pattern is too cute. I couldn't kill something so cute.

Sometimes it was hard to figure out whether the values in array_flip()
result were used. That's the point of this change. If you use
array_fill_keys(), the intention is obvious.

Change-Id: If8d340a8bc816a15afec37e64f00106ae45e10ed
2021-06-15 00:11:10 +00:00
Reedy
b80a9f4f6a Fix even more PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I5e04824d6fa6a4c36ce489850bb0ed7b4ac588f9
2020-05-16 00:51:14 +01:00
Lucas Werkmeister
3201bf5e39 Inject language services into ApiQueryLanguageinfo
Change-Id: I05a03d7a81aad3d9b592e062412eea1c1e9b57d8
2020-02-24 19:37:37 +01:00
Petr Pchelko
204fa7e509 Remove usages of deprecated Language methods
Change-Id: Iad3375b141b1d87c890baec6ecd16ed92f93e699
2020-02-16 00:45:48 +00:00
Peter Ovchyn
61e0908fa2 languages: Introduce LanguageConverterFactory
Done:
* Replace LanguageConverter::newConverter by LanguageConverterFactory::getLanguageConverter
* Remove LanguageConverter::newConverter from all subclasses
* Add LanguageConverterFactory integration tests which covers all languages by their code.
* Caching of LanguageConverters in factory
* Make all tests running (hope that's would be enough)
* Uncomment  the deprecated functions.
* Rename FakeConverter to TrivialLanguageConverter
* Create ILanguageConverter to have shared ancestor
* Make the LanguageConverter class abstract.
* Create table with mapping between lang code and converter instead of using name convention
* ILanguageConverter @internal
* Clean up code

Change-Id: I0e4d77de0f44e18c19956a1ffd69d30e63cf51bf
Bug: T226833, T243332
2020-02-03 11:38:03 +02:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Lucas Werkmeister
6ea72c551a Fix meta=languageinfo usage example
This switched between the generic uselang and a module-specific lilang
parameter a bit during development, and apparently an incorrect version
ended up being merged.

Change-Id: I004be4be318785ee1f59d609d8506d96644bc89d
2019-06-25 10:45:14 +02:00
Lucas Werkmeister
67b3cdc004 Add action=query&meta=languageinfo API module
This API module can be used to get information about all the languages
supported by this MediaWiki installation. Since parts of this
information, such as the fallback chain, are expensive to retrieve if
the localization cache is not populated, we apply continuation if the
request is taking too long (suggested by Anomie in T217239#4994301); we
don’t expect this to happen in Wikimedia production, though.

Bug: T74153
Bug: T220415
Change-Id: Ic66991cd85ed4439a47bfb1412dbe24c23bd9819
2019-06-03 12:46:03 +02:00