diff options
-rw-r--r-- | lib/private/Log/ExceptionSerializer.php | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/private/Log/ExceptionSerializer.php b/lib/private/Log/ExceptionSerializer.php index a943efd0084..dab134b26a4 100644 --- a/lib/private/Log/ExceptionSerializer.php +++ b/lib/private/Log/ExceptionSerializer.php @@ -228,14 +228,27 @@ class ExceptionSerializer { }, $filteredTrace); } - private function encodeArg($arg) { + private function encodeArg($arg, $nestingLevel = 5) { if (is_object($arg)) { - $data = get_object_vars($arg); - $data['__class__'] = get_class($arg); - return array_map([$this, 'encodeArg'], $data); + if ($nestingLevel === 0) { + return [ + '__class__' => get_class($arg), + '__properties__' => 'Encoding skipped as the maximum nesting level was reached', + ]; + } + + $objectInfo = [ '__class__' => get_class($arg) ]; + $objectVars = get_object_vars($arg); + return array_map(function ($arg) use ($nestingLevel) { + return $this->encodeArg($arg, $nestingLevel - 1); + }, array_merge($objectInfo, $objectVars)); } if (is_array($arg)) { + if ($nestingLevel === 0) { + return ['Encoding skipped as the maximum nesting level was reached']; + } + // Only log the first 5 elements of an array unless we are on debug if ((int)$this->systemConfig->getValue('loglevel', 2) !== 0) { $elemCount = count($arg); @@ -244,7 +257,9 @@ class ExceptionSerializer { $arg[] = 'And ' . ($elemCount - 5) . ' more entries, set log level to debug to see all entries'; } } - return array_map([$this, 'encodeArg'], $arg); + return array_map(function ($e) use ($nestingLevel) { + return $this->encodeArg($e, $nestingLevel - 1); + }, $arg); } return $arg; |