r69389 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69388‎ | r69389 | r69390 >
Date:16:27, 15 July 2010
Author:mah
Status:ok
Tags:
Comment:
Add cleanupChanneled() method to clean the channel consistently.
Modified paths:
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/Maintenance.php
@@ -225,8 +225,9 @@
226226 return;
227227 }
228228 if ( $channel === null ) {
 229+ $this->cleanupChanneled();
 230+
229231 $f = fopen( 'php://stdout', 'w' );
230 - if ( $this->lastChannel !== null ) fwrite( $f, "\n" );
231232 fwrite( $f, $out );
232233 fclose( $f );
233234 }
@@ -260,6 +261,18 @@
261262 private $lastChannel = null;
262263
263264 /**
 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+ /**
264277 * Message outputter with channeled message support. Messages on the
265278 * same channel are concatenated, but any intervening messages in another
266279 * channel start a new line.
@@ -268,17 +281,13 @@
269282 * channel. Channel comparison uses ===.
270283 */
271284 public function outputChanneled( $msg, $channel = null ) {
272 - $handle = fopen( 'php://stdout', 'w' );
273 -
274285 if ( $msg === false ) {
275 - // For cleanup
276 - if ( !$this->atLineStart ) {
277 - fwrite( $handle, "\n" );
278 - }
279 - fclose( $handle );
 286+ $this->cleanupChanneled();
280287 return;
281288 }
282289
 290+ $handle = fopen( 'php://stdout', 'w' );
 291+
283292 // End the current line if necessary
284293 if ( !$this->atLineStart && $channel !== $this->lastChannel ) {
285294 fwrite( $handle, "\n" );

Status & tagging log