Commit graph

346 commits

Author SHA1 Message Date
DannyS712
845094fe3d Language: retrieve MainConfig instead of using a bunch of globals
Change-Id: I791af9197a4a53723adf2869d7b3b9f41fe9c059
2022-03-15 02:58:42 +00:00
Umherirrender
b8bb463dba language: Fix order of arguments in truncateHtml()
The arg order of truncate_endBracket is tag, type, lastCh, tags, but the
type and lastCh are in wrong order. This is only relevant when $tag is
still non-empty after the loop, which is only happen for unclosed html
tags.

Found by phan strict checks

Change-Id: I08d6926dd4aac8ccc86c776f57a26437013ecb1d
2022-03-08 22:34:33 +00:00
jenkins-bot
dcf44db379 Merge "Use ObjectFactory in LanguageConverterFactory" 2022-02-24 18:11:54 +00:00
Umherirrender
a9bc9f8a04 Use ObjectFactory in LanguageConverterFactory
Use the object factory to inject service into TrivialLanguageConverter
class.
The other language converter classes does not use service directly.
The classes are using indirectly services in some function of
the parent class, which needs injection as well (tracked with T294185).

Needs fallback to global state in TrivialLanguageConverter, because the
class is used in extensions integration tests

Change-Id: If72d054d062a4f357e12c5b168e118bfafffd626
2022-02-24 17:47:09 +01:00
Timo Tijhof
8d406bbcd6 phpcs: Disable Generic.Files.LineLength for test files
There is a common and reasonable need for longer lines in tests.
The nudge for shorter lines doesn't seem valuable here. The natural
breaks will likely still fall in 80-100 given the enforced practice
for non-test code, e.g. whether through habit, or 80-100 column markers
in text editors, or the finite width of diff and code review
interfaces.

Change-Id: I879479e13551789a67624ce66f0946d2f185e6ee
2022-02-18 18:32:05 +00:00
Func
7f74a2e50c Clean up tests that misused the parameters of assertSame/Equals
Expected value is the first parameter to assertSame() or assertEquals().
And turn to use assertCount() for some assertions aginst count of array.

Based on code search `assert(?:Same|Equals)\(.+,.+expected` and I look
through files roughly, so some assertions that don't contains 'expected'
are also fixed. In the meantime, some assertions that I am not clear
about are not touched.

Change-Id: I75798b60d29fd19b33f4fdf34ed3c788db420d01
2022-02-08 07:21:10 +00:00
Amir E. Aharoni
ccd3d67546 Delete (month)-date messages
They were added in
Idca1bfc9f4eff7dc561253424f15c15ea007ab6d

See also bug T49211.

However, it looks like they are not actually used anywhere
except one test.

Change-Id: Id409e799f172bb6a76e9ba248cd2f4921696398b
2021-12-26 14:46:03 +02:00
jenkins-bot
d0507a2740 Merge "Use hasVariant in loop to determine parent language in LanguageFactory" 2021-12-07 00:03:05 +00:00
Func
cdd5b4db86 Use hasVariant in loop to determine parent language in LanguageFactory
Code of some language's parent language can't simply strip out the subcode.
e.g. ike-cans should get iu.

Change-Id: I4cf5bb1ddc463a8d98064451dd8e4dbebeca96e9
2021-12-06 13:52:46 +00:00
Kosta Harlan
d55dc6d953 phpunit: Use submap assertion for LanguageIntegrationTest
LanguageIntegrationTest asserts strict equality for namespaces, but
other extensions which add to namespaces are not accounted for. This
seems to work OK when LanguageIntegrationTest is run alongside all other
PHPUnit tests but causes failures when run on its own (see console
output in T297078).

Asserting the submap should be sufficient for this test, AIUI.

Bug: T297079
Change-Id: I708c79f452a3eede1bae1422f27160a32db0e4dd
2021-12-06 10:02:18 +01:00
Thiemo Kreuz
d51c0032af Tests: Update syntax referencing classes and internal functions
Change-Id: Icd577d522a24cb636305ea7f1067a4f75816ba34
2021-12-02 17:07:49 +01:00
TChin
349819dc5a Add Message/MessageValue user group member parameter type
* Added ParamType::OBJECT, which allows Stringable objects to be passed into MessageValue

Bug: T278482
Change-Id: Ib4990f87d4ad70b7525d7aa05c8b97e90c121674
2021-11-16 11:24:35 -05:00
TChin
fb4e7a803a Add message parameter type for User Groups
Bug: T278482
Change-Id: I45da5f73f8920b79b57c02776a05d0268d3480f2
2021-10-14 15:02:13 -04:00
Alexander Vorwerk
04dfdc3653 Hard deprecate User::setOption()
deprecated since 1.35

