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
PSquare is part of wikimedia/running-stat which is bundled with
MediaWiki core. There is no valid way to install a wiki without
the vendor libraries present.
The check was introduced in 2015 with I0d39920733fe7 when the class
was newly added to the package and deployment was happening
concurrently to the extension change.
Bug: T313341
Change-Id: I6717151c39b589f2e5b5e87da6896f62252cb5d8
The Wikimedia\PSquare class has changed such that its serialization
is incompatible with its prior version. We should probably refactor
this to use an actually supported serialization format, possibly
by enhancing PSquare with some kind of getter method that provides
a plain array that its constructor can accept again instead of relying
on internal PHP serialisation format, but for now we can bump the
cache version.
The side-effect of this will be that the performance stats captured
by Scribunto for visualiation in Grafana, will briefly split its
sampling logic between two versions instead of being global across
all wikis until the train is fully deployed. This does not have any
effect on its business logic or runtime behaviour, and is presumably
by design as that's the only way to bump the cache version, which was
a pre-existing factor in its cache key.
Basically, this means that during the deployment days on weeks where
this is bumped, we will briefly capture fewer samples as there are then
two separate counters trying to reach 1000 before flushing a median
to Graphite. We can remedy that by backporting and deploying to both.
While at it, I'm changing the cache key to conform to our conventions
and make it an explicit, greppable, lowercase and descriptive name
(scribuntu-stats) instead of the implicit __METHOD__ which expanded
to "Scribunto\Hooks::reportTiming". I note that this means the split
brain sampling actually happened at least once before during the week
where the namespace was introduced as that will have implicily changed
the cache-key. Another reason not to use __METHOD__ in a cache key.
Bug: T313341
Change-Id: Ic9dad0f55cba18ec03272b87366a091a396beb74