Commit graph

1564 commits

Author SHA1 Message Date
Fomafix
d65ac78277 Replace HTTP by HTTPS
* https://www.unicode.org/ instead of http://www.unicode.org/ or
  http://unicode.org/
* https://secure.php.net/ instead of http://www.php.net/ or
  http://php.net/
* https://hhvm.com/ instead of http://hhvm.com/
* https://www.iis.net/ instead of http://www.iis.net/

Change-Id: I84d818a7e0ced5ffb9485ec89a75efb28a77c1e0
2018-05-22 12:14:14 +02:00
Kunal Mehta
230958d97c Autofix MediaWiki.Commenting.FunctionComment.SpacingDoc* errors
Change-Id: I63761ebce04c03b9b13237919c27cc10180f198f
2018-05-19 14:07:03 -07:00
Michael Holloway
e6e9a8279b Add varianttitles parameter to API query prop=info
Returns the displaytitle (if present) or title->getPrefixedText for a
page, converted for each language variant configured on the wiki.

Bug: T178446
Change-Id: I35100af3824ca65c4fe5c106d4a6fbe4e5f75046
2018-04-09 22:03:19 +00:00
Umherirrender
52338150c8 Fix return type for html strings
Change-Id: Ifc1ae7740ad1b130186b4b970d3d84651b016177
2018-04-06 13:07:01 +02:00
jenkins-bot
e46d0694ac Merge "Truncate tag filter descriptions" 2018-02-21 12:52:23 +00:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
petarpetkovic
2d2575852c Truncate tag filter descriptions
Introduce truncateInternal() method in Language class, based on
existing truncate() method. New method abstracts string truncation,
allowing users to specify callable functions for text length measurement
and string truncation.

New method, truncateInternal(), is used to provide two options for
text truncation:
* For DB usage: truncateForDatabase() method is truncating text by
number of bytes.
* For UI usage: truncateForVisual() method is truncating text by number
of characters, using multibyte string PHP methods.

Old truncate() method is deprecated and just returns the results of
truncateForDatabase() method.

Newly introduced truncateForVisual() method is used for
truncation of long tag descriptions in RCFilters menu.

Bug: T179626
Change-Id: Ib01a8c303304064dde3ce983b817d93a88a5affd
2018-02-09 22:45:20 +01:00
Jesús Martínez Novo
92e74356e2 Performance: Shortcut Language::truncate if there's no need to truncate
Return the unmodified string if there's no need to truncate it without
doing a not-so-trivial round of getting a message from the message
cache.

Change-Id: I11ac88672aeb9d1c4f5709b79ad2d17223bd64d8
2018-01-12 21:05:17 +00:00
Bartosz Dziewoński
eb6bb6b7b9 Generalize non-digit-grouping of four-digit numbers
In some languages it's conventional not to insert a thousands
separator in numbers that are four digits long (1000-9999).
Rather than copy-paste the custom code to do this between 13 files,
introduce another option and have the base Language class handle it.

This also fixes an issue in several languages where this logic
previously would not work for negative or fractional numbers.

To implement this, a new option is added to MessagesXx.php files,
`$minimumGroupingDigits = 2;`, with the meaning as defined in
<http://unicode.org/reports/tr35/tr35-numbers.html>. It is a little
roundabout, but it could allow us to migrate the number formatting
(currently all custom code) to some generic library easily.

Bug: T177846
Change-Id: Iedd8de5648cf2de1c94044918626de2f96365d48
2018-01-02 11:17:25 +01:00
Umherirrender
255d76f2a1 build: Updating mediawiki/mediawiki-codesniffer to 15.0.0
Clean up use of @codingStandardsIgnore
- @codingStandardsIgnoreFile -> phpcs:ignoreFile
- @codingStandardsIgnoreLine -> phpcs:ignore
- @codingStandardsIgnoreStart -> phpcs:disable
- @codingStandardsIgnoreEnd -> phpcs:enable

For phpcs:disable always the necessary sniffs are provided.
Some start/end pairs are changed to line ignore

Change-Id: I92ef235849bcc349c69e53504e664a155dd162c8
2018-01-01 14:10:16 +01:00
Huji Lee
e74bfe13f6 Require indentation of CASE statements in PHP code
Bug: T182546
Change-Id: I91a9555893a08e4ec58da97c6cc4d1e70000ff6b
2017-12-10 22:07:50 -05:00
Sam Wilson
313675320f Always return a string from Language::formatNum()
It says it returns a string, and so it should.

