Don't fall into an infinite loop o' death if the pipes get broken.
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 19 May 2008 15:49:05 +0000 (15:49 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 19 May 2008 15:49:05 +0000 (15:49 +0000)
Exit out if we can't read from stdin anymore, instead of interpreting the 'false' error code as text ID 0...

maintenance/fetchText.php

index 3b745c0..6492fad 100644 (file)
@@ -10,6 +10,10 @@ $db = wfGetDB( DB_SLAVE );
 $stdin = fopen( "php://stdin", "rt" );
 while( !feof( $stdin ) ) {
        $line = fgets( $stdin );
+       if( $line === false ) {
+               // We appear to have lost contact...
+               break;
+       }
        $textId = intval( $line );
        $text = doGetText( $db, $textId );
        echo strlen( $text ) . "\n";
@@ -31,6 +35,3 @@ function doGetText( $db, $id ) {
        }
        return $text;
 }
-
-
-?>
\ No newline at end of file