r75641 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75640‎ | r75641 | r75642 >
Date:12:20, 29 October 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
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 (modified) (history)
  • /trunk/phase3/includes/api/ApiRsd.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQuery.php
@@ -383,9 +383,7 @@
384384 $result->addValue( 'query', 'redirects', $redirValues );
385385 }
386386
387 - //
388387 // Missing revision elements
389 - //
390388 $missingRevIDs = $pageSet->getMissingRevisionIDs();
391389 if ( count( $missingRevIDs ) ) {
392390 $revids = array();
@@ -398,9 +396,7 @@
399397 $result->addValue( 'query', 'badrevids', $revids );
400398 }
401399
402 - //
403400 // Page elements
404 - //
405401 $pages = array();
406402
407403 // Report any missing titles
@@ -457,48 +453,57 @@
458454 $result->addValue( 'query', 'pages', $pages );
459455 }
460456 if ( $this->params['export'] ) {
461 - $exportTitles = array();
462 - $titles = $pageSet->getGoodTitles();
463 - if( count( $titles ) ) {
464 - foreach ( $titles as $title ) {
465 - if ( $title->userCanRead() ) {
466 - $exportTitles[] = $title;
467 - }
 457+ $this->doExport( $pageSet, $result );
 458+ }
 459+ }
 460+
 461+ /**
 462+ * @param $pageSet ApiPageSet
 463+ * @param $result ApiResult
 464+ * @return
 465+ */
 466+ private function doExport( $pageSet, $result ) {
 467+ $exportTitles = array();
 468+ $titles = $pageSet->getGoodTitles();
 469+ if( count( $titles ) ) {
 470+ foreach ( $titles as $title ) {
 471+ if ( $title->userCanRead() ) {
 472+ $exportTitles[] = $title;
468473 }
469474 }
470 - //export, when there are titles
471 - if ( !count( $exportTitles ) ) {
472 - return;
473 - }
 475+ }
 476+ // only export when there are titles
 477+ if ( !count( $exportTitles ) ) {
 478+ return;
 479+ }
474480
475 - $exporter = new WikiExporter( $this->getDB() );
476 - // WikiExporter writes to stdout, so catch its
477 - // output with an ob
478 - ob_start();
479 - $exporter->openStream();
480 - foreach ( $exportTitles as $title ) {
481 - $exporter->pageByTitle( $title );
482 - }
483 - $exporter->closeStream();
484 - $exportxml = ob_get_contents();
485 - ob_end_clean();
 481+ $exporter = new WikiExporter( $this->getDB() );
 482+ // WikiExporter writes to stdout, so catch its
 483+ // output with an ob
 484+ ob_start();
 485+ $exporter->openStream();
 486+ foreach ( $exportTitles as $title ) {
 487+ $exporter->pageByTitle( $title );
 488+ }
 489+ $exporter->closeStream();
 490+ $exportxml = ob_get_contents();
 491+ ob_end_clean();
486492
487 - // Don't check the size of exported stuff
488 - // It's not continuable, so it would cause more
489 - // problems than it'd solve
490 - $result->disableSizeCheck();
491 - if ( $this->params['exportnowrap'] ) {
492 - $result->reset();
493 - // Raw formatter will handle this
494 - $result->addValue( null, 'text', $exportxml );
495 - $result->addValue( null, 'mime', 'text/xml' );
496 - } else {
497 - $r = array();
498 - ApiResult::setContent( $r, $exportxml );
499 - $result->addValue( 'query', 'export', $r );
500 - }
501 - $result->enableSizeCheck();
 493+ // Don't check the size of exported stuff
 494+ // It's not continuable, so it would cause more
 495+ // problems than it'd solve
 496+ $result->disableSizeCheck();
 497+ if ( $this->params['exportnowrap'] ) {
 498+ $result->reset();
 499+ // Raw formatter will handle this
 500+ $result->addValue( null, 'text', $exportxml );
 501+ $result->addValue( null, 'mime', 'text/xml' );
 502+ } else {
 503+ $r = array();
 504+ ApiResult::setContent( $r, $exportxml );
 505+ $result->addValue( 'query', 'export', $r );
502506 }
 507+ $result->enableSizeCheck();
503508 }
504509
505510 /**
Index: trunk/phase3/includes/api/ApiRsd.php
@@ -41,7 +41,6 @@
4242
4343 public function execute() {
4444 $result = $this->getResult();
45 -
4645
4746 $result->addValue( null, 'version', '1.0' );
4847 $result->addValue( null, 'xmlns', 'http://archipelago.phrasewise.com/rsd' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r75782Followup r75641, improve function documentationreedy11:57, 1 November 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75554* (bug 25463) Export header should not be shown if no pages were requested, t...reedy15:42, 27 October 2010

Comments

#Comment by Catrope (talk | contribs)   19:45, 31 October 2010
+	/**
+	 * @param  $pageSet ApiPageSet
+	 * @param  $result ApiResult
+	 * @return
+	 */

Mind providing something more informative here?

Status & tagging log