* (bug 25463) Export header should not be shown if no pages were requested, to reduce...
authorSam Reed <reedy@users.mediawiki.org>
Wed, 27 Oct 2010 15:42:32 +0000 (15:42 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Wed, 27 Oct 2010 15:42:32 +0000 (15:42 +0000)
Patch by Umherirrender, with a tweak to inverse logic to reduce nesting

RELEASE-NOTES
includes/api/ApiQuery.php

index 2cbc5b1..11393a6 100644 (file)
@@ -449,6 +449,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   used, rvlimit is enforced to 1.
 * If a action=parse request provides an oldid that is actually the current revision
   id, try the parser cache, and save it to it if necessary
+* (bug 25463) Export header should not be shown if no pages were requested, to
+  reduce confusion
 
 === Languages updated in 1.17 ===
 
index 4f2a1cf..40c5d4f 100644 (file)
@@ -457,15 +457,27 @@ 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;
+                                       }
+                               }
+                       }
+                       //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 ( $pageSet->getGoodTitles() as $title ) {
-                               if ( $title->userCanRead() ) {
-                                       $exporter->pageByTitle( $title );
-                               }
+                       foreach ( $exportTitles as $title ) {
+                               $exporter->pageByTitle( $title );
                        }
                        $exporter->closeStream();
                        $exportxml = ob_get_contents();