r101591 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101590‎ | r101591 | r101592 >
Date:07:58, 2 November 2011
Author:ariel
Status:ok
Tags:
Comment:
export specified range of revisions (as stubs)
Modified paths:
  • /trunk/phase3/includes/Export.php (modified) (history)
  • /trunk/phase3/maintenance/backup.inc (modified) (history)
  • /trunk/phase3/maintenance/dumpBackup.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/backup.inc
@@ -217,6 +217,8 @@
218218 } else if ( is_null( $this->pages ) ) {
219219 if ( $this->startId || $this->endId ) {
220220 $exporter->pagesByRange( $this->startId, $this->endId );
 221+ } elseif ( $this->revStartId || $this->revEndId ) {
 222+ $exporter->revsByRange( $this->revStartId, $this->revEndId );
221223 } else {
222224 $exporter->allPages();
223225 }
Index: trunk/phase3/maintenance/dumpBackup.php
@@ -27,7 +27,7 @@
2828
2929 $originalDir = getcwd();
3030
31 -$optionsWithArgs = array( 'pagelist', 'start', 'end' );
 31+$optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend');
3232
3333 require_once( dirname( __FILE__ ) . '/commandLine.inc' );
3434 require_once( 'backup.inc' );
@@ -57,6 +57,13 @@
5858 if ( isset( $options['end'] ) ) {
5959 $dumper->endId = intval( $options['end'] );
6060 }
 61+
 62+if ( isset( $options['revstart'] ) ) {
 63+ $dumper->revStartId = intval( $options['revstart'] );
 64+}
 65+if ( isset( $options['revend'] ) ) {
 66+ $dumper->revEndId = intval( $options['revend'] );
 67+}
6168 $dumper->skipHeader = isset( $options['skip-header'] );
6269 $dumper->skipFooter = isset( $options['skip-footer'] );
6370 $dumper->dumpUploads = isset( $options['uploads'] );
@@ -72,6 +79,8 @@
7380 $dumper->dump( WikiExporter::STABLE, $textMode );
7481 } elseif ( isset( $options['logs'] ) ) {
7582 $dumper->dump( WikiExporter::LOGS );
 83+} elseif ( isset($options['revrange'] ) ) {
 84+ $dumper->dump( WikiExporter::RANGE, $textMode );
7685 } else {
7786 $dumper->progress( <<<ENDS
7887 This script dumps the wiki page or logging database into an
@@ -87,7 +96,8 @@
8897 --stable Stable versions of pages?
8998 --pagelist=<file>
9099 Where <file> is a list of page titles to be dumped
91 -
 100+ --revrange Dump specified range of revisions, requires
 101+ revstart and revend options.
92102 Options:
93103 --quiet Don't dump status reports to stderr.
94104 --report=n Report position and speed after every n pages processed.
@@ -95,6 +105,8 @@
96106 --server=h Force reading from MySQL server h
97107 --start=n Start from page_id or log_id n
98108 --end=n Stop before page_id or log_id n (exclusive)
 109+ --revstart=n Start from rev_id n
 110+ --revend=n Stop before rev_id n (exclusive)
99111 --skip-header Don't output the <mediawiki> header
100112 --skip-footer Don't output the </mediawiki> footer
101113 --stub Don't perform old_text lookups; for 2-pass dump
Index: trunk/phase3/includes/Export.php
@@ -41,6 +41,7 @@
4242 const CURRENT = 2;
4343 const STABLE = 4; // extension defined
4444 const LOGS = 8;
 45+ const RANGE = 16;
4546
4647 const BUFFER = 0;
4748 const STREAM = 1;
@@ -56,7 +57,8 @@
5758 * main query is still running.
5859 *
5960 * @param $db Database
60 - * @param $history Mixed: one of WikiExporter::FULL or WikiExporter::CURRENT,
 61+ * @param $history Mixed: one of WikiExporter::FULL, WikiExporter::CURRENT,
 62+ * WikiExporter::RANGE or WikiExporter::STABLE,
6163 * or an associative array:
6264 * offset: non-inclusive offset at which to start the query
6365 * limit: maximum number of rows to return
@@ -120,6 +122,21 @@
121123 }
122124
123125 /**
 126+ * Dumps a series of page and revision records for those pages
 127+ * in the database with revisions falling within the rev_id range given.
 128+ * @param $start Int: inclusive lower limit (this id is included)
 129+ * @param $end Int: Exclusive upper limit (this id is not included)
 130+ * If 0, no upper limit.
 131+ */
 132+ public function revsByRange( $start, $end ) {
 133+ $condition = 'rev_id >= ' . intval( $start );
 134+ if ( $end ) {
 135+ $condition .= ' AND rev_id < ' . intval( $end );
 136+ }
 137+ return $this->dumpFrom( $condition );
 138+ }
 139+
 140+ /**
124141 * @param $title Title
125142 */
126143 public function pageByTitle( $title ) {
@@ -259,6 +276,10 @@
260277 wfProfileOut( __METHOD__ );
261278 throw new MWException( __METHOD__ . " given invalid history dump type." );
262279 }
 280+ } elseif ( $this->history & WikiExporter::RANGE ) {
 281+ # Dump of revisions within a specified range
 282+ $join['revision'] = array( 'INNER JOIN', 'page_id=rev_page' );
 283+ $opts['ORDER BY'] = 'rev_page ASC, rev_id ASC';
263284 } else {
264285 # Uknown history specification parameter?
265286 wfProfileOut( __METHOD__ );

Follow-up revisions

RevisionCommit summaryAuthorDate
r101744[JSTesting] partial rewrite of TestSwarmMWFetcher...krinkle23:17, 2 November 2011
r103041REL1_18 MFT r96616, r97889...reedy21:43, 14 November 2011
r1030431.18wmf1 MFT r103041...reedy21:46, 14 November 2011

Status & tagging log