This is apparently unofficially deprecated, and we can do things a bit
more straightforwardly by using ParserOutput::addJsConfigVars() to
communicate the error messages to the JS.
This also takes the opportunity to move "ext.scribunto", which is mostly
about errors, to "ext.scribunto.errors".
Bug: T75618
Change-Id: I1577dab2dab1bd79cb127879de141fdbb8963aeb
Should be good to apply now after Wikibase has been adopted to
this.
This reverts commit 06f03fe09b.
Bug: T69483
Change-Id: I28073a891b8847fc6aa5ad026bf702e4015f7d4a
* For most tests, subclassing MediaWikiLangTestCase instead of
MediaWikiTestCase works.
* The Site library needs to not reuse its namespace cache if the
language changed.
* ScribuntoExceptions are still being localized for some reason; test
the message and args of the exception instead of using getMessage().
Bug: T69483
Change-Id: I1c0ca3b11b6228654b47ceb92c1b1be7bda6709a
Use cases:
- size: Showing links (like to SVG validator) conditionally (e.g.
only if the filesize is below the threshold it can work on)
- mime: No longer have to guess the MIME type based on the file
extension. We use the MIME type for displaying correct and
precise information about maximum thumbnailable sizes in
case an uploaded work exceeds this limit.
This change will not have negative impact on performance; as soon
as width or height is loaded, the two newly added information are
gratis.
Change-Id: I25aad85c2a558a684aca83374aeb628f355fad1c
Replace numeric loops with iteration, don't unnecessarily check for nil
before table.insert (since it's a no-op in that case anyway), and similar
restructuring.
Change-Id: I155839a648f242a1b1de35f4081d8bcfa34f6933
At the moment, in mw.site.interwikiMap, URLs stored in the database
with relative protocols are converted to http or https depending
on the protocol of the user who last requested that the page be parsed.
However, this URL isn't updated for users pulling pages from the page
cache, so they may see links with an incorrect protocol. Module authors
can work round this by using mw.uri objects and the isProtocolRelative
property, but it would be simpler just to use relative URLs from the
outset.
Change-Id: If0a169cfd1597e09706fc0e6d5cdcc821ba8d06a
This makes the interwiki map available to Lua modules. The code is
based on the API interwiki map code in core (the appendInterwikiMap
method of includes/api/ApiQuerySiteInfo.php.) Everything that the
API includes is added, apart from iw_api and iw_wikiid, which I
couldn't think of a use for from Lua modules.
Accessing the interwiki map would be useful for modules like
enwiki's Module:InterwikiTable,[1] as it would stop module writers
having to duplicate the data.
[1] https://en.wikipedia.org/wiki/Module:InterwikiTable
Change-Id: Ie8ad2582aaf5e422824f7da51714a347bb4041d1
Change handling of PTD_FOR_INCLUSION to match that of the parser (i.e.,
don't set it if text is being expanded in the root frame), so that
frame:getParent():preprocess() will handle <noinclude> etc. correctly.
Change-Id: I13f45e57aa334642d310e9bd5fdd3dbe5922c4e1
When os.date("*t") or ("!*t") is called, instead of just setting the TTL
to 1 second, create a metatable that sets TTLs as the values are looked
at.
Change-Id: Id1e2df731f182f21cf19708738f9907fa927185c
When processing Lua console requests, don't attempt to parse pages that
aren't modules. This allows the Lua console to be successfully loaded
everywhere.
Change-Id: Idfd1985aca4acb6a8f3235d34ac00358e30e361c
Currently, mw.title.new always results in a database query, which holds up
the parse until it finishes. This changes it to not require a database
query if it's not actually necessary.
Bug: T68328
Change-Id: I62f347d4cd9176bd0440215dcbe804c1dc3d4c99
Add more information to error messages in mw.html. This includes the
error level, the function name, and the position of the argument in the
argument list. Where possible, use the functions in libraryUtil.lua to
do this.
Some functions in mw.html accept multiple types, so add a checkTypeMulti
function to libraryUtil.lua to make these kinds of functions easy to check.
And while we're at it, add test cases for libraryUtil.lua as well.
Change-Id: If9cf9a52bd4b1bb42cc7f9f1f1096828710cbc52
Just like the other methods, e shouldn't be allowing passing of things
that aren't numbers or strings here.
For that matter, we should just abstract out the whole "arg key and
value validation" into a separate function instead of repeating it in
four places.
Bug: T76609
Change-Id: Id7e512a988ef9b7a5c5a110c8992dd5d649dcbf9
In I019c24d1, an unnecessary variable redefinition was added to
Scribunto_LuaModule, which this removes.
Change-Id: Ib0232a5adcd9ad7ea5c0f4413ba06c42b5506d7b
mw.text.unstrip is too broad, it's allowing for unstripping things that
cause problems when unstripped (e.g. bug 61268). Since the original
request was only for unstripping <nowiki>, let's add a function that
does only that.
We should also add an interface to StripState::killMarkers(), instead of
requiring everyone to roll their own work-alike.
Then, to fix the bug, we can make mw.text.unstrip be the combination of
the two. This is the most like the original behavior of mw.text.unstrip
(removes all strip markers, replacing them with text where applicable)
without causing issues.
Bug: 61268
Change-Id: I3a151fd678b365d629b71b4f1cb0d5d284b98555
There are like a billion things missing in the inline documentation
of this extension. Wow. This is what I can do for now.
Change-Id: I019c24d13cf5cb22dde4d710b86ef8f976e1ec96
Scribunto currently supports libraries with PHP callbacks that are
loaded on startup, and pure-Lua libraries that may be loaded from the
module with require().
This change allows for libraries with PHP callbacks to also be loaded
with require().
Change-Id: Ibdc1f4ef51b1c8644c3d4c98d57755b5c06447a5
Use $title->exists() to see if a title exists, and use
$parser->fetchLatestRevisionOfTitle() when available, so that
TemplateSandbox works with title.exists and title.getContent().
Bug: 70495
Change-Id: I732da9daccdc35b11d726818c3a7c81f5e810a32
If LuaSandboxFunction::call returns false, it's an error on PHP's part.
Throw a "real" exception so that we can see what's causing it in server
logs.
Bug: 71045
Change-Id: I7185e186d3e0af6e467b73ea1ef13417ca96b088
Cache patterns and the regexes they become, avoid revalidating the same
pattern multiple times, and don't bother checking if something is a string
when we just made it one.
Change-Id: I1a61dd0a36eb449c8acdc8c1be68aae793f172d3
It's not necessary, it makes the output bigger, and some pages have enough
elements with CSS that it does make an actual difference.
Change-Id: I80d471899c7e04a8a4876c205198a8c0d0b1f281
When calling getContent() on the page currently being viewed, set
vary-revision on the parser output, as is done when a page transcludes
itself.
Change-Id: I908f095935067dc24dd561192b0699c602cb605f
In Ia4d58f44, the code enabling __pairs to work no longer ran inside
MWServer.lua, so it hasn't worked right for serialization since then. This
restores the correct behavior.
Change-Id: Iea31ab363957f5f69838d6715527cf822c15fa94
Add a way to fetch cascading protection information from Lua without
needing to call the CASCADINGSOURCES parser function.
Change-Id: I1b3ac18af11d3066f78d27b31da8d6709a6a2631