Made the earlier semantically-correct Hindi localization an alias
and added the suggested Hindi localization preferred by the Hindi
Wikipedia community members the primary Hindi localization.
Bug: T366235
Followup-To: I811594311abb4e1d3e44ce3b284d11f72836cbdd
Change-Id: I2f8c7b1dfe22f210773507e86f4b12edd3fd196b
When modules are first loaded by `require` in package.lua, it checks
for a return value with `if res then`. If that check fails, the module
will be cached with the default value `true` at line 109, and that
value is then returned.
That check should be changed to `if res ~= nil then`, because
otherwise a module with a return value of `false` will be cached with
the value `true`.
This also necessitates a corresponding change to the check at line 93,
which is when `package.loaded` is initially checked to see if a package
has been loaded before, as that value could be `false`.
Bug: T362045
Change-Id: Id42e26a922c13971c25ed8654e822dc6fdcb6ca7
`mw.clone` is called on the global table for each new `{{#invoke:}}`,
which is a major contributor to loading times on large pages. This
change introduces various speed optimisations that make it around
15% faster:
* `recursiveClone` is declared outside of the main function, to avoid
generating a new closure each time `mw.clone` is called.
* This means `tableRefs` has to be passed as an argument to
`recursiveClone` instead of being an upvalue, which also decreases
access time.
* `recursiveClone` is only called after a `type` then `tableRefs` check
confirms a value is an unseen table, meaning it's only called when
needed, not for every key/value pair (which add noticeable overhead
when cloning large tables).
* `getmetable` is only called once, not twice, by using a local
variable.
* `tableRefs[elt]` is only accessed once, by using a ternary operator.
* Any global accesses have been replaced by local ones.
Bug: T357199
Change-Id: I51593a971f0be728255723ca300d1ce692ead256
`mw.loadJsonData` in mw.lua throws an error if the input argument is
not a string. The error message should refer to the type of the input
argument `module`, not that of the variable `arg` (which is usually
undeclared, giving the type `nil`).
This also necessitates updating test `mw.loadJsonData, bad title (1)`
in CommonTests.lua, which checks for the error message if the input
is the number 0; the correct message should say "got number", not
"got nil".
Bug: T364987
Change-Id: I8362e91489a8ddc4c890e2799892f692c497c9b9
This includes the declaration of a class property from 7ec7813b2e
to avoid phan issue and avoids use of
dynamic properties as deprecated in php8.2
Change-Id: I192d3a6716c400487fe534809197c0d2b42a439d
Defense in depth: catch the error early when calling mw.language.new()
with a non-string `code` argument; but also check late when popping
the code off the argument array in case something altered the code
property after construction.
Bug: T361664
Change-Id: I04476d3e1c32c87e1df95cc9a0dddcaff475b756
In TitleLibrary::getContentInternal(), an external (interwiki) title will
fail when we try to `Parser::fetchCurrentRevisionRecordOfTitle`, but by
that time we've already tried to add it to the dependency list for the
page via `ParserOutput::addTemplate()`, which causes issues further on.
Bug: T362222
Change-Id: I171e97f17b6de176f92ced47757d10c341c979fd
Mixing different binary boolean operators within an expression
without using parentheses to clarify precedence is not allowed (T358966)
Change-Id: I6d3edc5f8dddcfc6bd6a7d2a8f2ad9467372908d