X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOrderedStreamingForkController.php;h=5424b13285665203c675cb27712e3315186a9614;hb=39835a1c6f27b425fe57f76ef7d98ee4e65dbbe6;hp=11abc81c1ff7049958a9eb6c20286f4a81a6df06;hpb=d3ed3b8409021271d05189fc0b55cc63d0fe2e85;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OrderedStreamingForkController.php b/includes/OrderedStreamingForkController.php index 11abc81c1f..5424b13285 100644 --- a/includes/OrderedStreamingForkController.php +++ b/includes/OrderedStreamingForkController.php @@ -135,13 +135,16 @@ class OrderedStreamingForkController extends ForkController { protected function consumeNoFork() { while ( !feof( $this->input ) ) { $data = fgets( $this->input ); - if ( $data[ strlen( $data ) - 1 ] == "\n" ) { + if ( substr( $data, -1 ) === "\n" ) { + // Strip any final new line used to delimit lines of input. + // The last line of input might not have it, though. $data = substr( $data, 0, -1 ); } - if ( strlen( $data ) !== 0 ) { - $result = call_user_func( $this->workCallback, $data ); - fwrite( $this->output, "$result\n" ); + if ( $data === '' ) { + continue; } + $result = call_user_func( $this->workCallback, $data ); + fwrite( $this->output, "$result\n" ); } } @@ -163,12 +166,12 @@ class OrderedStreamingForkController extends ForkController { $this->updateAvailableSockets( $sockets, $used, $sockets ? 0 : 5 ); } while ( !$sockets ); } - // Strip the trailing \n. The last line of a file might not have a trailing - // \n though - if ( $data[ strlen( $data ) - 1 ] == "\n" ) { + if ( substr( $data, - 1 ) === "\n" ) { + // Strip any final new line used to delimit lines of input. + // The last line of input might not have it, though. $data = substr( $data, 0, -1 ); } - if ( strlen( $data ) === 0 ) { + if ( $data === '' ) { continue; } $socket = array_pop( $sockets );