From 2b81e29ac5d918af02d3b8d783e169c882b3bbfe Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Fri, 29 Oct 2010 12:20:11 +0000 Subject: [PATCH] Followup r75554, functionise Export code, allows for return to be used "non scarily" Remove some extra blank comment lines --- includes/api/ApiQuery.php | 89 +++++++++++++++++++++------------------ includes/api/ApiRsd.php | 1 - 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index 40c5d4f547..61fa18e31d 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -383,9 +383,7 @@ class ApiQuery extends ApiBase { $result->addValue( 'query', 'redirects', $redirValues ); } - // // Missing revision elements - // $missingRevIDs = $pageSet->getMissingRevisionIDs(); if ( count( $missingRevIDs ) ) { $revids = array(); @@ -398,9 +396,7 @@ class ApiQuery extends ApiBase { $result->addValue( 'query', 'badrevids', $revids ); } - // // Page elements - // $pages = array(); // Report any missing titles @@ -457,48 +453,57 @@ class ApiQuery extends ApiBase { $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(); - - // 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(); + $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(); } /** diff --git a/includes/api/ApiRsd.php b/includes/api/ApiRsd.php index 552de59706..91188a2419 100644 --- a/includes/api/ApiRsd.php +++ b/includes/api/ApiRsd.php @@ -41,7 +41,6 @@ class ApiRsd extends ApiBase { public function execute() { $result = $this->getResult(); - $result->addValue( null, 'version', '1.0' ); $result->addValue( null, 'xmlns', 'http://archipelago.phrasewise.com/rsd' ); -- 2.20.1