const CURRENT = 2;
const STABLE = 4; // extension defined
const LOGS = 8;
+ const RANGE = 16;
const BUFFER = 0;
const STREAM = 1;
* 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
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
*/
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__ );
$originalDir = getcwd();
-$optionsWithArgs = array( 'pagelist', 'start', 'end' );
+$optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend');
require_once( dirname( __FILE__ ) . '/commandLine.inc' );
require_once( 'backup.inc' );
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'] );
$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( <<<ENDS
This script dumps the wiki page or logging database into an
--stable Stable versions of pages?
--pagelist=<file>
Where <file> 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.
--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 <mediawiki> header
--skip-footer Don't output the </mediawiki> footer
--stub Don't perform old_text lookups; for 2-pass dump