From: Brion Vibber Date: Mon, 19 May 2008 15:49:05 +0000 (+0000) Subject: Don't fall into an infinite loop o' death if the pipes get broken. X-Git-Tag: 1.31.0-rc.0~47542 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=69dd51f03b5b1022db9f1de0642130fc925cc85a;p=lhc%2Fweb%2Fwiklou.git Don't fall into an infinite loop o' death if the pipes get broken. Exit out if we can't read from stdin anymore, instead of interpreting the 'false' error code as text ID 0... --- diff --git a/maintenance/fetchText.php b/maintenance/fetchText.php index 3b745c0ac1..6492fad0e9 100644 --- a/maintenance/fetchText.php +++ b/maintenance/fetchText.php @@ -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