Disable $wgContentHandlerUseDB during upgrade where fields don't exist.
[lhc/web/wiklou.git] / includes / Exception.php
1 <?php
2 /**
3 * Exception class and handler.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 /**
24 * @defgroup Exception Exception
25 */
26
27 /**
28 * MediaWiki exception
29 *
30 * @ingroup Exception
31 */
32 class MWException extends Exception {
33 /**
34 * Should the exception use $wgOut to output the error?
35 *
36 * @return bool
37 */
38 function useOutputPage() {
39 return $this->useMessageCache() &&
40 !empty( $GLOBALS['wgFullyInitialised'] ) &&
41 !empty( $GLOBALS['wgOut'] ) &&
42 !empty( $GLOBALS['wgTitle'] );
43 }
44
45 /**
46 * Whether to log this exception in the exception debug log.
47 *
48 * @since 1.23
49 * @return boolean
50 */
51 function isLoggable() {
52 return true;
53 }
54
55 /**
56 * Can the extension use the Message class/wfMessage to get i18n-ed messages?
57 *
58 * @return bool
59 */
60 function useMessageCache() {
61 global $wgLang;
62
63 foreach ( $this->getTrace() as $frame ) {
64 if ( isset( $frame['class'] ) && $frame['class'] === 'LocalisationCache' ) {
65 return false;
66 }
67 }
68
69 return $wgLang instanceof Language;
70 }
71
72 /**
73 * Run hook to allow extensions to modify the text of the exception
74 *
75 * @param string $name class name of the exception
76 * @param array $args arguments to pass to the callback functions
77 * @return string|null string to output or null if any hook has been called
78 */
79 function runHooks( $name, $args = array() ) {
80 global $wgExceptionHooks;
81
82 if ( !isset( $wgExceptionHooks ) || !is_array( $wgExceptionHooks ) ) {
83 return null; // Just silently ignore
84 }
85
86 if ( !array_key_exists( $name, $wgExceptionHooks ) ||
87 !is_array( $wgExceptionHooks[$name] )
88 ) {
89 return null;
90 }
91
92 $hooks = $wgExceptionHooks[$name];
93 $callargs = array_merge( array( $this ), $args );
94
95 foreach ( $hooks as $hook ) {
96 if (
97 is_string( $hook ) ||
98 ( is_array( $hook ) && count( $hook ) >= 2 && is_string( $hook[0] ) )
99 ) {
100 // 'function' or array( 'class', hook' )
101 $result = call_user_func_array( $hook, $callargs );
102 } else {
103 $result = null;
104 }
105
106 if ( is_string( $result ) ) {
107 return $result;
108 }
109 }
110 return null;
111 }
112
113 /**
114 * Get a message from i18n
115 *
116 * @param string $key message name
117 * @param string $fallback default message if the message cache can't be
118 * called by the exception
119 * The function also has other parameters that are arguments for the message
120 * @return string message with arguments replaced
121 */
122 function msg( $key, $fallback /*[, params...] */ ) {
123 $args = array_slice( func_get_args(), 2 );
124
125 if ( $this->useMessageCache() ) {
126 return wfMessage( $key, $args )->plain();
127 } else {
128 return wfMsgReplaceArgs( $fallback, $args );
129 }
130 }
131
132 /**
133 * If $wgShowExceptionDetails is true, return a HTML message with a
134 * backtrace to the error, otherwise show a message to ask to set it to true
135 * to show that information.
136 *
137 * @return string html to output
138 */
139 function getHTML() {
140 global $wgShowExceptionDetails;
141
142 if ( $wgShowExceptionDetails ) {
143 return '<p>' . nl2br( htmlspecialchars( $this->getMessage() ) ) .
144 '</p><p>Backtrace:</p><p>' .
145 nl2br( htmlspecialchars( MWExceptionHandler::formatRedactedTrace( $this ) ) ) .
146 "</p>\n";
147 } else {
148 return "<div class=\"errorbox\">" .
149 '[' . MWExceptionHandler::getLogId( $this ) . '] ' .
150 gmdate( 'Y-m-d H:i:s' ) .
151 ": Fatal exception of type " . get_class( $this ) . "</div>\n" .
152 "<!-- Set \$wgShowExceptionDetails = true; " .
153 "at the bottom of LocalSettings.php to show detailed " .
154 "debugging information. -->";
155 }
156 }
157
158 /**
159 * Get the text to display when reporting the error on the command line.
160 * If $wgShowExceptionDetails is true, return a text message with a
161 * backtrace to the error.
162 *
163 * @return string
164 */
165 function getText() {
166 global $wgShowExceptionDetails;
167
168 if ( $wgShowExceptionDetails ) {
169 return $this->getMessage() .
170 "\nBacktrace:\n" . MWExceptionHandler::formatRedactedTrace( $this ) . "\n";
171 } else {
172 return "Set \$wgShowExceptionDetails = true; " .
173 "in LocalSettings.php to show detailed debugging information.\n";
174 }
175 }
176
177 /**
178 * Return the title of the page when reporting this error in a HTTP response.
179 *
180 * @return string
181 */
182 function getPageTitle() {
183 global $wgSitename;
184 return $this->msg( 'pagetitle', "$1 - $wgSitename", $this->msg( 'internalerror', 'Internal error' ) );
185 }
186
187 /**
188 * Get a the ID for this error.
189 *
190 * @since 1.20
191 * @deprecated since 1.22 Use MWExceptionHandler::getLogId instead.
192 * @return string
193 */
194 function getLogId() {
195 wfDeprecated( __METHOD__, '1.22' );
196 return MWExceptionHandler::getLogId( $this );
197 }
198
199 /**
200 * Return the requested URL and point to file and line number from which the
201 * exception occurred
202 *
203 * @since 1.8
204 * @deprecated since 1.22 Use MWExceptionHandler::getLogMessage instead.
205 * @return string
206 */
207 function getLogMessage() {
208 wfDeprecated( __METHOD__, '1.22' );
209 return MWExceptionHandler::getLogMessage( $this );
210 }
211
212 /**
213 * Output the exception report using HTML.
214 */
215 function reportHTML() {
216 global $wgOut;
217 if ( $this->useOutputPage() ) {
218 $wgOut->prepareErrorPage( $this->getPageTitle() );
219
220 $hookResult = $this->runHooks( get_class( $this ) );
221 if ( $hookResult ) {
222 $wgOut->addHTML( $hookResult );
223 } else {
224 $wgOut->addHTML( $this->getHTML() );
225 }
226
227 $wgOut->output();
228 } else {
229 header( 'Content-Type: text/html; charset=utf-8' );
230 echo "<!DOCTYPE html>\n" .
231 '<html><head>' .
232 '<title>' . htmlspecialchars( $this->getPageTitle() ) . '</title>' .
233 '<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
234 "</head><body>\n";
235
236 $hookResult = $this->runHooks( get_class( $this ) . 'Raw' );
237 if ( $hookResult ) {
238 echo $hookResult;
239 } else {
240 echo $this->getHTML();
241 }
242
243 echo "</body></html>\n";
244 }
245 }
246
247 /**
248 * Output a report about the exception and takes care of formatting.
249 * It will be either HTML or plain text based on isCommandLine().
250 */
251 function report() {
252 global $wgMimeType;
253
254 MWExceptionHandler::logException( $this );
255
256 if ( defined( 'MW_API' ) ) {
257 // Unhandled API exception, we can't be sure that format printer is alive
258 header( 'MediaWiki-API-Error: internal_api_error_' . get_class( $this ) );
259 wfHttpError( 500, 'Internal Server Error', $this->getText() );
260 } elseif ( self::isCommandLine() ) {
261 MWExceptionHandler::printError( $this->getText() );
262 } else {
263 header( 'HTTP/1.1 500 MediaWiki exception' );
264 header( 'Status: 500 MediaWiki exception', true );
265 header( "Content-Type: $wgMimeType; charset=utf-8", true );
266
267 $this->reportHTML();
268 }
269 }
270
271 /**
272 * Check whether we are in command line mode or not to report the exception
273 * in the correct format.
274 *
275 * @return bool
276 */
277 static function isCommandLine() {
278 return !empty( $GLOBALS['wgCommandLineMode'] );
279 }
280 }
281
282 /**
283 * Exception class which takes an HTML error message, and does not
284 * produce a backtrace. Replacement for OutputPage::fatalError().
285 *
286 * @since 1.7
287 * @ingroup Exception
288 */
289 class FatalError extends MWException {
290
291 /**
292 * @return string
293 */
294 function getHTML() {
295 return $this->getMessage();
296 }
297
298 /**
299 * @return string
300 */
301 function getText() {
302 return $this->getMessage();
303 }
304 }
305
306 /**
307 * An error page which can definitely be safely rendered using the OutputPage.
308 *
309 * @since 1.7
310 * @ingroup Exception
311 */
312 class ErrorPageError extends MWException {
313 public $title, $msg, $params;
314
315 /**
316 * Note: these arguments are keys into wfMessage(), not text!
317 *
318 * @param string|Message $title Message key (string) for page title, or a Message object
319 * @param string|Message $msg Message key (string) for error text, or a Message object
320 * @param array $params with parameters to wfMessage()
321 */
322 function __construct( $title, $msg, $params = null ) {
323 $this->title = $title;
324 $this->msg = $msg;
325 $this->params = $params;
326
327 // Bug 44111: Messages in the log files should be in English and not
328 // customized by the local wiki. So get the default English version for
329 // passing to the parent constructor. Our overridden report() below
330 // makes sure that the page shown to the user is not forced to English.
331 if ( $msg instanceof Message ) {
332 $enMsg = clone( $msg );
333 } else {
334 $enMsg = wfMessage( $msg, $params );
335 }
336 $enMsg->inLanguage( 'en' )->useDatabase( false );
337 parent::__construct( $enMsg->text() );
338 }
339
340 function report() {
341 global $wgOut;
342
343 $wgOut->showErrorPage( $this->title, $this->msg, $this->params );
344 $wgOut->output();
345 }
346 }
347
348 /**
349 * Show an error page on a badtitle.
350 * Similar to ErrorPage, but emit a 400 HTTP error code to let mobile
351 * browser it is not really a valid content.
352 *
353 * @since 1.19
354 * @ingroup Exception
355 */
356 class BadTitleError extends ErrorPageError {
357 /**
358 * @param string|Message $msg A message key (default: 'badtitletext')
359 * @param array $params parameter to wfMessage()
360 */
361 function __construct( $msg = 'badtitletext', $params = null ) {
362 parent::__construct( 'badtitle', $msg, $params );
363 }
364
365 /**
366 * Just like ErrorPageError::report() but additionally set
367 * a 400 HTTP status code (bug 33646).
368 */
369 function report() {
370 global $wgOut;
371
372 // bug 33646: a badtitle error page need to return an error code
373 // to let mobile browser now that it is not a normal page.
374 $wgOut->setStatusCode( 400 );
375 parent::report();
376 }
377
378 }
379
380 /**
381 * Show an error when a user tries to do something they do not have the necessary
382 * permissions for.
383 *
384 * @since 1.18
385 * @ingroup Exception
386 */
387 class PermissionsError extends ErrorPageError {
388 public $permission, $errors;
389
390 function __construct( $permission, $errors = array() ) {
391 global $wgLang;
392
393 $this->permission = $permission;
394
395 if ( !count( $errors ) ) {
396 $groups = array_map(
397 array( 'User', 'makeGroupLinkWiki' ),
398 User::getGroupsWithPermission( $this->permission )
399 );
400
401 if ( $groups ) {
402 $errors[] = array( 'badaccess-groups', $wgLang->commaList( $groups ), count( $groups ) );
403 } else {
404 $errors[] = array( 'badaccess-group0' );
405 }
406 }
407
408 $this->errors = $errors;
409 }
410
411 function report() {
412 global $wgOut;
413
414 $wgOut->showPermissionsErrorPage( $this->errors, $this->permission );
415 $wgOut->output();
416 }
417 }
418
419 /**
420 * Show an error when the wiki is locked/read-only and the user tries to do
421 * something that requires write access.
422 *
423 * @since 1.18
424 * @ingroup Exception
425 */
426 class ReadOnlyError extends ErrorPageError {
427 public function __construct() {
428 parent::__construct(
429 'readonly',
430 'readonlytext',
431 wfReadOnlyReason()
432 );
433 }
434 }
435
436 /**
437 * Show an error when the user hits a rate limit.
438 *
439 * @since 1.18
440 * @ingroup Exception
441 */
442 class ThrottledError extends ErrorPageError {
443 public function __construct() {
444 parent::__construct(
445 'actionthrottled',
446 'actionthrottledtext'
447 );
448 }
449
450 public function report() {
451 global $wgOut;
452 $wgOut->setStatusCode( 503 );
453 parent::report();
454 }
455 }
456
457 /**
458 * Show an error when the user tries to do something whilst blocked.
459 *
460 * @since 1.18
461 * @ingroup Exception
462 */
463 class UserBlockedError extends ErrorPageError {
464 public function __construct( Block $block ) {
465 // @todo FIXME: Implement a more proper way to get context here.
466 $params = $block->getPermissionsError( RequestContext::getMain() );
467 parent::__construct( 'blockedtitle', array_shift( $params ), $params );
468 }
469 }
470
471 /**
472 * Shows a generic "user is not logged in" error page.
473 *
474 * This is essentially an ErrorPageError exception which by default uses the
475 * 'exception-nologin' as a title and 'exception-nologin-text' for the message.
476 * @see bug 37627
477 * @since 1.20
478 *
479 * @par Example:
480 * @code
481 * if( $user->isAnon() ) {
482 * throw new UserNotLoggedIn();
483 * }
484 * @endcode
485 *
486 * Note the parameter order differs from ErrorPageError, this allows you to
487 * simply specify a reason without overriding the default title.
488 *
489 * @par Example:
490 * @code
491 * if( $user->isAnon() ) {
492 * throw new UserNotLoggedIn( 'action-require-loggedin' );
493 * }
494 * @endcode
495 *
496 * @ingroup Exception
497 */
498 class UserNotLoggedIn extends ErrorPageError {
499
500 /**
501 * @param string $reasonMsg A message key containing the reason for the error.
502 * Optional, default: 'exception-nologin-text'
503 * @param string $titleMsg A message key to set the page title.
504 * Optional, default: 'exception-nologin'
505 * @param array $params Parameters to wfMessage().
506 * Optional, default: null
507 */
508 public function __construct(
509 $reasonMsg = 'exception-nologin-text',
510 $titleMsg = 'exception-nologin',
511 $params = null
512 ) {
513 parent::__construct( $titleMsg, $reasonMsg, $params );
514 }
515 }
516
517 /**
518 * Show an error that looks like an HTTP server error.
519 * Replacement for wfHttpError().
520 *
521 * @since 1.19
522 * @ingroup Exception
523 */
524 class HttpError extends MWException {
525 private $httpCode, $header, $content;
526
527 /**
528 * Constructor
529 *
530 * @param $httpCode Integer: HTTP status code to send to the client
531 * @param string|Message $content content of the message
532 * @param string|Message $header content of the header (\<title\> and \<h1\>)
533 */
534 public function __construct( $httpCode, $content, $header = null ) {
535 parent::__construct( $content );
536 $this->httpCode = (int)$httpCode;
537 $this->header = $header;
538 $this->content = $content;
539 }
540
541 /**
542 * Returns the HTTP status code supplied to the constructor.
543 *
544 * @return int
545 */
546 public function getStatusCode() {
547 return $this->httpCode;
548 }
549
550 /**
551 * Report the HTTP error.
552 * Sends the appropriate HTTP status code and outputs an
553 * HTML page with an error message.
554 */
555 public function report() {
556 $httpMessage = HttpStatus::getMessage( $this->httpCode );
557
558 header( "Status: {$this->httpCode} {$httpMessage}", true, $this->httpCode );
559 header( 'Content-type: text/html; charset=utf-8' );
560
561 print $this->getHTML();
562 }
563
564 /**
565 * Returns HTML for reporting the HTTP error.
566 * This will be a minimal but complete HTML document.
567 *
568 * @return string HTML
569 */
570 public function getHTML() {
571 if ( $this->header === null ) {
572 $header = HttpStatus::getMessage( $this->httpCode );
573 } elseif ( $this->header instanceof Message ) {
574 $header = $this->header->escaped();
575 } else {
576 $header = htmlspecialchars( $this->header );
577 }
578
579 if ( $this->content instanceof Message ) {
580 $content = $this->content->escaped();
581 } else {
582 $content = htmlspecialchars( $this->content );
583 }
584
585 return "<!DOCTYPE html>\n" .
586 "<html><head><title>$header</title></head>\n" .
587 "<body><h1>$header</h1><p>$content</p></body></html>\n";
588 }
589 }
590
591 /**
592 * Handler class for MWExceptions
593 * @ingroup Exception
594 */
595 class MWExceptionHandler {
596 /**
597 * Install an exception handler for MediaWiki exception types.
598 */
599 public static function installHandler() {
600 set_exception_handler( array( 'MWExceptionHandler', 'handle' ) );
601 }
602
603 /**
604 * Report an exception to the user
605 */
606 protected static function report( Exception $e ) {
607 global $wgShowExceptionDetails;
608
609 $cmdLine = MWException::isCommandLine();
610
611 if ( $e instanceof MWException ) {
612 try {
613 // Try and show the exception prettily, with the normal skin infrastructure
614 $e->report();
615 } catch ( Exception $e2 ) {
616 // Exception occurred from within exception handler
617 // Show a simpler error message for the original exception,
618 // don't try to invoke report()
619 $message = "MediaWiki internal error.\n\n";
620
621 if ( $wgShowExceptionDetails ) {
622 $message .= 'Original exception: ' . self::formatRedactedTrace( $e ) . "\n\n" .
623 'Exception caught inside exception handler: ' . $e2->__toString();
624 } else {
625 $message .= "Exception caught inside exception handler.\n\n" .
626 "Set \$wgShowExceptionDetails = true; at the bottom of LocalSettings.php " .
627 "to show detailed debugging information.";
628 }
629
630 $message .= "\n";
631
632 if ( $cmdLine ) {
633 self::printError( $message );
634 } else {
635 echo nl2br( htmlspecialchars( $message ) ) . "\n";
636 }
637 }
638 } else {
639 $message = "Unexpected non-MediaWiki exception encountered, of type \"" .
640 get_class( $e ) . "\"";
641
642 if ( $wgShowExceptionDetails ) {
643 $message .= "\nexception '" . get_class( $e ) . "' in " .
644 $e->getFile() . ":" . $e->getLine() . "\nStack trace:\n" .
645 self::formatRedactedTrace( $e ) . "\n";
646 }
647
648 if ( $cmdLine ) {
649 self::printError( $message );
650 } else {
651 echo nl2br( htmlspecialchars( $message ) ) . "\n";
652 }
653 }
654 }
655
656 /**
657 * Print a message, if possible to STDERR.
658 * Use this in command line mode only (see isCommandLine)
659 *
660 * @param string $message Failure text
661 */
662 public static function printError( $message ) {
663 # NOTE: STDERR may not be available, especially if php-cgi is used from the
664 # command line (bug #15602). Try to produce meaningful output anyway. Using
665 # echo may corrupt output to STDOUT though.
666 if ( defined( 'STDERR' ) ) {
667 fwrite( STDERR, $message );
668 } else {
669 echo $message;
670 }
671 }
672
673 /**
674 * Exception handler which simulates the appropriate catch() handling:
675 *
676 * try {
677 * ...
678 * } catch ( MWException $e ) {
679 * $e->report();
680 * } catch ( Exception $e ) {
681 * echo $e->__toString();
682 * }
683 */
684 public static function handle( $e ) {
685 global $wgFullyInitialised;
686
687 self::report( $e );
688
689 // Final cleanup
690 if ( $wgFullyInitialised ) {
691 try {
692 // uses $wgRequest, hence the $wgFullyInitialised condition
693 wfLogProfilingData();
694 } catch ( Exception $e ) {
695 }
696 }
697
698 // Exit value should be nonzero for the benefit of shell jobs
699 exit( 1 );
700 }
701
702 /**
703 * Get the stack trace from the exception as a string, redacting certain
704 * function arguments in the process.
705 * @param Exception $e The exception
706 * @return string The stack trace as a string
707 */
708 public static function formatRedactedTrace( Exception $e ) {
709 global $wgRedactedFunctionArguments;
710 $finalExceptionText = '';
711
712 // Unique value to indicate redacted parameters
713 $redacted = new stdClass();
714
715 foreach ( $e->getTrace() as $i => $call ) {
716 $checkFor = array();
717 if ( isset( $call['class'] ) ) {
718 $checkFor[] = $call['class'] . '::' . $call['function'];
719 foreach ( class_parents( $call['class'] ) as $parent ) {
720 $checkFor[] = $parent . '::' . $call['function'];
721 }
722 } else {
723 $checkFor[] = $call['function'];
724 }
725
726 foreach ( $checkFor as $check ) {
727 if ( isset( $wgRedactedFunctionArguments[$check] ) ) {
728 foreach ( (array)$wgRedactedFunctionArguments[$check] as $argNo ) {
729 $call['args'][$argNo] = $redacted;
730 }
731 }
732 }
733
734 if ( isset( $call['file'] ) && isset( $call['line'] ) ) {
735 $finalExceptionText .= "#{$i} {$call['file']}({$call['line']}): ";
736 } else {
737 // 'file' and 'line' are unset for calls via call_user_func (bug 55634)
738 // This matches behaviour of Exception::getTraceAsString to instead
739 // display "[internal function]".
740 $finalExceptionText .= "#{$i} [internal function]: ";
741 }
742
743 if ( isset( $call['class'] ) ) {
744 $finalExceptionText .= $call['class'] . $call['type'] . $call['function'];
745 } else {
746 $finalExceptionText .= $call['function'];
747 }
748 $args = array();
749 if ( isset( $call['args'] ) ) {
750 foreach ( $call['args'] as $arg ) {
751 if ( $arg === $redacted ) {
752 $args[] = 'REDACTED';
753 } elseif ( is_object( $arg ) ) {
754 $args[] = 'Object(' . get_class( $arg ) . ')';
755 } elseif( is_array( $arg ) ) {
756 $args[] = 'Array';
757 } else {
758 $args[] = var_export( $arg, true );
759 }
760 }
761 }
762 $finalExceptionText .= '(' . implode( ', ', $args ) . ")\n";
763 }
764 return $finalExceptionText . '#' . ( $i + 1 ) . ' {main}';
765 }
766
767 /**
768 * Get the ID for this error.
769 *
770 * The ID is saved so that one can match the one output to the user (when
771 * $wgShowExceptionDetails is set to false), to the entry in the debug log.
772 *
773 * @since 1.22
774 * @param Exception $e
775 * @return string
776 */
777 public static function getLogId( Exception $e ) {
778 if ( !isset( $e->_mwLogId ) ) {
779 $e->_mwLogId = wfRandomString( 8 );
780 }
781 return $e->_mwLogId;
782 }
783
784 /**
785 * Return the requested URL and point to file and line number from which the
786 * exception occurred.
787 *
788 * @since 1.22
789 * @param Exception $e
790 * @return string
791 */
792 public static function getLogMessage( Exception $e ) {
793 global $wgRequest;
794
795 $id = self::getLogId( $e );
796 $file = $e->getFile();
797 $line = $e->getLine();
798 $message = $e->getMessage();
799
800 if ( isset( $wgRequest ) && !$wgRequest instanceof FauxRequest ) {
801 $url = $wgRequest->getRequestURL();
802 if ( !$url ) {
803 $url = '[no URL]';
804 }
805 } else {
806 $url = '[no req]';
807 }
808
809 return "[$id] $url Exception from line $line of $file: $message";
810 }
811
812 /**
813 * Log an exception to the exception log (if enabled).
814 *
815 * This method must not assume the exception is an MWException,
816 * it is also used to handle PHP errors or errors from other libraries.
817 *
818 * @since 1.22
819 * @param Exception $e
820 */
821 public static function logException( Exception $e ) {
822 global $wgLogExceptionBacktrace;
823
824 if ( !( $e instanceof MWException ) || $e->isLoggable() ) {
825 $log = self::getLogMessage( $e );
826 if ( $wgLogExceptionBacktrace ) {
827 wfDebugLog( 'exception', $log . "\n" . self::formatRedactedTrace( $e ) . "\n" );
828 } else {
829 wfDebugLog( 'exception', $log );
830 }
831 }
832 }
833
834 }