r103043 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103042‎ | r103043 | r103044 >
Date:21:46, 14 November 2011
Author:reedy
Status:ok
Tags:
Comment:
1.18wmf1 MFT r103041

Makes MFT r96616, r97889

Partial merge (non Export.php) of r96648, r101591
Modified paths:
  • /branches/wmf/1.18wmf1 (modified) (history)
  • /branches/wmf/1.18wmf1/includes (modified) (history)
  • /branches/wmf/1.18wmf1/maintenance/backup.inc (modified) (history)
  • /branches/wmf/1.18wmf1/maintenance/dumpBackup.php (modified) (history)
  • /branches/wmf/1.18wmf1/maintenance/dumpTextPass.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/maintenance/backup.inc
@@ -210,6 +210,8 @@
211211 } else if ( is_null( $this->pages ) ) {
212212 if ( $this->startId || $this->endId ) {
213213 $exporter->pagesByRange( $this->startId, $this->endId );
 214+ } elseif ( $this->revStartId || $this->revEndId ) {
 215+ $exporter->revsByRange( $this->revStartId, $this->revEndId );
214216 } else {
215217 $exporter->allPages();
216218 }
Index: branches/wmf/1.18wmf1/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: branches/wmf/1.18wmf1/maintenance/dumpTextPass.php
@@ -56,9 +56,9 @@
5757
5858 var $xmlwriterobj = false;
5959
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)
6363 var $maxTimeAllowed = 0; // 0 = no limit
6464 var $timeExceeded = false;
6565 var $firstPageWritten = false;
@@ -72,11 +72,11 @@
7373 }
7474
7575 function dump( $history, $text = WikiExporter::TEXT ) {
76 - # This shouldn't happen if on console... ;)
 76+ // This shouldn't happen if on console... ;)
7777 header( 'Content-type: text/html; charset=UTF-8' );
7878
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.
8181 if ( ini_get( 'display_errors' ) )
8282 ini_set( 'display_errors', 'stderr' );
8383
@@ -86,10 +86,10 @@
8787
8888 $this->egress = new ExportProgressFilter( $this->sink, $this );
8989
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
9191 $this->finalOptionCheck();
9292
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
9494 $this->xmlwriterobj = new XmlDumpWriter();
9595
9696 $input = fopen( $this->input, "rt" );
@@ -234,23 +234,20 @@
235235 }
236236
237237 function finalOptionCheck() {
238 - if (($this->checkpointFiles && ! $this->maxTimeAllowed) ||
239 - ($this->maxTimeAllowed && !$this->checkpointFiles)) {
 238+ if ( ( $this->checkpointFiles && ! $this->maxTimeAllowed ) ||
 239+ ( $this->maxTimeAllowed && !$this->checkpointFiles ) ) {
240240 throw new MWException("Options checkpointfile and maxtime must be specified together.\n");
241241 }
242242 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 ) {
245245 throw new MWException("Option checkpointfile must contain two '%s' for substitution of first and last pageids, count is $count instead, file is $checkpointFile.\n");
246246 }
247247 }
248248
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 ) ) {
255252 throw new MWException("One checkpointfile must be specified for each output option, if maxtime is used.\n");
256253 }
257254 }
@@ -285,19 +282,27 @@
286283 $offset += strlen( $chunk );
287284 } while ( $chunk !== false && !feof( $input ) );
288285 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
294288 if (file_exists($filenameList[0])) {
295289 $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 );
300305 $fileinfo = pathinfo($filenameList[$i]);
301 - $newFilenames[] = $fileinfo{'dirname'} . '/' . $checkpointNameFilledIn;
 306+ $newFilenames[] = $fileinfo['dirname'] . '/' . $checkpointNameFilledIn;
302307 }
303308 $this->egress->closeAndRename( $newFilenames );
304309 }
@@ -577,8 +582,8 @@
578583 $this->lastPageWritten = trim($this->thisPage);
579584 if ($this->timeExceeded) {
580585 $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
583588 $this->egress->sink->write("\n");
584589
585590 $this->buffer = $this->xmlwriterobj->closeStream();
@@ -586,20 +591,16 @@
587592
588593 $this->buffer = "";
589594 $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
591596 $checkpointFilenames = array();
592 - $filenameList = $this->egress->getFilename();
593 -
594 - if (! is_array($filenameList)) {
595 - $filenameList = array( $filenameList );
596 - }
 597+ $filenameList = (array)$this->egress->getFilenames();
597598 $newFilenames = array();
598599 $firstPageID = str_pad($this->firstPageWritten,9,"0",STR_PAD_LEFT);
599600 $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 );
602603 $fileinfo = pathinfo($filenameList[$i]);
603 - $newFilenames[] = $fileinfo{'dirname'} . '/' . $checkpointNameFilledIn;
 604+ $newFilenames[] = $fileinfo['dirname'] . '/' . $checkpointNameFilledIn;
604605 }
605606 $this->egress->closeRenameAndReopen( $newFilenames );
606607 $this->buffer = $this->xmlwriterobj->openStream();
@@ -629,8 +630,8 @@
630631 $this->thisPage .= $data;
631632 }
632633 }
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!!
635636 if ($this->checkpointJustWritten) {
636637 if ($data[0] == "\n") {
637638 $data = substr($data,1);
Property changes on: branches/wmf/1.18wmf1/includes
___________________________________________________________________
Modified: svn:mergeinfo
638639 Merged /branches/REL1_18/phase3/includes:r103041
639640 Merged /trunk/phase3/includes:r101591
Property changes on: branches/wmf/1.18wmf1
___________________________________________________________________
Modified: svn:mergeinfo
640641 Merged /branches/REL1_18/phase3:r103041
641642 Merged /trunk/phase3:r96616,96648,97889,101591

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96616uniform comment style, fix a few space issues, address couple issues from com...ariel21:06, 8 September 2011
r96648getFilename renamed to getFilenames since it can return a listariel07:28, 9 September 2011
r97889handle naming checkpoint file with first/last pageID when the file is emptyariel06:15, 23 September 2011
r101591export specified range of revisions (as stubs)ariel07:58, 2 November 2011
r103041REL1_18 MFT r96616, r97889...reedy21:43, 14 November 2011

Status & tagging log