function wmfImportSources(&$sources)
{
    global $wgConf, $IP, $lang;
    $wikipedias = array_flip(MWWikiversions::readDbListFile(getRealmSpecificFilename("{$IP}/../wikipedia.dblist")));
    $privates = array_flip(MWWikiversions::readDbListFile(getRealmSpecificFilename("{$IP}/../private.dblist")));
    // REMEMBER when editing this function, the values here are *interwiki prefixes*.
    // Sometimes the interwiki map does things you don't expect.
    // Look at dumpInterwiki.php in WikimediaMaintenance for guidance.
    // Enforce a sensible order
    $sources = array('meta', 'commons', 'incubator', 'wikipedia' => array(), 'wiktionary' => array(), 'wikibooks' => array(), 'wikinews' => array(), 'wikiquote' => array(), 'wikisource' => array('oldwikisource'), 'wikiversity' => array('betawikiversity'), 'wikivoyage' => array(), 'chapter' => array(), 'foundation', 'mediawikiwiki', 'nostalgia', 'outreach', 'strategy', 'tenwiki', 'testwiki', 'test2wiki', 'testwikidata', 'usability', 'wikidata', 'wikispecies', 'wikitech', 'wmania' => array('wm2005', 'wm2006', 'wm2007', 'wm2008', 'wm2009', 'wm2010', 'wm2011', 'wm2012', 'wm2013', 'wm2014', 'wm2015', 'wm2016'));
    // Add all regular language projects as import sources
    foreach ($wgConf->getLocalDatabases() as $dbname) {
        // No importing from private wikis
        if (isset($privates[$dbname])) {
            continue;
        }
        list($project, $subdomain) = $wgConf->siteFromDB($dbname);
        if ($project === 'wikimedia') {
            $sources['chapter'][] = $subdomain;
        } elseif ($subdomain === 'en' || $subdomain === $lang) {
            // Put $lang and en at the top for convenience
            array_unshift($sources[$project], $subdomain);
        } elseif (($project !== 'wikipedia' || isset($wikipedias[$dbname])) && $subdomain !== 'beta') {
            $sources[$project][] = $subdomain;
        }
    }
}
 /**
  * @covers MWWikiversions::evalDbListExpression
  */
 function testEvalDbListExpression()
 {
     $allDbs = MWWikiversions::readDbListFile('all');
     $allLabsDbs = MWWikiversions::readDbListFile('private');
     $exprDbs = MWWikiversions::evalDbListExpression('all - private');
     $expectedDbs = array_diff($allDbs, $allLabsDbs);
     sort($exprDbs);
     sort($expectedDbs);
     $this->assertEquals($exprDbs, $expectedDbs);
 }
 public static function getall()
 {
     static $list = null;
     if ($list) {
         return $list;
     }
     $objects = scandir(dirname(__DIR__) . '/dblists');
     foreach ($objects as $filename) {
         if (substr($filename, -7, 7) == '.dblist') {
             $projectname = substr($filename, 0, -7);
             # Happilly prefetch the files content
             $list[$projectname] = MWWikiversions::readDbListFile($filename);
         }
     }
     return $list;
 }
function updateWikiversions()
{
    global $argv;
    $common = MEDIAWIKI_STAGING_DIR;
    $jsonPath = getRealmSpecificFilename(MEDIAWIKI_STAGING_DIR . '/wikiversions.json');
    if (count($argv) !== 3) {
        print "Usage: updateWikiversions <name>.dblist php-X.XX-wmf.X\n";
        exit(1);
    }
    $dbListName = basename($argv[1], '.dblist');
    $dbList = MWWikiversions::readDbListFile($dbListName);
    $newVersion = $argv[2];
    if (!preg_match(MEDIAWIKI_DIRECTORY_REGEX, $newVersion) || !is_dir("{$common}/{$newVersion}")) {
        print "Invalid version specifier: {$newVersion}\n";
        exit(1);
    }
    if (file_exists($jsonPath)) {
        $versionRows = MWWikiversions::readWikiVersionsFile($jsonPath);
    } else {
        if ($dbListName !== 'all') {
            echo "No {$jsonPath} file and not invoked with 'all'. Cowardly refusing to act.\n";
            exit(1);
        }
        echo "{$jsonPath} not found -- rebuilding from scratch!\n";
        $versionRows = array();
    }
    $inserted = 0;
    $migrated = 0;
    foreach ($dbList as $dbName) {
        if (!isset($versionRows[$dbName])) {
            $inserted++;
        } else {
            $migrated++;
        }
        $versionRows[$dbName] = $newVersion;
    }
    $total = count($versionRows);
    ksort($versionRows);
    MWWikiversions::writeWikiVersionsFile($jsonPath, $versionRows);
    echo "Updated {$jsonPath}: {$inserted} inserted, {$migrated} migrated.\n";
}
<?php

