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
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
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
Test output changed in I3fac0f34d134d8eec46c7eefa3ad2b67abb957da.
Depends-On: I3fac0f34d134d8eec46c7eefa3ad2b67abb957da
Change-Id: I8797ab1adbd44b2766ec803d9b6fe646b3a5a116
As well as:
* Remove redundant `=== null`. The `isset()` before does this already.
* Use convenient PHPUnit shortcuts.
Change-Id: Ibef571e53a48c443d7798fee8abbc2624fbad225
This reverts commit 9adf9ef66c.
Reason for revert: The feature it's testing has been reverted in Ic6c0e31c8247f7d89824d20f28fb0aa56d6ed749
Change-Id: I74b4273bf246560b31911f8953974b9653217ec9
WikiPage::factory() is deprecated since 1.36 and should be replaced
with WikiPageFactory::newFromTitle().
Bug: T297688
Change-Id: Ie333c616c46a71430f8c18db85bdd64c13379ef0
This fixes an incompatibility introduced by Ia73ea587586cb69eb5.
Depends-On: I1f24703b80566220ac6fe8ee500e838ed7fd29af
Change-Id: I31ca0a8987f9694bc3b312a48c2c111ceda6fa3e
::doUserEditContent() is available since 1.36 as a replacement
for ::doEditContent(), which has been deprecated. Bump the
required version of MediaWiki to 1.36 accordingly.
Results in passing a user where previously the fallback
to $wgUser was being used.
Bug: T255507
Change-Id: I11e4a305e66935ea1d1b4692561fb5d49871a729
The replacement, Parser::getStripState(), was added to MediaWiki in
1.34.
The extension.json for this extension already requires MW >= 1.35.
Bug: T275160
Change-Id: I062ac8b69756a7ad35d8cc744b4735fd2e70f13e
Use $wgInterwikiCache to setup interwiki prefixes for testing instead
of the deprecated InterwikiLoadPrefix hook. This simplifies the test
setup quite a bit as well.
Bug: T270444
Change-Id: Icb772fcee07103a06548011ddd653487477ebfcc
These new error messages were referring to formatDate instead of
formatNum.
Change-Id: Ic20a5a5515ee55d46087449627138cc779909ec3
Follow-up: Ib7706ad40f7ee2da6ab7c6b2dab6ae8d129dab52
Bug: T268758