r96616 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96615‎ | r96616 | r96617 >
Date:21:06, 8 September 2011
Author:ariel
Status:ok
Tags:
Comment:
uniform comment style, fix a few space issues, address couple issues from comments on r95272
Modified paths:
  • /trunk/phase3/maintenance/dumpTextPass.php (modified) (history)

Diff [purge]

Index: trunk/phase3/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->getFilename();
 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,16 @@
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->getFilename();
 287+ // we wrote some stuff after last checkpoint that needs renamed
294288 if (file_exists($filenameList[0])) {
295289 $newFilenames = array();
296290 $firstPageID = str_pad($this->firstPageWritten,9,"0",STR_PAD_LEFT);
297291 $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);
 292+ for ( $i = 0; $i < count( $filenameList ); $i++ ) {
 293+ $checkpointNameFilledIn = sprintf( $this->checkpointFiles[$i], $firstPageID, $lastPageID );
300294 $fileinfo = pathinfo($filenameList[$i]);
301 - $newFilenames[] = $fileinfo{'dirname'} . '/' . $checkpointNameFilledIn;
 295+ $newFilenames[] = $fileinfo['dirname'] . '/' . $checkpointNameFilledIn;
302296 }
303297 $this->egress->closeAndRename( $newFilenames );
304298 }
@@ -566,8 +560,8 @@
567561 $this->lastPageWritten = trim($this->thisPage);
568562 if ($this->timeExceeded) {
569563 $this->egress->writeClosePage( $this->buffer );
570 - # nasty hack, we can't just write the chardata after the
571 - # page tag, it will include leading blanks from the next line
 564+ // nasty hack, we can't just write the chardata after the
 565+ // page tag, it will include leading blanks from the next line
572566 $this->egress->sink->write("\n");
573567
574568 $this->buffer = $this->xmlwriterobj->closeStream();
@@ -575,20 +569,16 @@
576570
577571 $this->buffer = "";
578572 $this->thisPage = "";
579 - /* this could be more than one file if we had more than one output arg */
 573+ // this could be more than one file if we had more than one output arg
580574 $checkpointFilenames = array();
581 - $filenameList = $this->egress->getFilename();
582 -
583 - if (! is_array($filenameList)) {
584 - $filenameList = array( $filenameList );
585 - }
 575+ $filenameList = (array)$this->egress->getFilename();
586576 $newFilenames = array();
587577 $firstPageID = str_pad($this->firstPageWritten,9,"0",STR_PAD_LEFT);
588578 $lastPageID = str_pad($this->lastPageWritten,9,"0",STR_PAD_LEFT);
589 - for ($i =0; $i < count($filenameList); $i++) {
590 - $checkpointNameFilledIn = sprintf($this->checkpointFiles[$i], $firstPageID, $lastPageID);
 579+ for ( $i = 0; $i < count( $filenameList ); $i++ ) {
 580+ $checkpointNameFilledIn = sprintf( $this->checkpointFiles[$i], $firstPageID, $lastPageID );
591581 $fileinfo = pathinfo($filenameList[$i]);
592 - $newFilenames[] = $fileinfo{'dirname'} . '/' . $checkpointNameFilledIn;
 582+ $newFilenames[] = $fileinfo['dirname'] . '/' . $checkpointNameFilledIn;
593583 }
594584 $this->egress->closeRenameAndReopen( $newFilenames );
595585 $this->buffer = $this->xmlwriterobj->openStream();
@@ -618,8 +608,8 @@
619609 $this->thisPage .= $data;
620610 }
621611 }
622 - # have to skip the newline left over from closepagetag line of
623 - # end of checkpoint files. nasty hack!!
 612+ // have to skip the newline left over from closepagetag line of
 613+ // end of checkpoint files. nasty hack!!
624614 if ($this->checkpointJustWritten) {
625615 if ($data[0] == "\n") {
626616 $data = substr($data,1);

Sign-offs

UserFlagDate
Hasharinspected16:29, 17 October 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r103041REL1_18 MFT r96616, r97889...reedy21:43, 14 November 2011
r1030431.18wmf1 MFT r103041...reedy21:46, 14 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95272add support for writing out checkpoint files of xml dump at regular intervals...ariel22:45, 22 August 2011

Status & tagging log