Cleanup for r56298 "(bug 18180) Special:Export ignores limit, dir, offset parameters...
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 29 Sep 2009 21:37:07 +0000 (21:37 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 29 Sep 2009 21:37:07 +0000 (21:37 +0000)
Reorder the checks so that we get the is_array() out of the way first instead of relying on the weird type interaction between the array and the integers when doing binary AND. :)
Also made a fix so this actually works when $wgExportMaxHistory is set to 0, which per doc comment seems like it should not limit.

includes/Export.php
includes/specials/SpecialExport.php

index ff702c1..645ff4a 100644 (file)
@@ -207,24 +207,8 @@ class WikiExporter {
                        $opts = array( 'ORDER BY' => 'page_id ASC' );
                        $opts['USE INDEX'] = array();
                        $join = array();
-                       # Latest revision dumps...
-                       if( $this->history & WikiExporter::CURRENT ) {
-                               if( $this->list_authors && $cond != '' )  { // List authors, if so desired
-                                       list($page,$revision) = $this->db->tableNamesN('page','revision');
-                                       $this->do_list_authors( $page, $revision, $cond );
-                               }
-                               $join['revision'] = array('INNER JOIN','page_id=rev_page AND page_latest=rev_id');
-                       # "Stable" revision dumps...
-                       } elseif( $this->history & WikiExporter::STABLE ) {
-                               # Default JOIN, to be overridden...
-                               $join['revision'] = array('INNER JOIN','page_id=rev_page AND page_latest=rev_id');
-                               # One, and only one hook should set this, and return false
-                               if( wfRunHooks( 'WikiExporter::dumpStableQuery', array(&$tables,&$opts,&$join) ) ) {
-                                       wfProfileOut( __METHOD__ );
-                                       return new WikiError( __METHOD__." given invalid history dump type." );
-                               }
-                       # Time offset/limit for all pages/history...
-                       } elseif( is_array( $this->history ) ) {
+                       if( is_array( $this->history ) ) {
+                               # Time offset/limit for all pages/history...
                                $revJoin = 'page_id=rev_page';
                                # Set time order
                                if( $this->history['dir'] == 'asc' ) {
@@ -244,11 +228,27 @@ class WikiExporter {
                                if( !empty( $this->history['limit'] ) ) {
                                        $opts['LIMIT'] = intval( $this->history['limit'] );
                                }
-                       # Full history dumps...
                        } elseif( $this->history & WikiExporter::FULL ) {
+                               # Full history dumps...
                                $join['revision'] = array('INNER JOIN','page_id=rev_page');
-                       # Uknown history specification parameter?
+                       } elseif( $this->history & WikiExporter::CURRENT ) {
+                               # Latest revision dumps...
+                               if( $this->list_authors && $cond != '' )  { // List authors, if so desired
+                                       list($page,$revision) = $this->db->tableNamesN('page','revision');
+                                       $this->do_list_authors( $page, $revision, $cond );
+                               }
+                               $join['revision'] = array('INNER JOIN','page_id=rev_page AND page_latest=rev_id');
+                       } elseif( $this->history & WikiExporter::STABLE ) {
+                               # "Stable" revision dumps...
+                               # Default JOIN, to be overridden...
+                               $join['revision'] = array('INNER JOIN','page_id=rev_page AND page_latest=rev_id');
+                               # One, and only one hook should set this, and return false
+                               if( wfRunHooks( 'WikiExporter::dumpStableQuery', array(&$tables,&$opts,&$join) ) ) {
+                                       wfProfileOut( __METHOD__ );
+                                       return new WikiError( __METHOD__." given invalid history dump type." );
+                               }
                        } else {
+                               # Uknown history specification parameter?
                                wfProfileOut( __METHOD__ );
                                return new WikiError( __METHOD__." given invalid history dump type." );
                        }
index de4795a..d0423f2 100644 (file)
@@ -96,7 +96,7 @@ class SpecialExport extends SpecialPage {
                        if ( $this->curonly ) {
                                $history = WikiExporter::CURRENT;
                        } elseif ( !$historyCheck ) {
-                               if ( $limit > 0 && $limit < $wgExportMaxHistory ) {
+                               if ( $limit > 0 && ($wgExportMaxHistory == 0 || $limit < $wgExportMaxHistory ) ) {
                                        $history['limit'] = $limit;
                                }
                                if ( !is_null( $offset ) ) {