Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -225,8 +225,9 @@ |
226 | 226 | return; |
227 | 227 | } |
228 | 228 | if ( $channel === null ) { |
| 229 | + $this->cleanupChanneled(); |
| 230 | + |
229 | 231 | $f = fopen( 'php://stdout', 'w' ); |
230 | | - if ( $this->lastChannel !== null ) fwrite( $f, "\n" ); |
231 | 232 | fwrite( $f, $out ); |
232 | 233 | fclose( $f ); |
233 | 234 | } |
— | — | @@ -260,6 +261,18 @@ |
261 | 262 | private $lastChannel = null; |
262 | 263 | |
263 | 264 | /** |
| 265 | + * Clean up channeled output. Output a newline if necessary. |
| 266 | + */ |
| 267 | + public function cleanupChanneled() { |
| 268 | + if ( !$this->atLineStart ) { |
| 269 | + $handle = fopen( 'php://stdout', 'w' ); |
| 270 | + fwrite( $handle, "\n" ); |
| 271 | + fclose( $handle ); |
| 272 | + $this->atLineStart = true; |
| 273 | + } |
| 274 | + } |
| 275 | + |
| 276 | + /** |
264 | 277 | * Message outputter with channeled message support. Messages on the |
265 | 278 | * same channel are concatenated, but any intervening messages in another |
266 | 279 | * channel start a new line. |
— | — | @@ -268,17 +281,13 @@ |
269 | 282 | * channel. Channel comparison uses ===. |
270 | 283 | */ |
271 | 284 | public function outputChanneled( $msg, $channel = null ) { |
272 | | - $handle = fopen( 'php://stdout', 'w' ); |
273 | | - |
274 | 285 | if ( $msg === false ) { |
275 | | - // For cleanup |
276 | | - if ( !$this->atLineStart ) { |
277 | | - fwrite( $handle, "\n" ); |
278 | | - } |
279 | | - fclose( $handle ); |
| 286 | + $this->cleanupChanneled(); |
280 | 287 | return; |
281 | 288 | } |
282 | 289 | |
| 290 | + $handle = fopen( 'php://stdout', 'w' ); |
| 291 | + |
283 | 292 | // End the current line if necessary |
284 | 293 | if ( !$this->atLineStart && $channel !== $this->lastChannel ) { |
285 | 294 | fwrite( $handle, "\n" ); |