Requests for comment/Shadow namespaces

This is a request for comments regarding implementing shadow namespaces, which refers to the concept where if a local page doesn't exist, it will be transparently fetched from a remote wiki, like how InstantCommons and foreign file repos currently work.

Background
Currently we have in MediaWiki core. The variable name is apt.

MediaWiki also has a shallow concept of shadow namespaces via ForeignFileRepos. Currently if you set up a foreign file repository, pages in the File namespace will pull from local version if it exists. If the local version does not exist, the foreign repo is queried. Foreign repos can be on the same wiki farm and using database connections or on remote wikis using the API.

Proposal
The work here would be to extend and improve the current shadow namespace implementation. Instead of applying only to the File namespace, shadow namespaces could be implemented with the User, Template, Module, and Help namespaces.

The term "global" here means across all MediaWiki instances, so any modern MediaWiki installation should be able to reference any other wiki (possibly requiring installation of extensions/setting up configuration). In addition, wiki-farms would be able to designate one of their wikis to be used as the central repository if they choose not to use the default one.

would be deprecated and/or removed from MediaWiki core.

Invocations (i.e., ) would try the local version first before trying the foreign repo equivalent. Links (i.e., ) would do the same, with appropriate coloring.

Applications
Shadow namespaces could be used to solve the following use-cases:


 * Global Scribunto/Lua modules; Module namespace; T41610
 * Global templates; Template namespace; T6547
 * Global user pages; User namespace; T16759
 * Global help pages; Help namespace; T14306
 * would allow sharing of global styles for T90914, T112991, and T105845 in general

Compatibility
MediaWiki installations using global scripts will not keep pace with Wikimedia Foundation deployments, so we need a method to continue to support older versions (or maybe just versions that are still supported with code/security updates?).

Licensing
Is this really a consideration here?

Search
When content starts living outside of the local wiki, interwiki search suddenly becomes a lot more important.

Usage tracking
For media on Commons, we have GlobalUsage tracking, however that's only Wikimedia-wide, and captures no usage information about non-Wikimedia Foundation installations using InstantCommons. This means that Commons administrators have no idea whether a file is actually used or not when doing destructive operations like renaming (without leaving a redirect behind) or deleting.

Cache invalidation
When a new version of a file is updated on Commons, it will automatically update on InstantCommons sites since images are hotlinked.[citation needed] However if a template is updated, it should cause HTMLCacheUpdate jobs to be queued so all pages are updated.

See also: Mentorship programs/Possible projects (T48525)

Chaining
Should we support chaining to multiple foreign repos? Basically, assuming we follow the zero one infinity rule with foreign repos, are we talking about one or infinity?

For example, imagine a wiki with two foreign repos configured. "Template:Baz" does not exist locally, but does exist on one of the foreign repos. Would there be some kind of fallback or order of precedence?