+ # For page dumps...
+ } else {
+ $tables = array( 'page', 'revision' );
+ $opts = array( 'ORDER BY' => 'page_id ASC' );
+ $opts['USE INDEX'] = array();
+ $join = array();
+ 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' ) {
+ $op = '>';
+ $opts['ORDER BY'] = 'rev_timestamp ASC';
+ } else {
+ $op = '<';
+ $opts['ORDER BY'] = 'rev_timestamp DESC';
+ }
+ # Set offset
+ if( !empty( $this->history['offset'] ) ) {
+ $revJoin .= " AND rev_timestamp $op " .
+ $this->db->addQuotes( $this->db->timestamp( $this->history['offset'] ) );
+ }
+ $join['revision'] = array('INNER JOIN',$revJoin);
+ # Set query limit
+ if( !empty( $this->history['limit'] ) ) {
+ $opts['LIMIT'] = intval( $this->history['limit'] );
+ }
+ } elseif( $this->history & WikiExporter::FULL ) {
+ # Full history dumps...
+ $join['revision'] = array('INNER JOIN','page_id=rev_page');
+ } 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." );
+ }