Page MenuHomePhabricator
Paste P4820

example multi-request for cirrus config parameters
ActivePublic

Authored by EBernhardson on Jan 26 2017, 9:48 PM.
$config = MediaWiki\MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'CirrusSearch' );
$resolver = new CirrusSearch\SiteMatrixInterwikiResolver( $config );
$iwl = MediaWiki\MediaWikiServices::getInstance()->getInterwikiLookup();
$start = microtime(true);
$reqs = [];
foreach ( array_keys( $resolver->getSisterProjectPrefixes() ) as $iwPrefix ) {
$interwiki = $iwl->fetch( $iwPrefix );
$api = $interwiki->getAPI();
if ( !$api ) {
$host = parse_url( $interwiki->getURL(), PHP_URL_HOST );
$api = "https://$host/w/api.php";
}
$reqs[] = [
'method' => 'GET',
'url' => $api,
'query' => [ 'action' => 'cirrus-config-dump', 'format' => 'json' ]
];
}
$client = new MultiHttpClient([]);
$reqs = $client->runMulti($reqs);
var_dump($reqs);
var_dump(microtime(true) - $start);