Bug: T182277
Change-Id: Ic68c65c634c2557a1d07281623cd6c971b000323
2017-12-07 13:59:56 +08:00
Zach
ebfdff32a4 Language: Update git.wikimedia.org URLs to point to Phabricator
Bug: T139089
Change-Id: I38492e0c8e90f3418bcb831f086fbe6ea2b319b5
2017-11-05 05:24:35 +00:00
Thiemo Mättig
67f5ee2acd Add missing @throws documentation to Language::factory
Change-Id: Id5ff9d438864e2d39a10441c43aba4188191f623
2017-10-23 16:35:55 +00:00
Fomafix
ea0bd74a94 Refactor global function wfBCP47 to static function LanguageCode::bcp47
Deprecate global function wfBCP47.

Change-Id: Ie6bb061b5d6ca67289bb18bc468a87421f38fc94
2017-10-05 09:54:45 +02:00
Umherirrender
3f1a52805e Use short type bool/int in param documentation
Enable the phpcs sniffs for this and used phpcbf

Change-Id: Iaa36687154ddd2bf663b9dd519f5c99409d37925
2017-08-20 13:20:59 +02:00
jenkins-bot
84b6d5c2e5 Merge "Add missing type to @param documentation" 2017-08-11 21:31:51 +00:00
WMDE-Fisch
6df9ed1ad6 update mediawiki-codesniffer to 0.11.0 and fix issues
- mostly auto fixes
- some too long lines fixed
- ignore amp space in one case  passing by reference

Change-Id: I6472f83bc3cbf4bd629d83050cc3319b19ec465c
2017-08-11 22:27:51 +02:00
Umherirrender
5544cef16b Add missing type to @param documentation
Change-Id: I6b2c9c7af9a281fe457099cc3a336a60a25e74aa
2017-08-11 20:37:35 +02:00
jenkins-bot
fb79f30319 Merge "Fix and make some types in PHPDoc and JSDoc tags more specific" 2017-08-05 22:08:00 +00:00
Thiemo Mättig
c785efd25e Fix and make some types in PHPDoc and JSDoc tags more specific
Change-Id: I7c109067579f570ecccaabc75b0b4db7eac4e6c2
2017-08-05 18:46:44 +02:00
Bartosz Dziewoński
8785e4a5b3 Replace remaining uses of deprecated DB_SLAVE with DB_REPLICA
Change 950cf6016c took care of the most,
but a few remain, either outside of includes/ and maintenance/
directories (which that change was limited to), or in code introduced
afterwards.

Change-Id: I9c363d0219ea7e71cde520faba39406949a36d27
2017-08-05 10:10:26 +00:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.

The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.

Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
2017-07-22 18:24:09 -07:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Bartosz Dziewoński
c5b1097290 Hide Pig Latin language entirely if $wgUsePigLatinVariant is false
Previously, even if $wgUsePigLatinVariant was false, the language
would show up on Special:Preferences (and some other places) as
'en-x-piglatin - Igpay Atinlay'.

Follow-up to d8375bee24.

Change-Id: I08faacabca87c04299c7b535be8df1770e0a37ac
2017-06-16 20:43:28 +02:00
Liangent
d8375bee24 New language variant 'en-x-piglatin' for easier variant testing
Guarded by the $wgUsePigLatinVariant variable, off by default.

Pig Latin is a language game where words in English are altered
according to the following rules:

* Words starting with a vowel have a '-way' suffix appended.
* Words starting with a consonant have the initial consonants (or 'qu'
  group) moved to the end and an '-ay' suffix appended.

https://en.wikipedia.org/wiki/Pig_Latin

* Added 'en-x-piglatin' as a language name.
* Added 'en' to LanguageConverter::$languagesWithVariants.
* Added LanguageEn class and its corresponding EnConverter which
  provides one-way translation from English to Pig Latin.
* Some minor internal changes in code that assumed that English
  doesn't have a language class or converter.

Bug: T45547
Depends-On: I1d9691c784032669979f8109c9a5f65cbf4122c9
Change-Id: I7fa2d85d6364958c5138366e8b4504a2697a8731
2017-06-12 16:59:57 -04:00
Thiemo Mättig
f420839554 Fix incomplete Language::getDatePreferences() documentation
Look at languages/messages/MessagesEo.php for one of about a dozen real
world examples where this is set to false. All code calling
getDatePreferences checks if it got a truthy value first before using
it.

Change-Id: I4ef5c8be618d41039297325c9dd4cf554ea14559
2017-05-24 11:32:41 +02:00
Thiemo Mättig
8bbf6cb2eb Use more specific string[] type hint for language variants
This patch only touches PHPDoc documentation, nothing else.

Change-Id: Ia79d06425a3b8629c171cd68ae435c64dac86f46
2017-04-17 22:31:22 +02:00
Timo Tijhof
3a2a707546 Clean up remaining get_class() uses
* get_class()        -> __CLASS__ (same as self::class)
* get_called_class() -> static::class
* get_class($this)   -> static::class

