/**
* @var array $fatalErrorTypes
*/
- protected static $fatalErrorTypes = array(
+ protected static $fatalErrorTypes = [
E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR,
/* HHVM's FATAL_ERROR level */ 16777217,
- );
+ ];
/**
* @var bool $handledFatalCallback
*/
// log.
$trace = $trace ?: debug_backtrace();
$logger = LoggerFactory::getInstance( 'fatal' );
- $logger->error( $msg, array(
- 'exception' => array(
+ $logger->error( $msg, [
+ 'exception' => [
'class' => 'ErrorException',
'message' => "PHP Fatal Error: {$message}",
'code' => $level,
'file' => $file,
'line' => $line,
'trace' => static::redactTrace( $trace ),
- ),
+ ],
'exception_id' => wfRandomString( 8 ),
- ) );
+ ] );
// Remember call so we don't double process via HHVM's fatal
// notifications and the shutdown hook behavior
* $wgShowExceptionDetails is set to false), to the entry in the debug log.
*
* @since 1.22
+ * @deprecated since 1.27: Exception IDs are synonymous with request IDs.
* @param Exception|Throwable $e
* @return string
*/
public static function getLogId( $e ) {
- if ( !isset( $e->_mwLogId ) ) {
- $e->_mwLogId = wfRandomString( 8 );
- }
- return $e->_mwLogId;
+ wfDeprecated( __METHOD__, '1.27' );
+ return WebRequest::getRequestId();
}
/**
* @return string
*/
public static function getLogMessage( $e ) {
- $id = self::getLogId( $e );
+ $id = WebRequest::getRequestId();
$type = get_class( $e );
$file = $e->getFile();
$line = $e->getLine();
}
public static function getPublicLogMessage( Exception $e ) {
- $logId = self::getLogId( $e );
+ $reqId = WebRequest::getRequestId();
$type = get_class( $e );
- return '[' . $logId . '] '
+ return '[' . $reqId . '] '
. gmdate( 'Y-m-d H:i:s' ) . ': '
. 'Fatal exception of type ' . $type;
}
* @return array
*/
public static function getLogContext( $e ) {
- return array(
+ return [
'exception' => $e,
- 'exception_id' => static::getLogId( $e ),
- );
+ 'exception_id' => WebRequest::getRequestId(),
+ ];
}
/**
*/
public static function getStructuredExceptionData( $e ) {
global $wgLogExceptionBacktrace;
- $data = array(
- 'id' => self::getLogId( $e ),
+ $data = [
+ 'id' => WebRequest::getRequestId(),
'type' => get_class( $e ),
'file' => $e->getFile(),
'line' => $e->getLine(),
'message' => $e->getMessage(),
'code' => $e->getCode(),
'url' => self::getURL() ?: null,
- );
+ ];
if ( $e instanceof ErrorException &&
( error_reporting() & $e->getSeverity() ) === 0
$json = self::jsonSerializeException( $e, false, FormatJson::ALL_OK );
if ( $json !== false ) {
$logger = LoggerFactory::getInstance( 'exception-json' );
- $logger->error( $json, array( 'private' => true ) );
+ $logger->error( $json, [ 'private' => true ] );
}
- Hooks::run( 'LogException', array( $e, false ) );
+ Hooks::run( 'LogException', [ $e, false ] );
}
}
$json = self::jsonSerializeException( $e, false, FormatJson::ALL_OK );
if ( $json !== false ) {
$logger = LoggerFactory::getInstance( "{$channel}-json" );
- $logger->error( $json, array( 'private' => true ) );
+ $logger->error( $json, [ 'private' => true ] );
}
- Hooks::run( 'LogException', array( $e, $suppressed ) );
+ Hooks::run( 'LogException', [ $e, $suppressed ] );
}
}