From c1c7c674d910a474dfd2bb1c577ed9d25b908912 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 29 Sep 2009 21:37:07 +0000 Subject: [PATCH] Cleanup for r56298 "(bug 18180) Special:Export ignores limit, dir, offset parameters. Patch by azliq7" 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 | 40 ++++++++++++++--------------- includes/specials/SpecialExport.php | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/includes/Export.php b/includes/Export.php index ff702c1433..645ff4a308 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -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." ); } diff --git a/includes/specials/SpecialExport.php b/includes/specials/SpecialExport.php index de4795a375..d0423f2880 100644 --- a/includes/specials/SpecialExport.php +++ b/includes/specials/SpecialExport.php @@ -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 ) ) { -- 2.20.1