User:Duesentrieb/Fix interwiki

This page describes the evil master plan to get rid of the Interwiki class (or at least render it harmless).

Purpose:
 * allow us to use the more flexible Sites system instead of the crusty Interwiki system
 * allow us to use Sites and Interwiki side by side, based on the same data
 * Preserve the legacy interface for interwiki links (static methods in Interwiki)
 * make Sites (at least as) performant as the current multi-cache hodge-podge implementation of Interwiki.
 * Maintain interwiki mappings / site definitions in files, not in the database. It's configuration, not state.

Outline:
 * Create a new interfacfe InterwikiLookup with all the public methods from Interwiki
 * Create HodgePodgeInterwiki implements InterwikiLookup; implement it using the code currently in Interwiki. "hodge-podge" because is implements several storage backends (sql, cdb, ...). The code should be changed as little as possible, only removing replacing access to global state with injection.
 * Make the public static methods in Interwiki delegate to a singleton instance of InterwikiLookup, remove everything else from the class.
 * Create an adapter, SiteStoreInterwikiLookup, implementing InterwikiLookup based on a SiteStore.
 * Deprecate all write methods in SiteStore. (Alternatively, migrate most usages to a SiteLookup interface without write methods)
 * FileSiteStore implements a (read only) SiteStore that will simply load site definitions from a list of local files
 * support at least JSON (easy to maintain) and PHP (code, not serialized data; fast with accelerator cache). Go by file extension.
 * Make CachingSiteStore cache individual groups. Use "siblings" group for sister projects of the same language.

Configuration:
 * InterwikiLookup implementation to use. Default: SiteStoreInterwikiLookup
 * For HodgePodgeInterwiki, use the old interwiki settings controlling CDB usage etc.
 * SiteStore implementation to use. Default: FileSiteStore
 * per default, read DefaultInterwiki.json (maintained in git) and LocalInterwiki.json (shipped empty).
 * on the Wikimedia cluster, use PHP files for speed. One common file, one per group, and one for local overrides per wiki.
 * Caching:
 * which cache (possibly none for PHP files)
 * duration
 * groups to cache separately (all?)