r97889 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97888‎ | r97889 | r97890 >
Date:06:15, 23 September 2011
Author:ariel
Status:ok (Comments)
Tags:
Comment:
handle naming checkpoint file with first/last pageID when the file is empty
Modified paths:
  • /trunk/phase3/maintenance/dumpTextPass.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/dumpTextPass.php
@@ -286,8 +286,19 @@
287287 // we wrote some stuff after last checkpoint that needs renamed
288288 if (file_exists($filenameList[0])) {
289289 $newFilenames = array();
290 - $firstPageID = str_pad($this->firstPageWritten,9,"0",STR_PAD_LEFT);
291 - $lastPageID = str_pad($this->lastPageWritten,9,"0",STR_PAD_LEFT);
 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+ }
292303 for ( $i = 0; $i < count( $filenameList ); $i++ ) {
293304 $checkpointNameFilledIn = sprintf( $this->checkpointFiles[$i], $firstPageID, $lastPageID );
294305 $fileinfo = pathinfo($filenameList[$i]);

Follow-up revisions

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

Comments

#Comment by Brion VIBBER (talk | contribs)   17:46, 23 September 2011

I think this'd be the same as just doing a sprintf("%09d", $this->firstPageWritten) but it doesn't hurt to be explicit in the check against false, rather than implicitly coercing the false to 0.

Status & tagging log