Go to the documentation of this file.
30 set_exception_handler(
array(
'MWExceptionHandler',
'handle' ) );
36 protected static function report( Exception
$e ) {
37 global $wgShowExceptionDetails;
45 }
catch ( Exception $e2 ) {
49 $message =
"MediaWiki internal error.\n\n";
51 if ( $wgShowExceptionDetails ) {
57 $message .=
"Exception caught inside exception handler.\n\n" .
58 "Set \$wgShowExceptionDetails = true; at the bottom of LocalSettings.php " .
59 "to show detailed debugging information.";
67 echo nl2br( htmlspecialchars( $message ) ) .
"\n";
71 $message =
"Unexpected non-MediaWiki exception encountered, of type \"" .
72 get_class(
$e ) .
"\"";
74 if ( $wgShowExceptionDetails ) {
82 echo nl2br( htmlspecialchars( $message ) ) .
"\n";
94 # NOTE: STDERR may not be available, especially if php-cgi is used from the
95 # command line (bug #15602). Try to produce meaningful output anyway. Using
96 # echo may corrupt output to STDOUT though.
97 if ( defined(
'STDERR' ) ) {
98 fwrite( STDERR, $message );
113 if (
$factory->hasMasterChanges() ) {
115 'Exception thrown with an uncommited database transaction: ' .
117 $e->getTraceAsString()
146 }
catch ( Exception
$e ) {
166 foreach ( self::getRedactedTrace(
$e )
as $level => $frame ) {
167 if ( isset( $frame[
'file'] ) && isset( $frame[
'line'] ) ) {
168 $text .=
"#{$level} {$frame['file']}({$frame['line']}): ";
173 $text .=
"#{$level} [internal function]: ";
176 if ( isset( $frame[
'class'] ) ) {
177 $text .= $frame[
'class'] . $frame[
'type'] . $frame[
'function'];
179 $text .= $frame[
'function'];
182 if ( isset( $frame[
'args'] ) ) {
183 $text .=
'(' . implode(
', ', $frame[
'args'] ) .
")\n";
190 $text .=
"#{$level} {main}";
207 return array_map(
function ( $frame ) {
208 if ( isset( $frame[
'args'] ) ) {
209 $frame[
'args'] = array_map(
function ( $arg ) {
210 return is_object( $arg ) ? get_class( $arg ) : gettype( $arg );
228 if ( !isset(
$e->_mwLogId ) ) {
243 if ( !isset( $wgRequest ) || $wgRequest instanceof
FauxRequest ) {
246 return $wgRequest->getRequestURL();
261 $message =
$e->getMessage();
264 return "[$id] $url Exception from line $line of $file: $message";
319 global $wgLogExceptionBacktrace;
321 $exceptionData =
array(
322 'id' => self::getLogId(
$e ),
323 'file' =>
$e->getFile(),
324 'line' =>
$e->getLine(),
325 'message' =>
$e->getMessage(),
334 if ( $wgLogExceptionBacktrace ) {
352 global $wgLogExceptionBacktrace;
356 if ( $wgLogExceptionBacktrace ) {
357 wfDebugLog(
'exception', $log .
"\n" .
$e->getTraceAsString() );
363 if ( $json !==
false ) {
364 wfDebugLog(
'exception-json', $json,
'private' );
WebRequest clone which takes values from a provided array.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Handler class for MWExceptions.
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
static getLogMessage(Exception $e)
Return the requested URL and point to file and line number from which the exception occurred.
static installHandler()
Install an exception handler for MediaWiki exception types.
static getRedactedTrace(Exception $e)
Return a copy of an exception's backtrace as an array.
static printError( $message)
Print a message, if possible to STDERR.
static isCommandLine()
Check whether we are in command line mode or not to report the exception in the correct format.
static jsonSerializeException(Exception $e, $pretty=false, $escaping=0)
Serialize an Exception object to JSON.
static getRedactedTraceAsString(Exception $e)
Generate a string representation of an exception's stack trace.
static getURL()
If the exception occurred in the course of responding to a request, returns the requested URL.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
static getLogId(Exception $e)
Get the ID for this error.
static report(Exception $e)
Report an exception to the user.
static handle( $e)
Exception handler which simulates the appropriate catch() handling:
if(PHP_SAPI !='cli') $file
& wfGetLBFactory()
Get the load balancer factory object.
static rollbackMasterChangesAndLog(Exception $e)
If there are any open database transactions, roll them back and log the stack trace of the exception ...
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static logException(Exception $e)
Log an exception to the exception log (if enabled).
wfRandomString( $length=32)
Get a random string containing a number of pseudo-random hex characters.