Negative values for 'i' in mw.ustring.byteoffset are supposed to count
from the end of the string. But in LuaSandbox, it was actually counting
from two bytes before the end of the string due to a typo.
Fix that, and add some tests for it.
Bug: 50176
Change-Id: Iceee1022a55abd7a08df1ea7843e1277eb02798b
If someone puts something broken in MediaWiki:Scribunto-doc-page-name,
it may not be possible to determine which module the page is a doc page
for. In that case, just pretend it's not a doc page.
Bug: 49322
Change-Id: Ia4421576b372e188cf7e3dfe2c0b8ce213d026d4
If the interpreter exits before the end of the page, then the call to
Scribunto_LuaStandaloneEngine::getLimitReport() throws an uncaught
exception when it tries to access the interpreter. Catch it.
Change-Id: I7ce4f09b1b2206f13ab0f422de35e0b69a3b24d5
The following errors are fixed:
* PHP warning and wrong return value with empty pattern and plain
* Incorrect offsets returned when init is larger than the string length
* Incorrect captured offsets returned when init is excessively negative
Bug: 47365
Change-Id: I9741418287dc727747326d6a19678370ce155a2b
We had intended to use the constant CONTENT_FORMAT_TEXT, but
accidentally used that as a string instead.
Change-Id: I93a2c02d48d3fd7b73530562165d817965e272d1
* zh names are dropped to use fallback.
* zh-yue is renamed to yue, with talk namespace name added.
Change-Id: I9b0e0e5ab03a70bcbbc052ef4e6c753574e73e13
Two related issues:
* The package module was inheriting the loaders from the outer sandbox,
so loaded modules were being loaded into the outer sandbox's
environment.
* mw.loadData was using the outer sandbox's require(), so again loaded
modules were being loaded into the outer sandbox's environment.
Bug: 47300
Change-Id: I48d8dd4784c9a890e3abb6389f96f38e1420dbbb
The documentation, and the expectation of users, is that
lang:parseFormattedNumber() should actually return a number, not a
string.
Bug: 47268
Change-Id: Ieabddd0d9192f1fd8ef7e890d5d6268be9636f38
One of the design goals of Scribunto is that each #invoke should be
independent. Creative use of mw.log and mw.getLogBuffer can get around
this, passing information from one #invoke to the next.
This patch takes the simple solution of removing mw.getLogBuffer from
modules' environments. For good measure, it also removes
mw.clearLogBuffer and mw.executeModule.
Some minor cleanup of the console code is also included.
Change-Id: I30d73928bade4a6bdd7c00ffcd58a3858ff55698
https://meta.wikimedia.org/wiki/Lua_deployments/Localization_of_Module
Four languages (ka, ms, zh, zh-yue) are missing the translation for
Module talk, as there wasn't one on the Meta page.
Full list of newly added languages (including the ones with partial
translations): an, ar, ast, ba, bn, ca, crh, da, dv, es, et, eu, fa,
gl, id, it, ja, ka, ko, min, ms, nn, no, pl, ru, sk, sl, uk, zh,
zh-yue.
Change-Id: I504ce98a2a430aa98f116186051331fbbfcc57d5
This uses the timezone support added to core Language::sprintfDate in
Iea1f7842 to add support for various timezone-related formatting
characters, and to correct the output for 'c', 'r', and 'U' in local
mode.
This is related to bug 33454, which requests the same for
ParserFunctions' {{#timel:}}.
Bug: 33454
Change-Id: I1b92dc671051a6cc53e35ebd74d383448e16696c
On Windows for LuaStandalone, the lua executable's standard output is a
text-mode file handle, even if the pipe is opened from PHP with the
binary flag. Which means that when Lua returns a "\n", it gets silently
rewritten to "\r\n" and the unserialization fails.
So, change the protocol for Lua→PHP messages to encode \r and \n (and \
itself, as the escape character) to avoid this issue.
Bug: 46294
Change-Id: I73b5f44e8aa0334f5fd03013dc027d1a57318349
Users are reporting disappointment that using pairs on title objects
doesn't let them see the fields available. It's easy enough to add a
__pairs metamethod to allow pairs to work on title objects, so let's do
that.
The same can be done for mw.uri objects.
For mw.message objects, we can easily enough change the implementation
to be like mw.language objects, which doesn't have this problem.
For mw.site.stats, we may as well just remove the load-on-demand feature
since it will be demanded as soon as the environment is cloned for the
first module.
Change-Id: Ie5a3b5684b2bb6c090f9994baa03977687688929