# This file is used by commandLine.inc and CommonSettings.php to initialise $wgConf
# WARNING: This file is publically viewable on the web. Do not put private data here.
$wgConf = new SiteConfiguration();
# Read wiki lists
$wgConf->suffixes = array('wikipedia' => 'wiki', 'wiktionary', 'wikiquote', 'wikibooks', 'wikiquote', 'wikinews', 'wikisource', 'wikiversity', 'wikimedia', 'wikivoyage');
$dbList = $wmfRealm === 'labs' ? 'all-labs' : 'all';
$wgConf->wikis = MWWikiversions::readDbListFile($dbList);
$wgConf->fullLoadCallback = 'wmfLoadInitialiseSettings';
$wgLocalDatabases =& $wgConf->getLocalDatabases();
 /**
  * This function is used for both the CentralAuthWikiList and
  * GlobalUserPageWikis hooks.
  */
 function wmfCentralAuthWikiList(&$list)
 {
     global $wgLocalDatabases, $IP, $wgSiteMatrixPrivateSites, $wgSiteMatrixFishbowlSites, $wgSiteMatrixClosedSites;
     $list = array_diff($wgLocalDatabases, $wgSiteMatrixPrivateSites, $wgSiteMatrixFishbowlSites, $wgSiteMatrixClosedSites, MWWikiversions::readDbListFile('nonglobal'));
     return false;
 }
 $wgExtraNamespaces[WB_NS_QUERY_TALK] = 'Query_talk';
 $wgWBRepoSettings = $wgWBSharedSettings + $wgWBRepoSettings;
 // Assigning the correct content models to the namespaces
 $wgWBRepoSettings['entityNamespaces'][CONTENT_MODEL_WIKIBASE_ITEM] = NS_MAIN;
 $wgWBRepoSettings['entityNamespaces'][CONTENT_MODEL_WIKIBASE_PROPERTY] = WB_NS_PROPERTY;
 $wgWBRepoSettings['normalizeItemByTitlePageNames'] = true;
 $wgWBRepoSettings['dataRightsText'] = 'Creative Commons CC0 License';
 $wgWBRepoSettings['dataRightsUrl'] = 'https://creativecommons.org/publicdomain/zero/1.0/';
 if ($wgDBname === 'testwikidatawiki') {
     // there is no cronjob dispatcher yet, this will do nothing
     $wgWBRepoSettings['clientDbList'] = array('testwiki', 'test2wiki', 'testwikidatawiki');
     $wgPropertySuggesterClassifyingPropertyIds = array(7);
 } else {
     $wgWBRepoSettings['clientDbList'] = array_diff(MWWikiversions::readDbListFile('wikidataclient'), array('testwikidatawiki', 'testwiki', 'test2wiki'));
     // Exclude closed wikis
     $wgWBRepoSettings['clientDbList'] = array_diff($wgWBRepoSettings['clientDbList'], MWWikiversions::readDbListFile($wmfRealm === 'labs' ? 'closed-labs' : 'closed'));
 }
 $wgWBRepoSettings['localClientDatabases'] = array_combine($wgWBRepoSettings['clientDbList'], $wgWBRepoSettings['clientDbList']);
 // T53637 and T48953
 $wgGroupPermissions['*']['property-create'] = $wgDBname === 'testwikidatawiki';
 $wgCacheEpoch = '20151020232024';
 $wgWBRepoSettings['dataSquidMaxage'] = 1 * 60 * 60;
 $wgWBRepoSettings['sharedCacheDuration'] = 60 * 60 * 24;
 $wgWBRepoSettings['sharedCacheKeyPrefix'] .= $wgWBSharedCacheKey;
 $wgPropertySuggesterMinProbability = 0.06900000000000001;
 // T72346
 $wgPropertySuggesterDeprecatedIds = array(107, 143, 357, 392, 438, 513, 741, 1134);
 if (!in_array('pageterms', $wgMFQueryPropModules)) {
     $wgMFQueryPropModules[] = 'pageterms';
 }
 $wgMFSearchAPIParams['wbptterms'] = array('label');