function provideSymlinkPathAndTarget() { $stage_dir = __DIR__ . '/../..'; $paths = array(); $jsonPath = getRealmSpecificFilename("{$stage_dir}/wikiversions.json"); $versionRows = MWWikiversions::readWikiVersionsFile($jsonPath); $activeVersions = array(); $versions = array(); foreach ($versionRows as $dbName => $version) { if (!isset($activeVersions[$version])) { // already listed? $activeVersions[$version] = 1; $version = substr($version, 4); // remove 'php-' $versions[] = $version; } } foreach ($versions as $version) { foreach (array('extensions', 'skins', 'resources') as $link) { $path = "{$stage_dir}/w/static/{$version}/{$link}"; $target = MEDIAWIKI_DEPLOYMENT_DIR . "/php-{$version}/{$link}"; $paths[] = array($path, $target); } } return $paths; }
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"; }
function getActiveWikiVersions() { global $argv; $options = str_replace('--home', '--staging', $argv); // accept '--home' as an alias for '--staging', for back-compat. array_shift($options); // first item is this file if (in_array('--staging', $options)) { $jsonPath = getRealmSpecificFilename(MEDIAWIKI_STAGING_DIR . '/wikiversions.json'); } else { $jsonPath = getRealmSpecificFilename(MEDIAWIKI_DEPLOYMENT_DIR . '/wikiversions.json'); } # Get all the wikiversion rows in wikiversions.json... try { $versionRows = MWWikiversions::readWikiVersionsFile($jsonPath); } catch (Exception $e) { if (in_array('--report', $options)) { throw $e; // show error } else { die(1); // silent death } } $result = $activeVersions = array(); foreach ($versionRows as $dbName => $version) { if (!isset($activeVersions[$version])) { // already listed? $activeVersions[$version] = 1; $version = substr($version, 4); // remove 'php-' if (in_array('--withdb', $options)) { $result[] = "{$version}={$dbName}"; } else { $result[] = "{$version}"; } } } return $result; }