From: Ariel Glenn Date: Wed, 2 Nov 2011 07:58:43 +0000 (+0000) Subject: export specified range of revisions (as stubs) X-Git-Tag: 1.31.0-rc.0~26764 X-Git-Url: http://git.cyclocoop.org/%27.%28%24current%20%3E%202?a=commitdiff_plain;h=669e5b9318af2906214834db4904b3c57693229f;p=lhc%2Fweb%2Fwiklou.git export specified range of revisions (as stubs) --- diff --git a/includes/Export.php b/includes/Export.php index 489a9284ec..3dcd3baeb5 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -41,6 +41,7 @@ class WikiExporter { const CURRENT = 2; const STABLE = 4; // extension defined const LOGS = 8; + const RANGE = 16; const BUFFER = 0; const STREAM = 1; @@ -56,7 +57,8 @@ class WikiExporter { * main query is still running. * * @param $db Database - * @param $history Mixed: one of WikiExporter::FULL or WikiExporter::CURRENT, + * @param $history Mixed: one of WikiExporter::FULL, WikiExporter::CURRENT, + * WikiExporter::RANGE or WikiExporter::STABLE, * or an associative array: * offset: non-inclusive offset at which to start the query * limit: maximum number of rows to return @@ -119,6 +121,21 @@ class WikiExporter { return $this->dumpFrom( $condition ); } + /** + * Dumps a series of page and revision records for those pages + * in the database with revisions falling within the rev_id range given. + * @param $start Int: inclusive lower limit (this id is included) + * @param $end Int: Exclusive upper limit (this id is not included) + * If 0, no upper limit. + */ + public function revsByRange( $start, $end ) { + $condition = 'rev_id >= ' . intval( $start ); + if ( $end ) { + $condition .= ' AND rev_id < ' . intval( $end ); + } + return $this->dumpFrom( $condition ); + } + /** * @param $title Title */ @@ -259,6 +276,10 @@ class WikiExporter { wfProfileOut( __METHOD__ ); throw new MWException( __METHOD__ . " given invalid history dump type." ); } + } elseif ( $this->history & WikiExporter::RANGE ) { + # Dump of revisions within a specified range + $join['revision'] = array( 'INNER JOIN', 'page_id=rev_page' ); + $opts['ORDER BY'] = 'rev_page ASC, rev_id ASC'; } else { # Uknown history specification parameter? wfProfileOut( __METHOD__ ); diff --git a/maintenance/backup.inc b/maintenance/backup.inc index 36c3beb573..814d0c09d0 100644 --- a/maintenance/backup.inc +++ b/maintenance/backup.inc @@ -217,6 +217,8 @@ class BackupDumper { } else if ( is_null( $this->pages ) ) { if ( $this->startId || $this->endId ) { $exporter->pagesByRange( $this->startId, $this->endId ); + } elseif ( $this->revStartId || $this->revEndId ) { + $exporter->revsByRange( $this->revStartId, $this->revEndId ); } else { $exporter->allPages(); } diff --git a/maintenance/dumpBackup.php b/maintenance/dumpBackup.php index e058198c58..15189261d5 100644 --- a/maintenance/dumpBackup.php +++ b/maintenance/dumpBackup.php @@ -27,7 +27,7 @@ $originalDir = getcwd(); -$optionsWithArgs = array( 'pagelist', 'start', 'end' ); +$optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend'); require_once( dirname( __FILE__ ) . '/commandLine.inc' ); require_once( 'backup.inc' ); @@ -57,6 +57,13 @@ if ( isset( $options['start'] ) ) { if ( isset( $options['end'] ) ) { $dumper->endId = intval( $options['end'] ); } + +if ( isset( $options['revstart'] ) ) { + $dumper->revStartId = intval( $options['revstart'] ); +} +if ( isset( $options['revend'] ) ) { + $dumper->revEndId = intval( $options['revend'] ); +} $dumper->skipHeader = isset( $options['skip-header'] ); $dumper->skipFooter = isset( $options['skip-footer'] ); $dumper->dumpUploads = isset( $options['uploads'] ); @@ -72,6 +79,8 @@ if ( isset( $options['full'] ) ) { $dumper->dump( WikiExporter::STABLE, $textMode ); } elseif ( isset( $options['logs'] ) ) { $dumper->dump( WikiExporter::LOGS ); +} elseif ( isset($options['revrange'] ) ) { + $dumper->dump( WikiExporter::RANGE, $textMode ); } else { $dumper->progress( << Where is a list of page titles to be dumped - + --revrange Dump specified range of revisions, requires + revstart and revend options. Options: --quiet Don't dump status reports to stderr. --report=n Report position and speed after every n pages processed. @@ -95,6 +105,8 @@ Options: --server=h Force reading from MySQL server h --start=n Start from page_id or log_id n --end=n Stop before page_id or log_id n (exclusive) + --revstart=n Start from rev_id n + --revend=n Stop before rev_id n (exclusive) --skip-header Don't output the header --skip-footer Don't output the footer --stub Don't perform old_text lookups; for 2-pass dump