Bug: T277818
Change-Id: Ic251d624e5d6fa857aa92f9c5dd3df44714ac610
2021-09-26 17:18:54 +02:00
Umherirrender
2e4ee47c3d Cleanup mixed space/tab line indent
Change-Id: I833052a656b1ce419c0929f6f0514f2a33c2c4cc
2021-09-04 00:52:31 +02:00
Fomafix
c7ebc1ec44 Fix various typos in documentation
Bug: T201491
Change-Id: I144c120cc88bda723c8608ed7fb0ccb709f295f1
2021-08-23 09:03:44 +00:00
Timo Tijhof
7c39f76452 Move Language subclasses to includes/
Depending on which namespace we want these classes to have after
T166010 they could either stay in includes/languages/ (plural) in
their own MediaWiki\Languages\-namespace dedicated to Language
subclasses, or they could go in into a subdirectory like
`includes/language/languages/` if we want to keep them in the same
top-level namespace as other Language classes and services, but in
a more nested namespace.

For now, I've made the smaller change and kept the Language subclasses
in their own directory directly under includes/, not nested further.

Bug: T225756
Change-Id: I01015424707b442853879fd50c97f00215e5c2fa
2021-08-04 23:44:46 +01:00
libraryupgrader
5357695270 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs now pass and were enabled:
  * Generic.ControlStructures.InlineControlStructure
  * MediaWiki.PHPUnit.AssertCount.NotUsed

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)

Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
2021-07-22 03:36:05 +00:00
DannyS712
2696c06a2b LanguageConverter: stop reading from $wgUser
Use RequestContext::getMain()->getUser() instead.
Given that there is an explicit check if the user is safe
to load, this should be fine - if the RequestContext
doesn't already have a user, it'll create one via
User::newFromSession() and then the isSafeToLoad()
call will fail.

Bug: T243708
Change-Id: I06906681e1c1e9ea3ef3c6e4fddcea7871bf164f
2021-07-14 04:19:15 +00:00
jenkins-bot
fbe639c1d1 Merge "Use correct SI prefix "zetta" instead of "zeta"" 2021-06-30 11:16:58 +00:00
Fomafix
d211570229 Use correct SI prefix "zetta" instead of "zeta"
The existing system messages
* size-zetabytes
* size-zetapixel
* bitrate-zetabits
are kept for compability and are now deprecated.

Bug: T283958
Change-Id: I9460e3b8c2655e9e68ce9147076f4bb1da02237f
2021-06-29 19:11:11 +00:00
DannyS712
4f9970f30b Fix a bunch of random typos
* yeild -> yield
* paramter -> parameter
* seperator -> separator
* neccesary -> necessary
* inital -> initial
* intial -> initial
* repsonse -> response
* retreived -> retrieved

Bug: T201491
Change-Id: I461941b027590997448f3bdd8a137a48bb338beb
2021-06-29 11:32:04 +00:00
Thiemo Kreuz
2ba01c7ee7 Remove some more comments that literally repeat the code
… including PHPDoc tags like `@return <type> $variableName`.
A return value doesn't have a variable name. I can see that
some people do this intentionally, repeating the variable
name that was used in the final `return $var;` at the end
of a method. This can indeed be helpful. I leave a lot of
these untouched and removed them only when it's obviously
wrong, or does not provide any additional information in
addition to what the code already says.

Change-Id: Ia18cd9f25ef658b08ad25b97a744897e2a8deffc
2021-06-18 21:23:56 +00:00
daniel
4880a82555 Parser: remove Title from method signatures
Bug: T281068
Change-Id: I3280e38dd82d71845c343eeb911e71dd33bb380b
2021-04-29 18:11:46 +02:00
Daimona Eaytoy
535d7abf59 phpunit: Mass-replace setMethods with onlyMethods and adjust
Ended up using
  grep -Prl '\->setMethods\(' . | xargs sed -r -i 's/setMethods\(/onlyMethods\(/g'

special-casing setMethods( null ) -> onlyMethods( [] )

and then manual fix of failing test (from PS2 onwards).

Bug: T278010
Change-Id: I012dca7ae774bb430c1c44d50991ba0b633353f1
2021-04-16 20:15:00 +02:00
daniel
1ae400bb93 Remove some deprecated methods from the Language class
The following methods and fields in the Language class, deprecated since
1.35, have been removed:
- findVariantLink()
- convertTitle()
- updateConversionTable()
- classFromCode()
- clearCaches()
- mConverter

