User:Daniel Kinzler (WMDE)/SitesInfo

This is a quick brain dump of what I believe should replace Interwiki, SitesLookup, and WikiMap.

Prior iterations of this, for reference:
 * RFC for overhauling Interwiki, SitesLookup, and WikiMap https://phabricator.wikimedia.org/T113034
 * Code experiment: chain starting at https://gerrit.wikimedia.org/r/c/349553/ and ending at https://gerrit.wikimedia.org/r/c/352474/

Needs identified during the code experiment:
 * Primary needs:
 * Resolve local aliases (interwiki prefixes) to global IDs. For convenience, most methods should allow the use of local aliases instead of global wiki IDs. Signature: getGlobalId( $wikiId ). If $id already is the global ID, it is just returned as-is.
 * Look up a "property" for a given foreign wiki. Relevant properties include the base URL, article path, script path, asset path, database name, database cluster, content language, family (wikipedia, wiktionary, etc), etc. There should be some well known properties, but this should be an open set: things should be able to just add and use new properties. Signature: getProperty( $wikiId, $propertyName, $default = null ). $wikiPage should accept global IDs and local alias. Should fail if the wiki sin't know. Should return the default if the wiki doesn't have that property set.
 * List all wikis with a specific property set, or with a specific value for a given property. E.g. list all wikis in a given family, list all wikis on a given db cluster, etc. Signature: findWikis( $property, $value = true ). Returns a list of global wiki IDs. If $value is not given, list all wikis that have the property set to true (convenient for boolean properties, like "multilingual").
 * Secondary needs (for maintenance, etc):
 * list the global IDs of all wikis. Signature: listWikis.
 * list the local aliases for a given wiki. Signature: getAliases( $wikiId ). Should accept an alias as input.
 * get all properties for a given local wiki. Signature: getProperties( $wikiId, $defaults = [] ). Returns an associative array, with the defaults applied for properties not set for the wiki.

The data should be represented as nested arrays in JSON or PHP files. Multiple files can be combined by recursively merging the arrays. Basic structure:

{       "wikis": { "dewiki": { "family": "wikipedia", ...           },            "wikidatawiki": { ...           }        },        "aliases": { "de": "dewiki", "d": "wikidatawiki", "wd": "wikidatawiki", "wikipedia": "dewiki", ....l       } }