dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Follow-up for Iba0138a6d: remove now-unused MWHookException class
[lhc/web/wiklou.git]
/
includes
/
exception
/
MWExceptionHandler.php
diff --git
a/includes/exception/MWExceptionHandler.php
b/includes/exception/MWExceptionHandler.php
index
d4a240f
..
5734902
100644
(file)
--- a/
includes/exception/MWExceptionHandler.php
+++ b/
includes/exception/MWExceptionHandler.php
@@
-56,9
+56,9
@@
class MWExceptionHandler {
/**
* Report an exception to the user
/**
* Report an exception to the user
- * @param Exception $e
+ * @param Exception
|Throwable
$e
*/
*/
- protected static function report(
Exception
$e ) {
+ protected static function report( $e ) {
global $wgShowExceptionDetails;
$cmdLine = MWException::isCommandLine();
global $wgShowExceptionDetails;
$cmdLine = MWException::isCommandLine();
@@
-132,9
+132,9
@@
class MWExceptionHandler {
* transaction could be aborted properly.
*
* @since 1.23
* transaction could be aborted properly.
*
* @since 1.23
- * @param Exception $e
+ * @param Exception
|Throwable
$e
*/
*/
- public static function rollbackMasterChangesAndLog(
Exception
$e ) {
+ public static function rollbackMasterChangesAndLog( $e ) {
$factory = wfGetLBFactory();
if ( $factory->hasMasterChanges() ) {
$logger = LoggerFactory::getInstance( 'Bug56269' );
$factory = wfGetLBFactory();
if ( $factory->hasMasterChanges() ) {
$logger = LoggerFactory::getInstance( 'Bug56269' );
@@
-159,9
+159,9
@@
class MWExceptionHandler {
* }
*
* @since 1.25
* }
*
* @since 1.25
- * @param Exception $e
+ * @param Exception
|Throwable
$e
*/
*/
- public static function handleException(
Exception
$e ) {
+ public static function handleException( $e ) {
try {
// Rollback DBs to avoid transaction notices. This may fail
// to rollback some DB due to connection issues or exceptions.
try {
// Rollback DBs to avoid transaction notices. This may fail
// to rollback some DB due to connection issues or exceptions.
@@
-350,11
+350,11
@@
TXT;
* Like Exception::getTraceAsString, but replaces argument values with
* argument type or class name.
*
* Like Exception::getTraceAsString, but replaces argument values with
* argument type or class name.
*
- * @param Exception $e
+ * @param Exception
|Throwable
$e
* @return string
* @see prettyPrintTrace()
*/
* @return string
* @see prettyPrintTrace()
*/
- public static function getRedactedTraceAsString(
Exception
$e ) {
+ public static function getRedactedTraceAsString( $e ) {
return self::prettyPrintTrace( self::getRedactedTrace( $e ) );
}
return self::prettyPrintTrace( self::getRedactedTrace( $e ) );
}
@@
-380,10
+380,12
@@
TXT;
$text .= "{$pad}#{$level} [internal function]: ";
}
$text .= "{$pad}#{$level} [internal function]: ";
}
- if ( isset( $frame['class'] ) ) {
+ if ( isset( $frame['class'] )
&& isset( $frame['type'] ) && isset( $frame['function'] )
) {
$text .= $frame['class'] . $frame['type'] . $frame['function'];
$text .= $frame['class'] . $frame['type'] . $frame['function'];
- } else {
+ } else
if ( isset( $frame['function'] ) )
{
$text .= $frame['function'];
$text .= $frame['function'];
+ } else {
+ $text .= 'NO_FUNCTION_GIVEN';
}
if ( isset( $frame['args'] ) ) {
}
if ( isset( $frame['args'] ) ) {
@@
-407,10
+409,10
@@
TXT;
* or its type (if the element is a PHP primitive).
*
* @since 1.22
* or its type (if the element is a PHP primitive).
*
* @since 1.22
- * @param Exception $e
+ * @param Exception
|Throwable
$e
* @return array
*/
* @return array
*/
- public static function getRedactedTrace(
Exception
$e ) {
+ public static function getRedactedTrace( $e ) {
return static::redactTrace( $e->getTrace() );
}
return static::redactTrace( $e->getTrace() );
}
@@
-442,10
+444,10
@@
TXT;
* $wgShowExceptionDetails is set to false), to the entry in the debug log.
*
* @since 1.22
* $wgShowExceptionDetails is set to false), to the entry in the debug log.
*
* @since 1.22
- * @param Exception $e
+ * @param Exception
|Throwable
$e
* @return string
*/
* @return string
*/
- public static function getLogId(
Exception
$e ) {
+ public static function getLogId( $e ) {
if ( !isset( $e->_mwLogId ) ) {
$e->_mwLogId = wfRandomString( 8 );
}
if ( !isset( $e->_mwLogId ) ) {
$e->_mwLogId = wfRandomString( 8 );
}
@@
-471,10
+473,10
@@
TXT;
* Get a message formatting the exception message and its origin.
*
* @since 1.22
* Get a message formatting the exception message and its origin.
*
* @since 1.22
- * @param Exception $e
+ * @param Exception
|Throwable
$e
* @return string
*/
* @return string
*/
- public static function getLogMessage(
Exception
$e ) {
+ public static function getLogMessage( $e ) {
$id = self::getLogId( $e );
$type = get_class( $e );
$file = $e->getFile();
$id = self::getLogId( $e );
$type = get_class( $e );
$file = $e->getFile();
@@
-485,6
+487,14
@@
TXT;
return "[$id] $url $type from line $line of $file: $message";
}
return "[$id] $url $type from line $line of $file: $message";
}
+ public static function getPublicLogMessage( Exception $e ) {
+ $logId = self::getLogId( $e );
+ $type = get_class( $e );
+ return '[' . $logId . '] '
+ . gmdate( 'Y-m-d H:i:s' ) . ': '
+ . 'Fatal exception of type ' . $type;
+ }
+
/**
* Get a PSR-3 log event context from an Exception.
*
/**
* Get a PSR-3 log event context from an Exception.
*
@@
-492,10
+502,10
@@
TXT;
* exception that can be used to augment a log message sent to a PSR-3
* logger.
*
* exception that can be used to augment a log message sent to a PSR-3
* logger.
*
- * @param Exception $e
+ * @param Exception
|Throwable
$e
* @return array
*/
* @return array
*/
- public static function getLogContext(
Exception
$e ) {
+ public static function getLogContext( $e ) {
return array(
'exception' => $e,
'exception_id' => static::getLogId( $e ),
return array(
'exception' => $e,
'exception_id' => static::getLogId( $e ),
@@
-509,11
+519,11
@@
TXT;
* backtrace) derived from the given exception. The backtrace information
* will be redacted as per getRedactedTraceAsArray().
*
* backtrace) derived from the given exception. The backtrace information
* will be redacted as per getRedactedTraceAsArray().
*
- * @param Exception $e
+ * @param Exception
|Throwable
$e
* @return array
* @since 1.26
*/
* @return array
* @since 1.26
*/
- public static function getStructuredExceptionData(
Exception
$e ) {
+ public static function getStructuredExceptionData( $e ) {
global $wgLogExceptionBacktrace;
$data = array(
'id' => self::getLogId( $e ),
global $wgLogExceptionBacktrace;
$data = array(
'id' => self::getLogId( $e ),
@@
-592,12
+602,12
@@
TXT;
* @endcode
*
* @since 1.23
* @endcode
*
* @since 1.23
- * @param Exception $e
+ * @param Exception
|Throwable
$e
* @param bool $pretty Add non-significant whitespace to improve readability (default: false).
* @param int $escaping Bitfield consisting of FormatJson::.*_OK class constants.
* @return string|false JSON string if successful; false upon failure
*/
* @param bool $pretty Add non-significant whitespace to improve readability (default: false).
* @param int $escaping Bitfield consisting of FormatJson::.*_OK class constants.
* @return string|false JSON string if successful; false upon failure
*/
- public static function jsonSerializeException(
Exception
$e, $pretty = false, $escaping = 0 ) {
+ public static function jsonSerializeException( $e, $pretty = false, $escaping = 0 ) {
$data = self::getStructuredExceptionData( $e );
return FormatJson::encode( $data, $pretty, $escaping );
}
$data = self::getStructuredExceptionData( $e );
return FormatJson::encode( $data, $pretty, $escaping );
}
@@
-609,9
+619,9
@@
TXT;
* it is also used to handle PHP exceptions or exceptions from other libraries.
*
* @since 1.22
* it is also used to handle PHP exceptions or exceptions from other libraries.
*
* @since 1.22
- * @param Exception $e
+ * @param Exception
|Throwable
$e
*/
*/
- public static function logException(
Exception
$e ) {
+ public static function logException( $e ) {
if ( !( $e instanceof MWException ) || $e->isLoggable() ) {
$logger = LoggerFactory::getInstance( 'exception' );
$logger->error(
if ( !( $e instanceof MWException ) || $e->isLoggable() ) {
$logger = LoggerFactory::getInstance( 'exception' );
$logger->error(