Change-Id: I9281f37be3a374e072d6afde8f352138af13adbe
2021-04-13 13:26:27 +00:00
Umherirrender
cfcb3e4785 Use ::class for class name
This works also for non-existing classes,
because it is resolved on compile time

Change-Id: Id3132341856fb1eb20e8b494bb4acdfe3a394db6
2021-04-08 21:17:42 +02:00
jenkins-bot
04626a940f Merge "Add converter for the Talysh language (tly)" 2021-02-23 12:45:31 +00:00
James D. Forrester
5a622b6a2e build: Upgrade eslint-config-wikimedia from 0.17.0 to 0.18.1
Change-Id: I5e3687be2b197134578126e1b890ee37dbc1bc1b
2021-02-18 08:39:09 -08:00
Amir Aharoni
14d363c29f Add converter for the Talysh language (tly)
Mostly copied from UzConverter.

This is a very simple converter, with bidirectional one to one
correspondence: for every Latin letter there is a corresponding
Cyrillic letter and vice versa. There are no digraphs or punctuation
to convert.

The Latin alphabet is the primary one used for this language today,
and will probably remain so for the foreseeable future, so "tly" remains
the usual code, and "tly-cyrl" is added for Cyrillic.

Language name is changed:
* The main language name is now Latin.
* The word "language" ("зывон") is removed.
* The spelling of the word "Talysh" is based on the Pireyko dictionary.

Bug: T258975
Change-Id: I552e07967ea82e03c413a0b10b129a846aa007c7
2021-02-17 13:49:36 +00:00
Umherirrender
a1de8b8700 Tests: Mark more more closures as static
Result of a new sniff I25a17fb22b6b669e817317a0f45051ae9c608208

Bug: T274036
Change-Id: I695873737167a75f0d94901fa40383a33984ca55
2021-02-09 02:55:57 +00:00
jenkins-bot
9fa1d86728 Merge "Improve some class properties documentation in tests" 2021-02-05 02:52:22 +00:00
Peter Ovchyn
d8f54cae8b Language: Turn public properties into Getters in LanguageConverter based hierarchy
The main goal is to simplify the construction of the LanguageConverter and
avoid using constructors for derived classes.

In order to hard-deprecate removed property, DeprecationHelper::deprecatePublicPropertyFallback
was introduced.

Bug: T253834
Change-Id: Ib167982e4e872cfdf0fbcb78b7ca597f5ac8d60a
2021-02-03 15:17:42 +02:00
DannyS712
210bbe84d4 LanguageConverterTest: fix assertStringNotContainsString call
Autofix in codesniffer was wrong, see T273624

