From: Timo Tijhof Date: Wed, 23 Sep 2015 16:36:10 +0000 (+0100) Subject: resourceloader: Include exception log id in error message X-Git-Tag: 1.31.0-rc.0~9818 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%22id_auteur=%24connect_id_auteur%22%29%20.%20%22?a=commitdiff_plain;h=9dcc8c872b0455be7324de479f8723c230aff6e2;p=lhc%2Fweb%2Fwiklou.git resourceloader: Include exception log id in error message This changes the current: > Internal error. To be: > [89466ede] 2015-09-23 16:40: Fatal exception of type Less_Exception This matches how exceptions are reported on HTML pages by MediaWiki (via MWException::getHTML in OutputPage). The IDs are okay to be public and exposed on HTML pages even when $wgShowExceptionDetails is disabled. Follows-up d478ffde100. Ref T110659. Change-Id: I501eaa629161184ba89d44e53cdac20b39cb0903 --- diff --git a/includes/exception/MWExceptionHandler.php b/includes/exception/MWExceptionHandler.php index d25f1a8269..4e50070c02 100644 --- a/includes/exception/MWExceptionHandler.php +++ b/includes/exception/MWExceptionHandler.php @@ -485,6 +485,14 @@ TXT; 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. * diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 1f48514c78..ab36701999 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -941,10 +941,10 @@ class ResourceLoader implements LoggerAwareInterface { global $wgShowExceptionDetails; if ( !$wgShowExceptionDetails ) { - return 'Internal error'; + return MWExceptionHandler::getPublicLogMessage( $e ); } - return $e->__toString(); + return MWExceptionHandler::getLogMessage( $e ); } /**