Commit graph

1524 commits

Author SHA1 Message Date
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08:00
Yuri Astrakhan
6fe0f40e8c Comments: Added phabricator IDs to bz bug #s
Change-Id: Ia8d4e570e78c62e5c26bda0264fbf1efc74e58a2
2016-10-24 19:56:07 +00:00
Amire80
7d28ef7bd7 Add a @throws doc line to getGrammarTransformations() in Language.php
Follow up to
I6b9b29b7017f958d62611671be017f97cee73415

Change-Id: I65b4a7b482238d2df97639f41f05af8566686414
2016-10-21 15:34:19 -07:00
Amire80
9bf67190b3 Remove unreachable code after an exception
Follow up to
I6b9b29b7017f958d62611671be017f97cee73415

Change-Id: Ib3ccbb103097a50f04b798a4ff33eedc64e62aef
2016-10-21 13:39:07 -07:00
Amir E. Aharoni
df5a848de8 Make grammar data loadable as an RL module and usable in JS
* Load the data of this variable from a JSON file to the same
  data structure that ResourceLoader uses for digitTransformTable,
  pluralRules, etc.
* Change the JSON structure to ensure the order of the rules.
  Otherwise JavaScript processes the keys in a random order.
* Delete the grammar code from JS and replace it with
  the same logic that is used in PHP for processing the data.

For now this is done only for Russian.

The next step will be to make the PHP and JS
data processing logic reusable.

Bug: T115217
Change-Id: I6b9b29b7017f958d62611671be017f97cee73415
2016-10-21 12:25:16 -07:00
Andrew Harris
66844a8176 Change documentation of formatTimePeriod
Currently, the function formatTimePeriod does not have a very descriptive
documentation and has a TODO tag on it to change the documentation
Change the documentation to be more descriptive and remove the TODO

Change-Id: Idde711f1d3d6cbe0ecab0c3b49c68a4876d9e8b2
2016-10-13 17:43:44 +00:00
Fomafix
7de07e8991 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Change-Id: I06d9e043730accc4ae71b927e0f8229f0fc3b340
2016-10-11 17:25:10 +00:00
Amir Sarabadani
9850c542c6 Clean up array() syntax in docs, part VII
Last part

Change-Id: I38f015e2122ef4fd2d2141718bd889794c29f06c
2016-09-27 06:53:25 +03:30
zppix1
b60a467f58 Add Localisation to the links, add the link to Localisation in Languages/Language.php
Change-Id: I996d09f38a007195ba9734e13f10611c4ca1242c
2016-09-17 01:33:37 +00:00
Amir Sarabadani
aac0f95c22 introduce {{#time: xiz}} for days passed in the year
Discussed in the community

Change-Id: I4d5f638d7f0635df2a0a253a3b3bfe278a0aed0e
2016-08-26 18:38:04 +04:30
jenkins-bot
abb4d29b54 Merge "Introduce {{#time: xit}} for days in the month in Iranian calendar" 2016-08-23 12:54:48 +00:00
Chad Horohoe
02f9963f07 Remove useless check for MEDIAWIKI definition
This class isn't any more special than others, it can be autoloaded
like all the others and there's nothing to execute in the file scope

Change-Id: I7c415025c9c15cf19110f39452df3a14e44bf6f9
2016-08-18 10:15:10 -07:00
Amir Sarabadani
c13b8773fc Introduce {{#time: xit}} for days in the month in Iranian calendar
I was asked by community members to build this

Change-Id: I4b884ce3b72b2fcae6b0c11130bf91f9e67dedf2
2016-07-31 18:06:50 +04:30
Brion Vibber
3b5f60f2c8 Remove old Esperanto character conversion support
Deletes LanguageEo.php class which only had remains of the server-side
character conversion (sx <-> ŝ, etc). This is being obsoleted in favor
of client-side IMEs provided by UniversalLanguageSelector extension.

Removes deprecated $wgEditEncoding, which was only used for this.

Turns Language::recodeInput() and Language::recordForEdit() into no-ops
for any old or extension code that happened to still use them.

Bug: T62677
Change-Id: Ib647353538d258dee941f2f7c571191060bc9c7d
2016-07-18 19:20:49 +00:00
Marius Hoch
9ca0f6c620 Only attempt to calculate the TTL in Language::sprintfDate if needed
Change-Id: Ifd24c9206be05bb4fd2277efc574c9d1018e1957
2016-06-23 12:36:25 +02:00
Max Semenik
3b89194788 Move mbstring initializaton to Setup.php, add checks
Bug: T137509
Change-Id: Ib3496c9465a7b229b97793c6fa5dafb878c04968
2016-06-13 21:47:47 +00:00
Fomafix
796d62d034 Language: Introduce new method equals( Language $lang )
Use

 $lang->equals( $wgContLang )

instead of

 $lang->getCode() === $wgContLang->getCode()

Change-Id: Id7ed6a21ce5e2ea2887ec98c7bd9d3eba83d733b
2016-05-16 22:33:33 +00:00
Ricordisamoa
cd7da66fb5 Add missing 'public' keywords to some more Language methods
All of them are already being used outside the class:
* getMonthAbbreviation
* getMonthAbbreviationsArray
* getWeekdayName
* sprintfDate
* userAdjust
* date
* time
* timeanddate
* getMessage
* iconv
* ucfirst
* uc

Change-Id: I63ec93858cebc02cdf3b9b042eddf4ef620cc110
2016-05-04 16:02:39 +02:00
jenkins-bot
75cdcc9400 Merge "Fix wrong @return type hints in Language::tsTo… methods" 2016-04-19 12:12:34 +00:00
Thiemo Mättig
6209fe38e4 Fix wrong @return type hints in Language::tsTo… methods
Change-Id: Ic4dec8e8612021f010734037b6c3527bef2fe04a
2016-04-19 12:18:20 +02:00
jenkins-bot
bb333d91a4 Merge "Show absolute block expiry in user timezone on block logs" 2016-04-09 19:37:29 +00:00
umherirrender
afd72226b8 Show absolute block expiry in user timezone on block logs
For this add an user parameter to Language::translateBlockExpiry.
This allows the function to display the absolute block expiry in the
user's time zone. Use this when formatting block log entries.

This also avoids the use of $wgUser

Bug: T131241
Change-Id: If0a1d3c88bb4242a016eb9b2df115413de786149
2016-04-09 20:57:33 +02:00
Kevin Israel
5b48bf1b92 Clean up after "Kill mbstring fallbacks"
* Removed fallback code from Language, the associated data file
  (Utf8Case.ser), and the code to generate that data file.
* Removed comment in LanguageFi that "mb_substr has a compatibility
  function in GlobalFunctions.php".
* Removed check for mbstring in bench_utf8_title_check.php.
* In the tests for StringUtils::isUtf8():
  * Removed separate test for the non-mbstring code path.
  * Removed mentions of mbstring from function names and assertion
    messages, since mb_check_encoding() is now always used.
* Also updated the comment in StringUtils::isUtf8() referring to
  PHP 5.3, which is no longer supported in MediaWiki, to indicate
  that the same issue also exists in old versions of HHVM. (If
  we don't have to support 3.4 or older, then the function could
  be deprecated and removed if desired.)

Follows-up 943563062f.

Change-Id: I55e5cd534b849c6ea06a7fadacbbf34a12d87ebe
2016-04-07 09:02:37 -04:00
Ricordisamoa
aab4b2e078 Add missing 'public' keywords to some Language methods
All of them are already being used outside the class:
* getFallbackLanguages
* getBookstoreList
* getFormattedNamespaces
* getNsText
* getFormattedNsText
* getGenderNsText
* needsGenderDistinction
* getNamespaceAliases
* getNamespaceIds
* getNsIndex
* getVariantname
* getDatePreferences
* getDefaultDateFormat
* getDatePreferenceMigrationMap
* getImageFiles
* getExtraUserToggles
* getMessageFromDB
* getMonthName
* getMonthNamesArray
* getMonthNameGen

Change-Id: Iff5495596c5a711259c45b4d57c453aad9526a9a
2016-03-24 14:02:50 +01:00
Reedy
b5656b6953 Many more function case mismatches
Change-Id: I5d3a5eb8adea1ecbf136415bb9fd7a162633ccca
2016-03-19 00:20:58 +00:00
jenkins-bot
8170af4935 Merge "Use an example with working digit transformation" 2016-03-14 09:54:30 +00:00
Siebrand Mazeland
b98dc6ced8 Update and correct documentation in Language class
Change-Id: I1d530bded0da7133f9b5120b515f32fc87507c84
2016-03-11 15:09:47 +00:00
Siebrand Mazeland
288e1ad503 Remove deprecated Language::getLangObj()
Was deprecated since 1.24. There were no uses in Gerrit extensions

Change-Id: I7ca08416d10fbba5222cb1a1fde75b697d354b09
2016-03-08 21:44:26 +00:00
Siebrand Mazeland
67d783b50e Remove deprecated Language::specialPage()
Was deprecated since 1.24. There were no uses in Gerrit extensions

Change-Id: If67456a62cb7d9688793d876508f0f168f3bb1ff
2016-03-08 21:43:21 +00:00
Siebrand Mazeland
182e45f31a Remove deprecated Language::GetLanguageName()
Was deprecated since 1.20. Uses in Gerrit extensions have been replaced.

Change-Id: I623e82ec1d9ade4da05f2eae15afdf65aa04109b
2016-03-08 21:38:59 +00:00
Siebrand Mazeland
19cd88808c Remove deprecated Language::getTranslatedLanguageNames()
Was deprecated since 1.20. There were no uses in Gerrit extensions

Change-Id: I0b16c0f146ecbee81921b5823b32776414f6945c
2016-03-08 20:26:51 +00:00
Siebrand Mazeland
4f03894063 Remove deprecated Language::getLanguageNames()
Was deprecated since 1.20. Uses in Gerrit extensions have been replaced.

Change-Id: I2011d3e209915ddbbafdbdfff0279ea7cc5b9125
2016-03-08 20:26:34 +00:00
Matthew Flaschen
b341b63243 Use an example with working digit transformation
Change-Id: I6424774a4cf720fe85a431ff12e5d5c61c9bfcde
2016-03-07 20:14:34 -05:00
Bartosz Dziewoński
c161c46d26 Improve code suffering from PHP 5.3's lack of support for foo()[]
I searched for /\$(\S+) = (.+?\(.*?\);)\n.*?\$\1\[/, ignored
everything involving isset(), unset() or array assigments, then
skimmed through the remaining results and changed things where they
made sense. These changes were not automated, so please review them.

Change-Id: Ib37b4c66fc57648470f151ad412210b3629c2538
2016-02-28 22:49:20 +01:00
Fomafix
6b976d825a Update comments about language codes
* RFC 3066 is obsoleted by RFC 4646.
* RFC 4646 is obsoleted by RFC 5646.
* All are also known as BCP 47.
* Language codes must treated as case insensitive.
* There exist conventions for the capitalization of some of the subtags.
* Write a space between BCP and 47 in comments.
* http://www.adobe.com/devnet/xmp/pdfs/XMPSpecificationPart1.pdf is not available.
* https://wwwimages2.adobe.com/content/dam/Adobe/en/devnet/xmp/pdfs/XMP%20SDK%20Release%20cc-2014-12/XMPSpecificationPart1.pdf
  is the new position.

Change-Id: I91e305fd5754cf4dedf8fd7460f7d3375f792c89
2016-02-19 07:31:51 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
jenkins-bot
d4ecfc1a5c Merge "Don't modify $wgHooks on language object construction" 2016-02-11 04:05:56 +00:00
Tim Starling
f43e0d840f Use autoloader for PHP data files instead of include/require
Move ZhConversion.php and Names.php to languages/data and make them both
expose their data as static class variables instead of in the local
scope. This means that the autoloader can be used to load the data,
which is efficient and secure. This also makes additional request-local
caching of the arrays unnecessary.

Change-Id: Iafb96ac4165d0965fcb9a69f1d0a91139ea9790c
2016-01-30 13:08:46 +11:00
Tim Starling
059fd9a2ae Don't modify $wgHooks on language object construction
Previously various language objects would install a hook to update the
shared conversion table cache when the object was constructed. This is
not a good idea since language objects may be constructed even when they
are not the content language, but only the content language is
associated with variant conversion and the conversion cache.

Instead, have WikiPage call a method on $wgContLang directly. I put this
with message cache update since the logic is almost identical.

Change-Id: Ief9c0ef993e39645e74a6e158cb4e6e2139ce91d
2016-01-29 15:03:56 +11:00
Florian
e0ad37d49a Remove Language::armourMath() and friends
Change-Id: I0ce18bce2d9b5787221e2dabff143de9792abb3a
2016-01-07 09:21:53 -08:00
Fomafix
d680c77bf9 Simplify Language::getFallbackFor
This avoids a redundant check of the language code.

Change-Id: Ifbe23b80a9d8fd5c3aa06f6656dbf2699a318003
2015-12-16 09:51:53 +00:00
Timo Tijhof
5a9e862063 Language: Convert names cache from MapCacheLRU to HashBagOStuff
Change-Id: I3237c8ed97d23e82caa171d936ecb5745a2fe3d5
2015-11-09 23:29:20 +00:00
Timo Tijhof
f739fca055 Language: Remove logic for class file inclusion
* Remove strcspn() check in newFromCode already in isValidCode().
* Leverage the autoloader instead via class_exists instead of
  including files based on user input.
* Create fallback instance directly instead of recursing back
  into newFromCode().

* Remove method preloadLanguageClass (unused).
* Remove method getClassFileName (unused)

Change-Id: I90035ca4b07facae051b1a584e92df72b42c4a49
2015-10-29 01:39:23 +00:00
Roan Kattouw
e4d6238c00 Language::truncate(): don't chop up multibyte characters when input contains newlines
To detect whether the truncation had chopped up a multibyte
character after the first byte, a regex was used. But in this
regex, the dot (.) didn't match newlines, so it failed to
detect chopped multibyte characters (after the first byte)
if there was a newline preceding the chopped character.

Bug: T116693
Change-Id: I66e4fd451acac0a1019da7060d5a37d70963a15a
2015-10-26 20:17:37 -07:00
Amir E. Aharoni
50f546aa3e Make lines short to pass phpcs in Language.php
Bug: T102614
Change-Id: I14fd848398ce68bd646f36b196560f70352d5f49
2015-09-27 10:45:31 +03:00
jenkins-bot
827e10dc40 Merge "Use wikimedia/cldr-plural-rule-parser" 2015-09-24 23:15:56 +00:00
Niklas Laxström
4a3fd2e42a Use wikimedia/cldr-plural-rule-parser
Replaces the parser included in MediaWiki with same code in
a library.

Change-Id: I1d2675466a543269e17faf213aa68d2b7afaf78e
2015-09-24 21:41:50 +02:00
umherirrender
271da88127 Some bugzilla.wikimedia.org -> phabricator.wikimedia.org changes
Changed some old bugzilla links to new phabricator links in comments,
test data and error message. This reduces the need for redirects from
old bugzilla to new phabricator from our source code.

Change-Id: Id98278e26ce31656295a23f3cadb536859c4caa5
2015-09-24 17:17:25 +02:00
Vivek Ghaisas
d9d846b8a2 Add // @codingStandardsIgnore around very very long line in Language.php
Bug: T110238
Change-Id: Ic681d3eb4e02443b06386ae390536912a8fc4566
2015-09-07 17:13:11 +05:30
Kunal Mehta
b74003c970 Language: Fix 'pretty' fallback in getDateFormatString()
* If using 'default', still fallback to 'date' if 'pretty' is
unavailable.
* Fix instance caching of 'default', which never worked since $pref
would be changed inside the !isset() block.

Bug: T110945
Change-Id: Ic53b279f8741371fa1cb642c53e6d487cb1c6b81
2015-09-01 18:05:07 -04:00