r90993 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90992‎ | r90993 | r90994 >
Date:19:46, 28 June 2011
Author:demon
Status:ok
Tags:
Comment:
* Remove Exception.php's reliance on wfDie(), as well as the awful constant MEDIAWIKI_INSTALL (holdover from old installer)
* Rm checking for MEDIAWIKI_INSTALL in wfOut(), no codepath leads here from the installer anymore
Modified paths:
  • /trunk/phase3/includes/Exception.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Exception.php
@@ -187,12 +187,8 @@
188188 die( $hookResult );
189189 }
190190
191 - $html = $this->getHTML();
192 - if ( defined( 'MEDIAWIKI_INSTALL' ) ) {
193 - echo $html;
194 - } else {
195 - wfDie( $html );
196 - }
 191+ echo $this->getHTML();
 192+ die(1);
197193 }
198194 }
199195
@@ -215,7 +211,7 @@
216212 }
217213
218214 static function isCommandLine() {
219 - return !empty( $GLOBALS['wgCommandLineMode'] ) && !defined( 'MEDIAWIKI_INSTALL' );
 215+ return !empty( $GLOBALS['wgCommandLineMode'] );
220216 }
221217 }
222218
@@ -431,7 +427,7 @@
432428 if ( $cmdLine ) {
433429 self::printError( $message );
434430 } else {
435 - wfDie( nl2br( htmlspecialchars( $message ) ) ) . "\n";
 431+ self::escapeEchoAndDie( $message );
436432 }
437433 }
438434 } else {
@@ -445,7 +441,7 @@
446442 if ( $cmdLine ) {
447443 self::printError( $message );
448444 } else {
449 - wfDie( nl2br( htmlspecialchars( $message ) ) ) . "\n";
 445+ self::escapeEchoAndDie( $message );
450446 }
451447 }
452448 }
@@ -453,6 +449,7 @@
454450 /**
455451 * Print a message, if possible to STDERR.
456452 * Use this in command line mode only (see isCommandLine)
 453+ * @param $message String Failure text
457454 */
458455 public static function printError( $message ) {
459456 # NOTE: STDERR may not be available, especially if php-cgi is used from the command line (bug #15602).
@@ -465,6 +462,16 @@
466463 }
467464
468465 /**
 466+ * Print a message after escaping it and converting newlines to <br>
 467+ * Use this for non-command line failures
 468+ * @param $message String Failure text
 469+ */
 470+ private static function escapeEchoAndDie( $message ) {
 471+ echo nl2br( htmlspecialchars( $message ) ) . "\n";
 472+ die(1);
 473+ }
 474+
 475+ /**
469476 * Exception handler which simulates the appropriate catch() handling:
470477 *
471478 * try {
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -3350,7 +3350,7 @@
33513351 function wfOut( $s ) {
33523352 wfDeprecated( __METHOD__ );
33533353 global $wgCommandLineMode;
3354 - if ( $wgCommandLineMode && !defined( 'MEDIAWIKI_INSTALL' ) ) {
 3354+ if ( $wgCommandLineMode ) {
33553355 echo $s;
33563356 } else {
33573357 echo htmlspecialchars( $s );

Follow-up revisions

RevisionCommit summaryAuthorDate
r94041Readd basic headers and <html>...</html> arround error contents that was remo...ialex12:28, 7 August 2011

Status & tagging log