*/
private static $QueryMetaModules = [
'allmessages' => 'ApiQueryAllMessages',
+ 'authmanagerinfo' => 'ApiQueryAuthManagerInfo',
'siteinfo' => 'ApiQuerySiteinfo',
'userinfo' => 'ApiQueryUserInfo',
'filerepoinfo' => 'ApiQueryFileRepoInfo',
}
$exporter = new WikiExporter( $this->getDB() );
- // WikiExporter writes to stdout, so catch its
- // output with an ob
- ob_start();
+ $sink = new DumpStringOutput;
+ $exporter->setOutputSink( $sink );
$exporter->openStream();
foreach ( $exportTitles as $title ) {
$exporter->pageByTitle( $title );
}
$exporter->closeStream();
- $exportxml = ob_get_contents();
- ob_end_clean();
// Don't check the size of exported stuff
// It's not continuable, so it would cause more
if ( $this->mParams['exportnowrap'] ) {
$result->reset();
// Raw formatter will handle this
- $result->addValue( null, 'text', $exportxml, ApiResult::NO_SIZE_CHECK );
+ $result->addValue( null, 'text', $sink, ApiResult::NO_SIZE_CHECK );
$result->addValue( null, 'mime', 'text/xml', ApiResult::NO_SIZE_CHECK );
} else {
- $result->addValue( 'query', 'export', $exportxml, ApiResult::NO_SIZE_CHECK );
+ $result->addValue( 'query', 'export', $sink, ApiResult::NO_SIZE_CHECK );
$result->addValue( 'query', ApiResult::META_BC_SUBELEMENTS, [ 'export' ] );
}
}
return implode( "\n", $moduleDescriptions );
}
+ public function isReadMode() {
+ // We need to make an exception for certain meta modules that should be
+ // accessible even without the 'read' right. Restrict the exception as
+ // much as possible: no other modules allowed, and no pageset
+ // parameters either. We do allow the 'rawcontinue' and 'indexpageids'
+ // parameters since frameworks might add these unconditionally and they
+ // can't expose anything here.
+ $this->mParams = $this->extractRequestParams();
+ $params = array_filter(
+ array_diff_key(
+ $this->mParams + $this->getPageSet()->extractRequestParams(),
+ [ 'rawcontinue' => 1, 'indexpageids' => 1 ]
+ )
+ );
+ if ( array_keys( $params ) !== [ 'meta' ] ) {
+ return true;
+ }
+
+ // Ask each module if it requires read mode. Any true => this returns
+ // true.
+ $modules = [];
+ $this->instantiateModules( $modules, 'meta' );
+ foreach ( $modules as $module ) {
+ if ( $module->isReadMode() ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
protected function getExamplesMessages() {
return [
'action=query&prop=revisions&meta=siteinfo&' .