r41096 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41095‎ | r41096 | r41097 >
Date:09:38, 21 September 2008
Author:tstarling
Status:old
Tags:
Comment:
Log exceptions encountered in api.php. Check for null $wgRequest.
Modified paths:
  • /trunk/phase3/includes/Exception.php (modified) (history)
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiMain.php
@@ -257,6 +257,11 @@
258258 try {
259259 $this->executeAction();
260260 } catch (Exception $e) {
 261+ // Log it
 262+ if ( $e instanceof MWException ) {
 263+ wfDebugLog( 'exception', $e->getLogMessage() );
 264+ }
 265+
261266 //
262267 // Handle any kind of exception by outputing properly formatted error message.
263268 // If this fails, an unhandled exception should be thrown so that global error
Index: trunk/phase3/includes/Exception.php
@@ -129,7 +129,16 @@
130130 $file = $this->getFile();
131131 $line = $this->getLine();
132132 $message = $this->getMessage();
133 - return $wgRequest->getRequestURL() . " Exception from line $line of $file: $message";
 133+ if ( isset( $wgRequest ) ) {
 134+ $url = $wgRequest->getRequestURL();
 135+ if ( !$url ) {
 136+ $url = '[no URL]';
 137+ }
 138+ } else {
 139+ $url = '[no req]';
 140+ }
 141+
 142+ return "$url Exception from line $line of $file: $message";
134143 }
135144
136145 /** Output the exception report using HTML */