From: Brad Jorsch Date: Fri, 25 Oct 2013 14:57:11 +0000 (-0400) Subject: Distinguish redactions from the string "REDACTED" in formatRedactedTrace X-Git-Tag: 1.31.0-rc.0~18385^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22suivi_revisions%22%2C%22id_auteur=%24connecte%22%29%20.%20%22?a=commitdiff_plain;h=63b2441d62f8a2e5805ab444413dec298c11356a;p=lhc%2Fweb%2Fwiklou.git Distinguish redactions from the string "REDACTED" in formatRedactedTrace In the output of MWExceptionHandler::formatRedactedTrace, it is not possible to determine (without checking the configuration) whether arg 0 in "foo('REDACTED')" was redacted or was merely passed the string "REDACTED". This patch changes redaction to instead output "foo(REDACTED)" in the case of redaction. This parallels the situation with arrays and objects, where for example "foo(Array)" was passed an array while "foo('Array')" was passed the string "Array". Change-Id: Ia2a761687c69b630afa3ccd8668b06b28e3ecdd3 --- diff --git a/includes/Exception.php b/includes/Exception.php index fba857f90d..a91f8657a0 100644 --- a/includes/Exception.php +++ b/includes/Exception.php @@ -686,6 +686,9 @@ class MWExceptionHandler { global $wgRedactedFunctionArguments; $finalExceptionText = ''; + // Unique value to indicate redacted parameters + $redacted = new stdClass(); + foreach ( $e->getTrace() as $i => $call ) { $checkFor = array(); if ( isset( $call['class'] ) ) { @@ -700,7 +703,7 @@ class MWExceptionHandler { foreach ( $checkFor as $check ) { if ( isset( $wgRedactedFunctionArguments[$check] ) ) { foreach ( (array)$wgRedactedFunctionArguments[$check] as $argNo ) { - $call['args'][$argNo] = 'REDACTED'; + $call['args'][$argNo] = $redacted; } } } @@ -722,7 +725,9 @@ class MWExceptionHandler { $args = array(); if ( isset( $call['args'] ) ) { foreach ( $call['args'] as $arg ) { - if ( is_object( $arg ) ) { + if ( $arg === $redacted ) { + $args[] = 'REDACTED'; + } elseif ( is_object( $arg ) ) { $args[] = 'Object(' . get_class( $arg ) . ')'; } elseif( is_array( $arg ) ) { $args[] = 'Array';