Index: branches/REL1_18/phase3/maintenance/backup.inc |
— | — | @@ -210,6 +210,8 @@ |
211 | 211 | } else if ( is_null( $this->pages ) ) { |
212 | 212 | if ( $this->startId || $this->endId ) { |
213 | 213 | $exporter->pagesByRange( $this->startId, $this->endId ); |
| 214 | + } elseif ( $this->revStartId || $this->revEndId ) { |
| 215 | + $exporter->revsByRange( $this->revStartId, $this->revEndId ); |
214 | 216 | } else { |
215 | 217 | $exporter->allPages(); |
216 | 218 | } |
Index: branches/REL1_18/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: branches/REL1_18/phase3/maintenance/dumpTextPass.php |
— | — | @@ -56,9 +56,9 @@ |
57 | 57 | |
58 | 58 | var $xmlwriterobj = false; |
59 | 59 | |
60 | | - # when we spend more than maxTimeAllowed seconds on this run, we continue |
61 | | - # processing until we write out the next complete page, then save output file(s), |
62 | | - # rename it/them and open new one(s) |
| 60 | + // when we spend more than maxTimeAllowed seconds on this run, we continue |
| 61 | + // processing until we write out the next complete page, then save output file(s), |
| 62 | + // rename it/them and open new one(s) |
63 | 63 | var $maxTimeAllowed = 0; // 0 = no limit |
64 | 64 | var $timeExceeded = false; |
65 | 65 | var $firstPageWritten = false; |
— | — | @@ -72,11 +72,11 @@ |
73 | 73 | } |
74 | 74 | |
75 | 75 | function dump( $history, $text = WikiExporter::TEXT ) { |
76 | | - # This shouldn't happen if on console... ;) |
| 76 | + // This shouldn't happen if on console... ;) |
77 | 77 | header( 'Content-type: text/html; charset=UTF-8' ); |
78 | 78 | |
79 | | - # Notice messages will foul up your XML output even if they're |
80 | | - # relatively harmless. |
| 79 | + // Notice messages will foul up your XML output even if they're |
| 80 | + // relatively harmless. |
81 | 81 | if ( ini_get( 'display_errors' ) ) |
82 | 82 | ini_set( 'display_errors', 'stderr' ); |
83 | 83 | |
— | — | @@ -86,10 +86,10 @@ |
87 | 87 | |
88 | 88 | $this->egress = new ExportProgressFilter( $this->sink, $this ); |
89 | 89 | |
90 | | - # it would be nice to do it in the constructor, oh well. need egress set |
| 90 | + // it would be nice to do it in the constructor, oh well. need egress set |
91 | 91 | $this->finalOptionCheck(); |
92 | 92 | |
93 | | - # we only want this so we know how to close a stream :-P |
| 93 | + // we only want this so we know how to close a stream :-P |
94 | 94 | $this->xmlwriterobj = new XmlDumpWriter(); |
95 | 95 | |
96 | 96 | $input = fopen( $this->input, "rt" ); |
— | — | @@ -234,23 +234,20 @@ |
235 | 235 | } |
236 | 236 | |
237 | 237 | function finalOptionCheck() { |
238 | | - if (($this->checkpointFiles && ! $this->maxTimeAllowed) || |
239 | | - ($this->maxTimeAllowed && !$this->checkpointFiles)) { |
| 238 | + if ( ( $this->checkpointFiles && ! $this->maxTimeAllowed ) || |
| 239 | + ( $this->maxTimeAllowed && !$this->checkpointFiles ) ) { |
240 | 240 | throw new MWException("Options checkpointfile and maxtime must be specified together.\n"); |
241 | 241 | } |
242 | 242 | foreach ($this->checkpointFiles as $checkpointFile) { |
243 | | - $count = substr_count ($checkpointFile,"%s"); |
244 | | - if (substr_count ($checkpointFile,"%s") != 2) { |
| 243 | + $count = substr_count ( $checkpointFile,"%s" ); |
| 244 | + if ( $count != 2 ) { |
245 | 245 | throw new MWException("Option checkpointfile must contain two '%s' for substitution of first and last pageids, count is $count instead, file is $checkpointFile.\n"); |
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | | - if ($this->checkpointFiles) { |
250 | | - $filenameList = $this->egress->getFilename(); |
251 | | - if (! is_array($filenameList)) { |
252 | | - $filenameList = array( $filenameList ); |
253 | | - } |
254 | | - if (count($filenameList) != count($this->checkpointFiles)) { |
| 249 | + if ( $this->checkpointFiles ) { |
| 250 | + $filenameList = (array)$this->egress->getFilenames(); |
| 251 | + if ( count( $filenameList ) != count( $this->checkpointFiles ) ) { |
255 | 252 | throw new MWException("One checkpointfile must be specified for each output option, if maxtime is used.\n"); |
256 | 253 | } |
257 | 254 | } |
— | — | @@ -285,19 +282,27 @@ |
286 | 283 | $offset += strlen( $chunk ); |
287 | 284 | } while ( $chunk !== false && !feof( $input ) ); |
288 | 285 | if ($this->maxTimeAllowed) { |
289 | | - $filenameList = $this->egress->getFilename(); |
290 | | - # we wrote some stuff after last checkpoint that needs renamed */ |
291 | | - if (! is_array($filenameList)) { |
292 | | - $filenameList = array( $filenameList ); |
293 | | - } |
| 286 | + $filenameList = (array)$this->egress->getFilenames(); |
| 287 | + // we wrote some stuff after last checkpoint that needs renamed |
294 | 288 | if (file_exists($filenameList[0])) { |
295 | 289 | $newFilenames = array(); |
296 | | - $firstPageID = str_pad($this->firstPageWritten,9,"0",STR_PAD_LEFT); |
297 | | - $lastPageID = str_pad($this->lastPageWritten,9,"0",STR_PAD_LEFT); |
298 | | - for ($i =0; $i < count($filenameList); $i++) { |
299 | | - $checkpointNameFilledIn = sprintf($this->checkpointFiles[$i], $firstPageID, $lastPageID); |
| 290 | + # we might have just written the header and footer and had no |
| 291 | + # pages or revisions written... perhaps they were all deleted |
| 292 | + # there's no pageID 0 so we use that. the caller is responsible |
| 293 | + # for deciding what to do with a file containing only the |
| 294 | + # siteinfo information and the mw tags. |
| 295 | + if (! $this->firstPageWritten) { |
| 296 | + $firstPageID = str_pad(0,9,"0",STR_PAD_LEFT); |
| 297 | + $lastPageID = str_pad(0,9,"0",STR_PAD_LEFT); |
| 298 | + } |
| 299 | + else { |
| 300 | + $firstPageID = str_pad($this->firstPageWritten,9,"0",STR_PAD_LEFT); |
| 301 | + $lastPageID = str_pad($this->lastPageWritten,9,"0",STR_PAD_LEFT); |
| 302 | + } |
| 303 | + for ( $i = 0; $i < count( $filenameList ); $i++ ) { |
| 304 | + $checkpointNameFilledIn = sprintf( $this->checkpointFiles[$i], $firstPageID, $lastPageID ); |
300 | 305 | $fileinfo = pathinfo($filenameList[$i]); |
301 | | - $newFilenames[] = $fileinfo{'dirname'} . '/' . $checkpointNameFilledIn; |
| 306 | + $newFilenames[] = $fileinfo['dirname'] . '/' . $checkpointNameFilledIn; |
302 | 307 | } |
303 | 308 | $this->egress->closeAndRename( $newFilenames ); |
304 | 309 | } |
— | — | @@ -577,8 +582,8 @@ |
578 | 583 | $this->lastPageWritten = trim($this->thisPage); |
579 | 584 | if ($this->timeExceeded) { |
580 | 585 | $this->egress->writeClosePage( $this->buffer ); |
581 | | - # nasty hack, we can't just write the chardata after the |
582 | | - # page tag, it will include leading blanks from the next line |
| 586 | + // nasty hack, we can't just write the chardata after the |
| 587 | + // page tag, it will include leading blanks from the next line |
583 | 588 | $this->egress->sink->write("\n"); |
584 | 589 | |
585 | 590 | $this->buffer = $this->xmlwriterobj->closeStream(); |
— | — | @@ -586,20 +591,16 @@ |
587 | 592 | |
588 | 593 | $this->buffer = ""; |
589 | 594 | $this->thisPage = ""; |
590 | | - /* this could be more than one file if we had more than one output arg */ |
| 595 | + // this could be more than one file if we had more than one output arg |
591 | 596 | $checkpointFilenames = array(); |
592 | | - $filenameList = $this->egress->getFilename(); |
593 | | - |
594 | | - if (! is_array($filenameList)) { |
595 | | - $filenameList = array( $filenameList ); |
596 | | - } |
| 597 | + $filenameList = (array)$this->egress->getFilenames(); |
597 | 598 | $newFilenames = array(); |
598 | 599 | $firstPageID = str_pad($this->firstPageWritten,9,"0",STR_PAD_LEFT); |
599 | 600 | $lastPageID = str_pad($this->lastPageWritten,9,"0",STR_PAD_LEFT); |
600 | | - for ($i =0; $i < count($filenameList); $i++) { |
601 | | - $checkpointNameFilledIn = sprintf($this->checkpointFiles[$i], $firstPageID, $lastPageID); |
| 601 | + for ( $i = 0; $i < count( $filenameList ); $i++ ) { |
| 602 | + $checkpointNameFilledIn = sprintf( $this->checkpointFiles[$i], $firstPageID, $lastPageID ); |
602 | 603 | $fileinfo = pathinfo($filenameList[$i]); |
603 | | - $newFilenames[] = $fileinfo{'dirname'} . '/' . $checkpointNameFilledIn; |
| 604 | + $newFilenames[] = $fileinfo['dirname'] . '/' . $checkpointNameFilledIn; |
604 | 605 | } |
605 | 606 | $this->egress->closeRenameAndReopen( $newFilenames ); |
606 | 607 | $this->buffer = $this->xmlwriterobj->openStream(); |
— | — | @@ -629,8 +630,8 @@ |
630 | 631 | $this->thisPage .= $data; |
631 | 632 | } |
632 | 633 | } |
633 | | - # have to skip the newline left over from closepagetag line of |
634 | | - # end of checkpoint files. nasty hack!! |
| 634 | + // have to skip the newline left over from closepagetag line of |
| 635 | + // end of checkpoint files. nasty hack!! |
635 | 636 | if ($this->checkpointJustWritten) { |
636 | 637 | if ($data[0] == "\n") { |
637 | 638 | $data = substr($data,1); |
Property changes on: branches/REL1_18/phase3/includes |
___________________________________________________________________ |
Modified: svn:mergeinfo |
638 | 639 | Merged /trunk/phase3/includes:r101591 |
Property changes on: branches/REL1_18/phase3 |
___________________________________________________________________ |
Modified: svn:mergeinfo |
639 | 640 | Merged /trunk/phase3:r96616,96648,97889,101591 |