Page MenuHomePhabricator

Scribunto external package loader
Open, Needs TriagePublic

Description

require() and mw.loadData() call LuaEngine::loadPackage() which loads from local files, then if no file is found, from a page on the wiki. We will add external packages to the fallback sequence.

Similarly mw.loadJsonData() currently loads only from a page on the wiki, and this will be extended to also call the package loader.

  • Entry point
  • Process cache
  • Default loader configuration and per-package overrides
  • Loader backend:
    • Local file loader
    • SQL loader

We also need a sandbox loader although that might be integrated with the existing wiki page loading code.

The SQL loader is a file store independent of any particular VCS.

The main difference between this file store and existing stores (like the page store) is that this store can efficiently do atomic updates of many files. The fetcher (T412320) inserts the new texts, and the updater (T412323) links them to a deployment state ID. Marking the state as active is the atomic step and only changes a single row.

The active state ID and the state/content links are per-wiki. The text may be shared across wikis.

The loader gets the active state ID, and this remains consistent for the duration of a parse operation.

Scribunto provides an accelerator blob to the updater (T412323) with a map of module names to file names. The loader loads this blob and uses it to determine whether a module exists and which package and file it is in. The loader asks the file store for the file.

mw.loadJsonData() should probably take a slash-separated file name rather than a dot-separated module name. This file can be requested directly from the file store, without using the accelerator blob.

The entry point is responsible for registering a link in a link table.

Event Timeline

Change #1250193 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/extensions/Produnto@master] Add ProduntoRuntime service

https://gerrit.wikimedia.org/r/1250193

Change #1250195 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[mediawiki/extensions/Scribunto@master] Load modules and JSON from Produnto if available

https://gerrit.wikimedia.org/r/1250195

Change #1250193 merged by jenkins-bot:

[mediawiki/extensions/Produnto@master] Add ProduntoRuntime service

https://gerrit.wikimedia.org/r/1250193

Change #1264928 had a related patch set uploaded (by Tim Starling; author: Tim Starling):

[integration/config@master] Scribunto phan will depend on Produnto for runtime service

https://gerrit.wikimedia.org/r/1264928

Change #1264928 merged by jenkins-bot:

[integration/config@master] Scribunto phan will depend on Produnto for runtime service

https://gerrit.wikimedia.org/r/1264928

I have merged integration/config 1264928, on CI that would cause Phan analysis of Scribunto to also clone the Produnto extension.

The Phan configuration in Scribunto will need to be adjusted though, there is no automatic discovery. This is done via .phan/config.php and is documented at https://www.mediawiki.org/wiki/Continuous_integration/Tutorials/Add_phan_to_a_MediaWiki_extension#Advanced . You probably only have to add ../../extensions/Produnto to the directory_list and exclude_analysis_directory_list Phan configuration variables.


A caveat: the reverse dependency is not tested. A change made to Produnto might merge and cause the Phan run in Scribunto to fail. I believe that can be addressed by adding to zuul/phan_dependencies.yaml the reverse dependency:

Produnto:
  - Scribunto

And amending Produnto .phan/config.php to read Scribunto. I am not sure whether we care about the reverse dependencies.


For the PHPUnit tests, the dependency is expressed in another file zuul/dependencies.yaml and can be added as:

Scribunto:
  recurse: false
  dependencies:
    - Produnto

And probably the reverse dependency should be added as well to have Scribunto tests to run when a patch to Produnto is added:

Produnto:
  recurse: false
  dependencies:
    - Scribunto

Note that tests in Scribunto would need to be skipped when Produnto is not present. This would happen for any extension that depends on Scribunto (and would not have Produnto added). The Scribunto > Produnto integration should thus be skipped using:

$this->markTestSkippedIfExtensionNotLoaded( 'Produnto' )

Change #1250195 merged by Tim Starling:

[mediawiki/extensions/Scribunto@master] Load modules and JSON from Produnto if available

https://gerrit.wikimedia.org/r/1250195