MonitoredObject: Keep structure of nested cvs during protection
fixes #4439
This commit is contained in:
parent
2b09d22326
commit
d123b390b1
|
@ -466,19 +466,22 @@ abstract class MonitoredObject implements Filterable
|
||||||
return $customvars;
|
return $customvars;
|
||||||
}
|
}
|
||||||
|
|
||||||
$obfuscatedCustomVars = [];
|
$obfuscator = function ($vars) use ($blacklistPattern, &$obfuscator) {
|
||||||
$obfuscator = function ($vars) use ($blacklistPattern, &$obfuscatedCustomVars, &$obfuscator) {
|
$result = [];
|
||||||
foreach ($vars as $name => $value) {
|
foreach ($vars as $name => $value) {
|
||||||
if ($blacklistPattern && preg_match($blacklistPattern, $name)) {
|
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 {
|
} else {
|
||||||
$obfuscatedCustomVars[$name] = $value instanceof stdClass || is_array($value)
|
$result[$name] = $value;
|
||||||
? $obfuscator($value)
|
|
||||||
: $value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
};
|
};
|
||||||
$obfuscator($customvars);
|
$obfuscatedCustomVars = $obfuscator($customvars);
|
||||||
|
|
||||||
return $customvars instanceof stdClass ? (object) $obfuscatedCustomVars : $obfuscatedCustomVars;
|
return $customvars instanceof stdClass ? (object) $obfuscatedCustomVars : $obfuscatedCustomVars;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue