http://www.mediawiki.org/wiki/Special:Code/MediaWiki/75641
Revision: 75641 Author: reedy Date: 2010-10-29 12:20:11 +0000 (Fri, 29 Oct 2010) Log Message: ----------- Followup r75554, functionise Export code, allows for return to be used "non scarily" Remove some extra blank comment lines Modified Paths: -------------- trunk/phase3/includes/api/ApiQuery.php trunk/phase3/includes/api/ApiRsd.php Modified: trunk/phase3/includes/api/ApiQuery.php =================================================================== --- trunk/phase3/includes/api/ApiQuery.php 2010-10-29 05:52:38 UTC (rev 75640) +++ trunk/phase3/includes/api/ApiQuery.php 2010-10-29 12:20:11 UTC (rev 75641) @@ -383,9 +383,7 @@ $result->addValue( 'query', 'redirects', $redirValues ); } - // // Missing revision elements - // $missingRevIDs = $pageSet->getMissingRevisionIDs(); if ( count( $missingRevIDs ) ) { $revids = array(); @@ -398,9 +396,7 @@ $result->addValue( 'query', 'badrevids', $revids ); } - // // Page elements - // $pages = array(); // Report any missing titles @@ -457,48 +453,57 @@ $result->addValue( 'query', 'pages', $pages ); } if ( $this->params['export'] ) { - $exportTitles = array(); - $titles = $pageSet->getGoodTitles(); - if( count( $titles ) ) { - foreach ( $titles as $title ) { - if ( $title->userCanRead() ) { - $exportTitles[] = $title; - } + $this->doExport( $pageSet, $result ); + } + } + + /** + * @param $pageSet ApiPageSet + * @param $result ApiResult + * @return + */ + private function doExport( $pageSet, $result ) { + $exportTitles = array(); + $titles = $pageSet->getGoodTitles(); + if( count( $titles ) ) { + foreach ( $titles as $title ) { + if ( $title->userCanRead() ) { + $exportTitles[] = $title; } } - //export, when there are titles - if ( !count( $exportTitles ) ) { - return; - } + } + // only export when there are titles + if ( !count( $exportTitles ) ) { + return; + } - $exporter = new WikiExporter( $this->getDB() ); - // WikiExporter writes to stdout, so catch its - // output with an ob - ob_start(); - $exporter->openStream(); - foreach ( $exportTitles as $title ) { - $exporter->pageByTitle( $title ); - } - $exporter->closeStream(); - $exportxml = ob_get_contents(); - ob_end_clean(); + $exporter = new WikiExporter( $this->getDB() ); + // WikiExporter writes to stdout, so catch its + // output with an ob + ob_start(); + $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 - // problems than it'd solve - $result->disableSizeCheck(); - if ( $this->params['exportnowrap'] ) { - $result->reset(); - // Raw formatter will handle this - $result->addValue( null, 'text', $exportxml ); - $result->addValue( null, 'mime', 'text/xml' ); - } else { - $r = array(); - ApiResult::setContent( $r, $exportxml ); - $result->addValue( 'query', 'export', $r ); - } - $result->enableSizeCheck(); + // Don't check the size of exported stuff + // It's not continuable, so it would cause more + // problems than it'd solve + $result->disableSizeCheck(); + if ( $this->params['exportnowrap'] ) { + $result->reset(); + // Raw formatter will handle this + $result->addValue( null, 'text', $exportxml ); + $result->addValue( null, 'mime', 'text/xml' ); + } else { + $r = array(); + ApiResult::setContent( $r, $exportxml ); + $result->addValue( 'query', 'export', $r ); } + $result->enableSizeCheck(); } /** Modified: trunk/phase3/includes/api/ApiRsd.php =================================================================== --- trunk/phase3/includes/api/ApiRsd.php 2010-10-29 05:52:38 UTC (rev 75640) +++ trunk/phase3/includes/api/ApiRsd.php 2010-10-29 12:20:11 UTC (rev 75641) @@ -41,7 +41,6 @@ public function execute() { $result = $this->getResult(); - $result->addValue( null, 'version', '1.0' ); $result->addValue( null, 'xmlns', 'http://archipelago.phrasewise.com/rsd' ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs