Index: trunk/phase3/maintenance/backup.inc |
— | — | @@ -217,6 +217,8 @@ |
218 | 218 | } else if ( is_null( $this->pages ) ) { |
219 | 219 | if ( $this->startId || $this->endId ) { |
220 | 220 | $exporter->pagesByRange( $this->startId, $this->endId ); |
| 221 | + } elseif ( $this->revStartId || $this->revEndId ) { |
| 222 | + $exporter->revsByRange( $this->revStartId, $this->revEndId ); |
221 | 223 | } else { |
222 | 224 | $exporter->allPages(); |
223 | 225 | } |
Index: trunk/phase3/maintenance/dumpBackup.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | |
29 | 29 | $originalDir = getcwd(); |
30 | 30 | |
31 | | -$optionsWithArgs = array( 'pagelist', 'start', 'end' ); |
| 31 | +$optionsWithArgs = array( 'pagelist', 'start', 'end', 'revstart', 'revend'); |
32 | 32 | |
33 | 33 | require_once( dirname( __FILE__ ) . '/commandLine.inc' ); |
34 | 34 | require_once( 'backup.inc' ); |
— | — | @@ -57,6 +57,13 @@ |
58 | 58 | if ( isset( $options['end'] ) ) { |
59 | 59 | $dumper->endId = intval( $options['end'] ); |
60 | 60 | } |
| 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 | +} |
61 | 68 | $dumper->skipHeader = isset( $options['skip-header'] ); |
62 | 69 | $dumper->skipFooter = isset( $options['skip-footer'] ); |
63 | 70 | $dumper->dumpUploads = isset( $options['uploads'] ); |
— | — | @@ -72,6 +79,8 @@ |
73 | 80 | $dumper->dump( WikiExporter::STABLE, $textMode ); |
74 | 81 | } elseif ( isset( $options['logs'] ) ) { |
75 | 82 | $dumper->dump( WikiExporter::LOGS ); |
| 83 | +} elseif ( isset($options['revrange'] ) ) { |
| 84 | + $dumper->dump( WikiExporter::RANGE, $textMode ); |
76 | 85 | } else { |
77 | 86 | $dumper->progress( <<<ENDS |
78 | 87 | This script dumps the wiki page or logging database into an |
— | — | @@ -87,7 +96,8 @@ |
88 | 97 | --stable Stable versions of pages? |
89 | 98 | --pagelist=<file> |
90 | 99 | 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. |
92 | 102 | Options: |
93 | 103 | --quiet Don't dump status reports to stderr. |
94 | 104 | --report=n Report position and speed after every n pages processed. |
— | — | @@ -95,6 +105,8 @@ |
96 | 106 | --server=h Force reading from MySQL server h |
97 | 107 | --start=n Start from page_id or log_id n |
98 | 108 | --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) |
99 | 111 | --skip-header Don't output the <mediawiki> header |
100 | 112 | --skip-footer Don't output the </mediawiki> footer |
101 | 113 | --stub Don't perform old_text lookups; for 2-pass dump |
Index: trunk/phase3/includes/Export.php |
— | — | @@ -41,6 +41,7 @@ |
42 | 42 | const CURRENT = 2; |
43 | 43 | const STABLE = 4; // extension defined |
44 | 44 | const LOGS = 8; |
| 45 | + const RANGE = 16; |
45 | 46 | |
46 | 47 | const BUFFER = 0; |
47 | 48 | const STREAM = 1; |
— | — | @@ -56,7 +57,8 @@ |
57 | 58 | * main query is still running. |
58 | 59 | * |
59 | 60 | * @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, |
61 | 63 | * or an associative array: |
62 | 64 | * offset: non-inclusive offset at which to start the query |
63 | 65 | * limit: maximum number of rows to return |
— | — | @@ -120,6 +122,21 @@ |
121 | 123 | } |
122 | 124 | |
123 | 125 | /** |
| 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 | + /** |
124 | 141 | * @param $title Title |
125 | 142 | */ |
126 | 143 | public function pageByTitle( $title ) { |
— | — | @@ -259,6 +276,10 @@ |
260 | 277 | wfProfileOut( __METHOD__ ); |
261 | 278 | throw new MWException( __METHOD__ . " given invalid history dump type." ); |
262 | 279 | } |
| 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'; |
263 | 284 | } else { |
264 | 285 | # Uknown history specification parameter? |
265 | 286 | wfProfileOut( __METHOD__ ); |