Change-Id: I1888a1897ecf4548a2e5a67a942e5c080dd7e3d3
2017-03-07 22:03:47 +00:00
jenkins-bot
aa3319c4c0 Merge "Miscellaneous indentation tweaks" 2017-02-28 18:38:36 +00:00
James D. Forrester
3526417586 languages: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: Id2f9d229d17b8eee66b2ca4e3927f3f66ac62988
2017-02-28 00:33:38 +00:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01:00
Brad Jorsch
fb3ae6fbe3 Replace use of &$this
Use of &$this doesn't work in PHP 7.1. For callbacks to methods like
array_map() it's completely unnecessary, while for hooks we still need
to pass a reference and so we need to copy $this into a local variable.

Bug: T153505
Change-Id: I8bbb26e248cd6f213fd0e7460d6d6935a3f9e468
2017-01-31 23:01:54 -05:00
Zhuyifei1999
0effd172ce translateBlockExpiry: Duration is block expiry minus current time
For relative timestamps in $str, strtotime( $str, $now ) returns an
absolute Unix timestamp $str since $now, and this timestamp is given
to $time. However, Language::formatDuration expects a time duration,
not an absolute timestamp. We obtain this duration from the difference
between $time, the absolute timestamp of block expiry, and $now, the
absolute timestamp of the time in which the block action happened.

Tests have been added to test both this patch and 01936fa, the patch
that caused this regression.

Bug: T156453
Change-Id: I6fd8c02dc3c6456067fe25cb9f33f5b4c78332aa
2017-01-28 07:22:00 +00:00
Bartosz Dziewoński
01936fa994 BlockLogFormatter: Durations are relative to block's timestamp, not Unix epoch
Also fixed legacy code in LogFormatter producing messages for IRC feed.

Bug: T55907
Change-Id: I0df19574f74210a91ce72c79188b6618f04ef9a2
2017-01-18 13:21:56 +00:00
This, that and the other
2b2cda890b Proper handling of invalid/unknown time zones
Currently, a user who has an invalid time zone stored in the database is
effectively locked out of their account on HHVM sites. This patch addresses
this by (1) preventing users from setting invalid time zones, and (2) not
throwing an unhandled exception if a user's TZ is unknown.

When the user saves their preferences, the code silently rewrites invalid
time zones to UTC. I think this is OK, since to cause this to happen you
have to manually muck around with the Preferences page DOM or submit the
form from a script.

Bug: T137182
Change-Id: I28c5e2ac9f2e681718c6080fb49b3b01e4af46dd
2017-01-05 05:24:45 +00:00
Amir E. Aharoni
6b03e2e88e Make the code for grammar data processing common
This makes the code for processing JSON files with
grammar transformations reusable by different languages
and applies the same logic to Russian and Hebrew.
It will be done to other languages in further patches.

This patch is not supposed to change any functionality,
and the tests are intact (except a comment in the test
for Hebrew - the class doesn't exist any longer).

PHP:
* Move the JSON grammar transformation data processing logic
  from LanguageRu.php to convertGrammar() in Language.php.
  By default all these data files are supposed to be
  processed identically, so the code should be common.
  If there is no JSON data file, nothing new happens.
* LanguageRu's own convertGrammar() method is removed.
* The LanguageHe class is removed, now that all its functionality
  is handled by generic JSON data processing in the Language class.
  LanguageHe.php file is removed from the repo and from autoloading.

JavaScript:
* Move the JSON grammar transformation data processing logic
  from ru.js to mediawiki.language.js.
* JavaScript grammar code files he.js and ru.js are removed
  from the repo and from Resources.php, because all the data
  is in JSON, and the default logic in mediawiki.language.js
  works for both languages.

Bug: T115217
Change-Id: I5e75467121c3d791bb84f9e6fdfcf07c1840f81a
2016-12-16 15:52:14 +02:00
jenkins-bot
9ac29c74ed Merge "Cleanup some incorrect return annotations" 2016-12-16 07:22:24 +00:00
Erik Bernhardson
f5f7795609 Fix PhanTypeInvalidLeftOperand in Language.php
Not entirely sure what's going on here. Best guess is phan isn't able
to figure out that array + mixed will result in an array, and then
adding validNamespaces (another array) is ok. Could make things a little
more explicit with array_merge, but this seems to work to remove the
issue without changing the meaning of the code.

Change-Id: I7031ae4e68878ec3198e47c55ab5de4d52a6d922
2016-12-13 11:54:15 -08:00
Erik Bernhardson
3becc477a9 Add script to support per-line @suppress annotations in Phan
Adds the functionality of per-line @suppress annotations. Phan already
supports per-class or per-method annotations, but does not have any
per-line support due to the PHP AST only returning comments that are
class/property/method level docblocks.

This is a bit of a hack, but get's the job done. Removes the
PhanTypeInvalidLeftOperand issue from blacklist and suppresses it
to demonstrate the supression works as expected.

Change-Id: I5066b3b431fb69175a711ee366e95f31c7c47639
2016-12-13 11:54:10 -08:00
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