Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -309,10 +309,11 @@ |
310 | 310 | } |
311 | 311 | if ( $channel === null ) { |
312 | 312 | $this->cleanupChanneled(); |
313 | | - |
314 | | - $f = fopen( 'php://stdout', 'a' ); |
315 | | - fwrite( $f, $out ); |
316 | | - fclose( $f ); |
| 313 | + if( php_sapi_name() == 'cli' ) { |
| 314 | + fwrite( STDOUT, $out ); |
| 315 | + } else { |
| 316 | + print( $out ); |
| 317 | + } |
317 | 318 | } |
318 | 319 | else { |
319 | 320 | $out = preg_replace( '/\n\z/', '', $out ); |
— | — | @@ -331,9 +332,7 @@ |
332 | 333 | if ( php_sapi_name() == 'cli' ) { |
333 | 334 | fwrite( STDERR, $err . "\n" ); |
334 | 335 | } else { |
335 | | - $f = fopen( 'php://stderr', 'a' ); |
336 | | - fwrite( $f, $err . "\n" ); |
337 | | - fclose( $f ); |
| 336 | + print $err; |
338 | 337 | } |
339 | 338 | $die = intval( $die ); |
340 | 339 | if ( $die > 0 ) { |
— | — | @@ -349,9 +348,11 @@ |
350 | 349 | */ |
351 | 350 | public function cleanupChanneled() { |
352 | 351 | if ( !$this->atLineStart ) { |
353 | | - $handle = fopen( 'php://stdout', 'w' ); |
354 | | - fwrite( $handle, "\n" ); |
355 | | - fclose( $handle ); |
| 352 | + if( php_sapi_name() == 'cli' ) { |
| 353 | + fwrite( STDOUT, "\n" ); |
| 354 | + } else { |
| 355 | + print "\n"; |
| 356 | + } |
356 | 357 | $this->atLineStart = true; |
357 | 358 | } |
358 | 359 | } |
— | — | @@ -370,25 +371,34 @@ |
371 | 372 | return; |
372 | 373 | } |
373 | 374 | |
374 | | - $handle = fopen( 'php://stdout', 'a' ); |
| 375 | + $cli = php_sapi_name() == 'cli'; |
375 | 376 | |
376 | 377 | // End the current line if necessary |
377 | 378 | if ( !$this->atLineStart && $channel !== $this->lastChannel ) { |
378 | | - fwrite( $handle, "\n" ); |
| 379 | + if( $cli ) { |
| 380 | + fwrite( STDOUT, "\n" ); |
| 381 | + } else { |
| 382 | + print "\n"; |
| 383 | + } |
379 | 384 | } |
380 | 385 | |
381 | | - fwrite( $handle, $msg ); |
| 386 | + if( $cli ) { |
| 387 | + fwrite( STDOUT, $msg ); |
| 388 | + } else { |
| 389 | + print $msg; |
| 390 | + } |
382 | 391 | |
383 | 392 | $this->atLineStart = false; |
384 | 393 | if ( $channel === null ) { |
385 | 394 | // For unchanneled messages, output trailing newline immediately |
386 | | - fwrite( $handle, "\n" ); |
| 395 | + if( $handle ) { |
| 396 | + fwrite( STDOUT, "\n" ); |
| 397 | + } else { |
| 398 | + print "\n"; |
| 399 | + } |
387 | 400 | $this->atLineStart = true; |
388 | 401 | } |
389 | 402 | $this->lastChannel = $channel; |
390 | | - |
391 | | - // Cleanup handle |
392 | | - fclose( $handle ); |
393 | 403 | } |
394 | 404 | |
395 | 405 | /** |