mw.loadData() allows for optimizing the loading Lua tables by requiring
only one parse and lookup. However it's often easier for people to
write/maintain bulk data in JSON rather than Lua tables.
mw.loadJsonData() has roughly the same characteristics as mw.loadData()
and it can be used on JSON content model pages in any namespace.
As noted on the linked bug report, it's possible to already implement
this by writing a wrapper Lua module that loads and parses the JSON
content. But that requires a dummy module for each JSON page, which is
just annoying and inconvenient.
Test cases are copied from the mw.loadData() ones, with a few omissions
for syntax not supported in JSON (e.g. NaN, infinity, etc.).
Bug: T217500
Change-Id: I1b35ad27a37b94064707bb8c9b7108c7078ed4d1
For the most part, it is a good idea to avoid global variables and use
`local` variables instead. Quoting from the ScopeTutorial[1], "The
general rule is to always use local variables, unless it's necessary for
every part of your program to be able to access the variable (which is
very rare)."
Wikimedia module authors have written "Module:No globals", which errors
on the use of any global variable. On the English Wikipedia, this is
used on 32% of pages (18 million). Wikidata[2] indicates that it's been
copied to 334 other wikis.
Lua itself distributes an extra named "strict.lua"[3], which is what
this is based off of. Similar to bit32.lua, this is a pure-Lua library
that can be imported/enabled with `require( "strict" )` at the top of a
module.
The two changes I made from Lua's strict is to exempt the `arg` key,
which is used internally by Scribunto, and remove `what()`, since we
don't enable access to `debug.getinfo()` for security reasons.
[1] https://lua-users.org/wiki/ScopeTutorial
[2] https://www.wikidata.org/wiki/Q16748603
[3] http://www.lua.org/extras/5.1/strict.lua
Bug: T209310
Change-Id: I46ee6f630ac6b26c68c31becd1f3b9d961bcab29
In Chromium-based browsers the lack of padding means the cursor
isn't visible in the textarea when focused. In this case, it's
probably more important for the cursor to be visible than the
lack of padding to make it look more like a terminal.
Bug: T272678
Change-Id: I09ed2933bdac292ee9b9b98a2c8c48d96914d096
Use OOUI's PopupWidget to display error tracebacks/details instead of a
deprecated jquery.ui dialog.
Bug: T319361
Change-Id: Ie7796c853782de9874595674fe250f6702db717e
This fixes a warning on php8.1 related to preg_match_all returning
null when given invalid UTF-8.
I made a separate patch to change the null into an exception Ic0c9083b
In a sense, this is a follow-up to ec103b6966.
Bug: T319218
Change-Id: Ia17fc2fa428ec35bdbd242f1127fcdff501fb741
This is basically unexploitable, given that Scribunto sessions are
"extremely ephemeral", protected by a 31-bit non-cryptographically
random token and generally contain very little useful data.
But, requiring a CSRF token is a best practice and since this module
is internal and only used in one place, it's also unlikely to break
anything. Because it needs a token, the module is POST-only now too.
Bug: T212071
Change-Id: I7fb6b4f856ee6194eb37c26e14f178fea6c0a3f6
Pages ending with a ".json" suffix in the Module namespace will use the
built-in JSON content model by default. Previously editors had to use
Special:ChangeContentModel to get a JSON page, which requires the
"editcontentmodel" userright that is not granted to a wide set of users
by default.
Bug: T144475
Change-Id: I1546fcad823a55a8c5a93177df8715844de1e87c
* This patch builds on core functionality provided in
Ied0295feab06027a8df885b3215435e596f0353b.
* This removes any nowiki wrappers present in unstripped text
(which there would be for preprocssed nowiki tags) which mimics
the effect of procssing nowikis in core when generating HTML.
* Updated lua tests to verify the new expectation.
* A previously failing parser test added to test T272507 now passes
and has been re-enabled.
Bug: T272507
Depends-On: Ied0295feab06027a8df885b3215435e596f0353b
Change-Id: I1613ac7bd60cf3ef4a3308b08ea3705b3cf2dee0
* This test fails with a core patch and will only pass in a
subsequent patch in this repo.
Needed-By: Ied0295feab06027a8df885b3215435e596f0353b
Change-Id: Id6ea611549e98893f53094116a3851e9c42b8dc8
* Ia3cc8f95833cd0e9ae985528f8e72396111c4504 in core changed
localizations for kaa language
Followup-To: Ia3cc8f95833cd0e9ae985528f8e72396111c4504
Change-Id: Ie1b686b65f008c0cd5f4017102699e51f6960b39
* Running into a missing module error in CI but cannot reproduce
locally.
* Let us unbreak CI for other dependent repos and investigate this
in the followup patch that reverts this.
Bug: T316331
Change-Id: Ic5983e503203f132fff521e422f0c7143f91d779
* Turned on wt2html and wt2wt Parsoid modes for all tests with
aggressive normalization to eliminate the need to add html/parsoid
sections.
We expect these modes to pass.
* The failing wt2wt tests is because the input wikitext duplicates
arguments and Parsoid's wt2html doesn't capture duplicate template
args which cause the wt2wt output to be normalized.
This explains the two failing wt2wt tests and the corresponding
selser "failures".
* The failing wt2html safesubst test might be a real failure and
something we will have to look into. Will file a phab task for this.
* Added a new test for T272507 that fails with Parsoid right now,
but will pass in a subsequent patch.
Change-Id: I96fba68dda7524d2fe562eb60ced64e5e0518f65
The addition of PSquare::__serialize() in wikimedia/running-stat is
having the same cache implication as the issue this was meant to fix.
The legacy PHP serialized form is not compatible with the stable
serialize form that we're switching to.
Bug: T313341
Change-Id: Iec4c1c958e10560abcbd4184a0ca4e1a0c19183a
This reverts commit 62e1fb0b5f.
Reason for revert: caused several errors:
* unnamespaced HooksTest collides with core’s class of the same name
* Scribunto_LuaError renamed without class alias despite being used in Wikibase
Bug: T314464
Change-Id: I8b151327236bf86945e59823fba155497e4b3fc6