r67322 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67321‎ | r67322 | r67323 >
Date:02:24, 4 June 2010
Author:ariel
Status:resolved (Comments)
Tags:
Comment:
XML snapshots: when retrieving revision text, send the text id back to requester for doublechecking (avoids revision text out of sync errors), partial fix for bugs 23264, 18694
Modified paths:
  • /trunk/phase3/maintenance/dumpTextPass.php (modified) (history)
  • /trunk/phase3/maintenance/fetchText.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/fetchText.php
@@ -39,7 +39,7 @@
4040 }
4141 $textId = intval( $line );
4242 $text = $this->doGetText( $db, $textId );
43 - $this->output( strlen( $text ) . "\n" . $text );
 43+ $this->output( $textId . "\n" . strlen( $text ) . "\n" . $text );
4444 }
4545 }
4646
Index: trunk/phase3/maintenance/dumpTextPass.php
@@ -331,7 +331,17 @@
332332 $ok = fflush( $this->spawnWrite );
333333 // $this->progress( ">> [flush]" );
334334 if ( !$ok ) return false;
335 -
 335+
 336+ // check that the text id they are sending is the one we asked for
 337+ // this avoids out of sync revision text errors we have encountered in the past
 338+ $newId = fgets( $this->spawnRead );
 339+ if ( $newId === false ) {
 340+ return false;
 341+ }
 342+ if ( $id != intval( $newId ) ) {
 343+ return false;
 344+ }
 345+
336346 $len = fgets( $this->spawnRead );
337347 // $this->progress( "<< " . trim( $len ) );
338348 if ( $len === false ) return false;

Comments

#Comment by MarkAHershberger (talk | contribs)   19:50, 15 July 2010

if ( $id != intval( $newId ) ) {

I prefer type-sensitive comparisons like:if ( intval( $id ) !== intval( $newId ) ) {

#Comment by MarkAHershberger (talk | contribs)   19:51, 15 July 2010

if ( $id != intval( $newId ) ) {

I prefer type-sensitive comparisons like:if ( intval( $id ) !== intval( $newId ) ) {

#Comment by MarkAHershberger (talk | contribs)   19:58, 15 July 2010

you could remove the additional intval() in

intval( $id )

if you set $id to its intval() up in doGetText() rather than having to intval() it twice in each of the getText{DbSafe,Spawned}.

#Comment by ArielGlenn (talk | contribs)   21:35, 15 July 2010

See revision 69408.

Status & tagging log