Follow-up: Idb413be4b8cba8611afdc022af59810ce1a4531e
Change-Id: I97c174661ba9ed3e8da7f6b164666d53f36e9fa3
2021-02-03 04:00:52 +00:00
Umherirrender
205f141bb8 Improve some class properties documentation in tests
Change-Id: Id9c9e56865cf9a6bb112be37a5674ec753604fb1
2021-02-02 16:48:15 +00:00
Umherirrender
62002cdcf1 build: Update mediawiki/mediawiki-codesniffer to 35.0.0
Change-Id: Idb413be4b8cba8611afdc022af59810ce1a4531e
2021-01-31 13:34:38 +00:00
jenkins-bot
eb4b304ed8 Merge "Add missing @param and @return to documentation in tests" 2021-01-30 15:22:33 +00:00
vladshapik
3669d658f2 LanguageConverter: add test for deeper checking of each converter`s work
LanguageConverterIntegrationTest was added. It checks work of each converter with providing of long texts to translate. It must check each converter(includes/language/converters) as much as possible.

Bug: T272164
Change-Id: I4504b8071c4ae0427375a6c1acffd62d4e6121b5
2021-01-29 14:12:31 +02:00
Amir Aharoni
0e68b408c4 Update the converter for the Tashelhit language (shi)
The alphabets are based on what is used in
"Dictionnaire Général de la Langue Amazighe Informatisé"
by IRCAM (https://tal.ircam.ma/dglai/lexieam.php, DGLAi).

This was also requested by the community in the Tashelhit
Wikipedia Incubator.

Changes:
* Tests are enhanced to cover the whole alphabet.
* The Latin letter š is replaced with the letter c as
  the equivalent of Tifinagh letter ⵛ.
* The Tifinagh letters ⵠ and ⵒ are eliminated
  because they are not used in the Moroccan version
  of Tifinagh, as presented in the DGLAi.
* The Latin letters O, P, V are converted to the
  Tifinagh letters ⵓ, ⴱ, ⴼ, which are the same letters
  that correspond to the Latin letters U, B, and F.
* Greek Gamma and Epsilon characters are replaced with
  the corresponding characters from the Latin range.
* All the non-ASCII Latin letters are added to
  the uppercase-lowercase Latin conversion.

This is the first patch in a series to fix the most important
issues listed above. It's kept minimal to make reviewing easier.
There will be more patches to fix readability and public/private
members, and to add more tests.

Change-Id: I7134216457b12018fd187ca7200e45c1b5a67471
2021-01-25 14:40:55 +00:00
Umherirrender
7691dbeca9 Add missing @param and @return to documentation in tests
Change-Id: Ic663e81cca0bf007804a70772250914a85f1fef4
2021-01-22 19:57:25 +01:00
Umherirrender
0347fd0631 Improve some function documentation in tests
Also fix some whitespaces

Change-Id: Ibed50a4f07442d3f299cf545c16f5dbb5f27a411
2021-01-14 22:13:55 +01:00
jenkins-bot
64fd98b19a Merge "LanguageConverterTest: use some data providers" 2021-01-14 15:34:15 +00:00
DannyS712
8dbcddb333 LanguageConverterFactoryTest::codeProvider simplify using a loop
Change-Id: I06adfcd43ef846124742d901e15c98e92bfc9bd1
2021-01-14 08:43:02 +00:00
DannyS712
f3e79c753b LanguageConverterTest: use some data providers
Change-Id: If59a636af0cf410a25cc36956d62d3f5a2deb1df
2021-01-12 12:56:03 +00:00
DannyS712
6a93b0ca93 More misc test cleanup
* parent::setUp() should be first, and ::tearDown()
  should be last
* Move tests that directly extend PHPUnit\Framework\TestCase
  to /unit

Change-Id: I1172855c58f4f52a8f624e6d596ec43beb8c93ff
2020-12-24 00:52:06 +00:00
David Kamholz
9cb5187944 Implement Balinese language converter
This patch implements the BanConverter class for Balinese. Its purpose is to transliterate Balinese in Balinese script to Latin script. Latin to Balinese is not currently supported, because (1) the Latin transliteration is not fully one-to-one, (2) I'm not aware of any users who currently need Latin to Balinese.

The converter supports three distinct Latin transliteration variants: ban-dharma, ban-palmleaf, and ban-puri-kauhan-ubud. All three variants have been requested by different Balinese community members working with Balinese palm-leaf manuscripts. ban-puri-kauhan-ubud is the default, as it is the most familiar to lontar scholars, but Balinese Wikisource users will be able to select their preferred variant via a user script.

Conversion is accomplished via ICU Rule-Based Transliterators, bindings for which are available through the Intl extension.

This patchset adds the abstract class LanguageConverterIcu and has BanConverter inherit from it (makes future ICU-based LanguageConverters easier).

Bug: T263082
Change-Id: Ic3a46a215fbf020a022726e6b130b1d25496e284
2020-12-21 12:45:41 -08:00
jenkins-bot
02342b9065 Merge "Don't access $wgRequest from User" 2020-12-16 05:06:16 +00:00
Tim Starling
6b2a52181f Don't access $wgRequest from User
Some User methods fail if they are called before $wgRequest is
set. But according to the Setup.php comment, it is only set for b/c.
The global request object can be lazy-initialised at any time.

This is sufficient to avoid T263911 (loss/obfuscation of the $wgServer
error message).

In tests, try to keep $wgRequest and RequestContext::$request in sync.
Introduce MediaWikiIntegrationTestCase::setRequest() which sets both at
once, and use that instead of setMwGlobals() or direct assignment.

BlockManagerTest was accidentally exploiting the fact that the global
context request and $wgRequest were separate objects. Making them the
same causes session cookies to appear in the response, breaking the
cookie counts. Use a new response for the test.

Bug: T263911
Bug: T245940
Change-Id: I2be99f7251a837bc6b62be0b152038157dec10f2
2020-12-16 12:21:00 +11:00
DannyS712
9c47a99639 LanguageConverterTest: reduce direct references to $wgUser
Should be a no-op, doesn't actually reduce the places where $wgUser
is set, just reduces the number of hits in codesearch and makes the
future migration of LanguageConverter to not use $wgUser a bit
easier

Bug: T243708
Change-Id: Ieb04b0e760dd37e037a95408ef429ac5c510f1d9
2020-12-14 21:24:17 +00:00
Umherirrender
12e15e410b LanguageClassesTestCase::setup: Validate language code
This trait is used in class LanguageIntegrationTest, resulting in the
language code "integration" being used, which is an invalid language.

Change-Id: I9398015bb0e85eb26116bb8608c8f39216ce8204
2020-12-13 17:19:57 +00:00