Krinkle has uploaded a new change for review.
https://gerrit.wikimedia.org/r/177096
Change subject: exception: Hide suppressed errors in 'error' log, flag in
'error-json'
......................................................................
exception: Hide suppressed errors in 'error' log, flag in 'error-json'
Follows-up 399ba2f.
Bug: T75619
Change-Id: I1f312660c058a3940bf1e9425f86cfd531121ba3
---
M includes/exception/MWExceptionHandler.php
1 file changed, 17 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/96/177096/1
diff --git a/includes/exception/MWExceptionHandler.php
b/includes/exception/MWExceptionHandler.php
index 39c4c3a..8272688 100644
--- a/includes/exception/MWExceptionHandler.php
+++ b/includes/exception/MWExceptionHandler.php
@@ -384,6 +384,11 @@
'message' => $e->getMessage(),
);
+ if ( $e instanceof ErrorException && ( error_reporting() &
$e->getSeverity() ) === 0 ) {
+ // Flag surpressed errors
+ $exceptionData['suppressed'] = true;
+ }
+
// Because MediaWiki is first and foremost a web application,
we set a
// 'url' key unconditionally, but set it to null if the
exception does
// not occur in the context of a web request, as a way of
making that
@@ -429,18 +434,23 @@
* Log an exception that wasn't thrown but made to wrap an error.
*
* @since 1.25
- * @param Exception $e
+ * @param ErrorException $e
*/
- protected static function logError( Exception $e ) {
+ protected static function logError( ErrorException $e ) {
global $wgLogExceptionBacktrace;
- $log = self::getLogMessage( $e );
- if ( $wgLogExceptionBacktrace ) {
- wfDebugLog( 'error', $log . "\n" .
$e->getTraceAsString() );
- } else {
- wfDebugLog( 'error', $log );
+ // The set_error_handler callkback is independent from
error_reporting.
+ // Filter out unwanted errors manually (e.g. when
wfSuppressWarnings is active).
+ if ( ( error_reporting() & $e->getSeverity() ) !== 0 ) {
+ $log = self::getLogMessage( $e );
+ if ( $wgLogExceptionBacktrace ) {
+ wfDebugLog( 'error', $log . "\n" .
$e->getTraceAsString() );
+ } else {
+ wfDebugLog( 'error', $log );
+ }
}
+ // Include all errors in the json log (surpressed errors will
be flagged)
$json = self::jsonSerializeException( $e, false,
FormatJson::ALL_OK );
if ( $json !== false ) {
wfDebugLog( 'error-json', $json, 'private' );
--
To view, visit https://gerrit.wikimedia.org/r/177096
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1f312660c058a3940bf1e9425f86cfd531121ba3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits