From f0386d31835b8f65fb7fc1f275d1761cae339e97 Mon Sep 17 00:00:00 2001
From: Timo Tijhof
Date: Wed, 9 Oct 2013 02:20:41 +0200
Subject: [PATCH] exception: Move logging logic to static method of
MWExceptionHandler
Follows-up c28251a9fd, which unconditionally called logException
on objects that aren't always instances of MWException.
This makes it possible to, for example, log PHP errors or errors
from Less in ResourceLoader to be logged as well (which naturally
don't have a logException method).
As a result of the handling now being generic, non-MWException
errors will now be loggable, and also have their ID fixed between
HTML output and the debug log entry.
* Not yet removing MWException::getLogMessage (introduced in bcb9f9e1c)
as it has been around since 2006 (released in 1.8.0).
* Not yet removing MWException::getLogId (introduced in 70841c5867)
as it was part of the 1.20.0 release.
* Removed MWException::logException (introduced in c28251a9fd)
as it was only added a few weeks ago within this release cycle.
Change-Id: Iab98e3a7a9b78d8602e69e0571b35cf107a96b72
---
includes/Exception.php | 123 ++++++++++++++-------
includes/resourceloader/ResourceLoader.php | 16 +--
2 files changed, 88 insertions(+), 51 deletions(-)
diff --git a/includes/Exception.php b/includes/Exception.php
index b97697dedf..fba857f90d 100644
--- a/includes/Exception.php
+++ b/includes/Exception.php
@@ -30,7 +30,6 @@
* @ingroup Exception
*/
class MWException extends Exception {
- var $logId;
/**
* Should the exception use $wgOut to output the error?
@@ -131,7 +130,7 @@ class MWException extends Exception {
"
\n";
} else {
return "" .
- '[' . $this->getLogId() . '] ' .
+ '[' . MWExceptionHandler::getLogId( $this ) . '] ' .
gmdate( 'Y-m-d H:i:s' ) .
": Fatal exception of type " . get_class( $this ) . "
\n" .
"