From d123b390b1c550de91988a3451d2c3818082c12e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 13 Jul 2021 17:43:17 +0200 Subject: [PATCH] MonitoredObject: Keep structure of nested cvs during protection fixes #4439 --- .../Monitoring/Object/MonitoredObject.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 1e440e7d1..e16425cf9 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -466,19 +466,22 @@ abstract class MonitoredObject implements Filterable return $customvars; } - $obfuscatedCustomVars = []; - $obfuscator = function ($vars) use ($blacklistPattern, &$obfuscatedCustomVars, &$obfuscator) { + $obfuscator = function ($vars) use ($blacklistPattern, &$obfuscator) { + $result = []; foreach ($vars as $name => $value) { if ($blacklistPattern && preg_match($blacklistPattern, $name)) { - $obfuscatedCustomVars[$name] = '***'; + $result[$name] = '***'; + } elseif ($value instanceof stdClass || is_array($value)) { + $obfuscated = $obfuscator($value); + $result[$name] = $value instanceof stdClass ? (object) $obfuscated : $obfuscated; } else { - $obfuscatedCustomVars[$name] = $value instanceof stdClass || is_array($value) - ? $obfuscator($value) - : $value; + $result[$name] = $value; } } + + return $result; }; - $obfuscator($customvars); + $obfuscatedCustomVars = $obfuscator($customvars); return $customvars instanceof stdClass ? (object) $obfuscatedCustomVars : $obfuscatedCustomVars; }