r57083 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57082‎ | r57083 | r57084 >
Date:21:37, 29 September 2009
Author:brion
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/Export.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialExport.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Export.php
@@ -207,24 +207,8 @@
208208 $opts = array( 'ORDER BY' => 'page_id ASC' );
209209 $opts['USE INDEX'] = array();
210210 $join = array();
211 - # Latest revision dumps...
212 - if( $this->history & WikiExporter::CURRENT ) {
213 - if( $this->list_authors && $cond != '' ) { // List authors, if so desired
214 - list($page,$revision) = $this->db->tableNamesN('page','revision');
215 - $this->do_list_authors( $page, $revision, $cond );
216 - }
217 - $join['revision'] = array('INNER JOIN','page_id=rev_page AND page_latest=rev_id');
218 - # "Stable" revision dumps...
219 - } elseif( $this->history & WikiExporter::STABLE ) {
220 - # Default JOIN, to be overridden...
221 - $join['revision'] = array('INNER JOIN','page_id=rev_page AND page_latest=rev_id');
222 - # One, and only one hook should set this, and return false
223 - if( wfRunHooks( 'WikiExporter::dumpStableQuery', array(&$tables,&$opts,&$join) ) ) {
224 - wfProfileOut( __METHOD__ );
225 - return new WikiError( __METHOD__." given invalid history dump type." );
226 - }
227 - # Time offset/limit for all pages/history...
228 - } elseif( is_array( $this->history ) ) {
 211+ if( is_array( $this->history ) ) {
 212+ # Time offset/limit for all pages/history...
229213 $revJoin = 'page_id=rev_page';
230214 # Set time order
231215 if( $this->history['dir'] == 'asc' ) {
@@ -244,11 +228,27 @@
245229 if( !empty( $this->history['limit'] ) ) {
246230 $opts['LIMIT'] = intval( $this->history['limit'] );
247231 }
248 - # Full history dumps...
249232 } elseif( $this->history & WikiExporter::FULL ) {
 233+ # Full history dumps...
250234 $join['revision'] = array('INNER JOIN','page_id=rev_page');
251 - # Uknown history specification parameter?
 235+ } elseif( $this->history & WikiExporter::CURRENT ) {
 236+ # Latest revision dumps...
 237+ if( $this->list_authors && $cond != '' ) { // List authors, if so desired
 238+ list($page,$revision) = $this->db->tableNamesN('page','revision');
 239+ $this->do_list_authors( $page, $revision, $cond );
 240+ }
 241+ $join['revision'] = array('INNER JOIN','page_id=rev_page AND page_latest=rev_id');
 242+ } elseif( $this->history & WikiExporter::STABLE ) {
 243+ # "Stable" revision dumps...
 244+ # Default JOIN, to be overridden...
 245+ $join['revision'] = array('INNER JOIN','page_id=rev_page AND page_latest=rev_id');
 246+ # One, and only one hook should set this, and return false
 247+ if( wfRunHooks( 'WikiExporter::dumpStableQuery', array(&$tables,&$opts,&$join) ) ) {
 248+ wfProfileOut( __METHOD__ );
 249+ return new WikiError( __METHOD__." given invalid history dump type." );
 250+ }
252251 } else {
 252+ # Uknown history specification parameter?
253253 wfProfileOut( __METHOD__ );
254254 return new WikiError( __METHOD__." given invalid history dump type." );
255255 }
Index: trunk/phase3/includes/specials/SpecialExport.php
@@ -96,7 +96,7 @@
9797 if ( $this->curonly ) {
9898 $history = WikiExporter::CURRENT;
9999 } elseif ( !$historyCheck ) {
100 - if ( $limit > 0 && $limit < $wgExportMaxHistory ) {
 100+ if ( $limit > 0 && ($wgExportMaxHistory == 0 || $limit < $wgExportMaxHistory ) ) {
101101 $history['limit'] = $limit;
102102 }
103103 if ( !is_null( $offset ) ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r56298(bug 18180) Special:Export ignores limit, dir, offset parameters. Patch by az...catrope12:57, 14 September 2009

Status & tagging log