Nesting level too deep – recursive dependency? at /var/www/html/lib/private/Log/ExceptionSerializer.php

目录 Linux更新于 2022-08-24
Nesting level too deep – recursive dependency? at /var/www/html/lib/private/Log/ExceptionSerializer.php-下一朵云

Nextcloud 24.0.4后台添加用户时,报错Nesting level too deep – recursive dependency? at var/www/html/lib/private/Log/ExceptionSerializer.php#215

说明:此问题不是配置问题,或者服务器问题,目前确认是一个BUG,等待官方修复。(后续官方发布补丁的话会在本文更新)

目前解决办法:

禁用 Circles应用,这个问题就不会再出现,但是又会触发新的BUG

OCP\AppFramework\OCS\OCSException: Invalid displayname

https://github.com/nextcloud/server/issues/33591

总之,这东西版本越新问题越多,考虑要弃坑了!

Nesting level too deep – recursive dependency? at /var/www/html/lib/private/Log/ExceptionSerializer.php-下一朵云
图1 禁用Circles应用
Nesting level too deep – recursive dependency? at /var/www/html/lib/private/Log/ExceptionSerializer.php-下一朵云
图2 触发新的BUG

一、问题复现:

1.管理员用户登录Nextcloud

2.打开“ 设置/用户 ”

3.单击“创建用户”

4.填写用户信息,包括电子邮件、密码、组(触发BUG)和显示名称

Nesting level too deep – recursive dependency? at /var/www/html/lib/private/Log/ExceptionSerializer.php-下一朵云
图3 新建用户

5.单击“添加新用户”

6.此时,会出现报错:”An error occurred during the request. Unable to proceed.”

7.刷新网页,用户又创建成功了

8.日志中报错:Nesting level too deep – recursive dependency? at /var/www/html/lib/private/Log/ExceptionSerializer.php#215

二、解决办法

解决办法: 禁用 Circles应用

暂时并未找到解决方法,官方也未对此BUG作回复。

尝试打了补丁,问题依旧存在!

尝试方法:(打补丁无法解决

(1)下载或创建33501.patch文件,文件内容如下:

From bc35deee5ebf3345d5b65e426ff234d8475e6764 Mon Sep 17 00:00:00 2001
From: Christoph Wurst <christoph@winzerhof-wurst.at>
Date: Wed, 10 Aug 2022 15:54:51 +0200
Subject: [PATCH] Catch PHP in_array recursion inside exception serializer

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
---
 lib/private/Log/ExceptionSerializer.php | 31 ++++++++++++++++++-------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/lib/private/Log/ExceptionSerializer.php b/lib/private/Log/ExceptionSerializer.php
index aaf6a39235e0..f19418b3b9ba 100644
--- a/lib/private/Log/ExceptionSerializer.php
+++ b/lib/private/Log/ExceptionSerializer.php
@@ -40,6 +40,9 @@
 use OCA\Encryption\KeyManager;
 use OCA\Encryption\Session;
 use OCP\HintException;
+use Throwable;
+use function in_array;
+use function is_array;
 
 class ExceptionSerializer {
 	public const SENSITIVE_VALUE_PLACEHOLDER = '*** sensitive parameters replaced ***';
@@ -210,16 +213,26 @@ private function filterTrace(array $trace) {
 	}
 
 	private function removeValuesFromArgs($args, $values) {
-		$workArgs = [];
-		foreach ($args as $arg) {
-			if (in_array($arg, $values, true)) {
-				$arg = self::SENSITIVE_VALUE_PLACEHOLDER;
-			} elseif (is_array($arg)) {
-				$arg = $this->removeValuesFromArgs($arg, $values);
+		return array_map(function($arg) use ($values) {
+			// Sensitive?
+			try {
+				if (in_array($arg, $values, true)) {
+					return self::SENSITIVE_VALUE_PLACEHOLDER;
+				}
+			} catch (Throwable $e) {
+				// In very rare cases PHP can't run in_array on the args because
+				// of a recursive structure. In that case we fall back to
+				// assuming the argument could be sensitive
+				return self::SENSITIVE_VALUE_PLACEHOLDER;
 			}
-			$workArgs[] = $arg;
-		}
-		return $workArgs;
+
+			// Array?
+			if (is_array($arg)) {
+				return $this->removeValuesFromArgs($arg, $values);
+			}
+
+			return $arg;
+		}, $args);
 	}
 
 	private function encodeTrace($trace) {

(2)在Nextcloud目录下,执行以下命令

patch -p 1 < 33501.patch
Nesting level too deep – recursive dependency? at /var/www/html/lib/private/Log/ExceptionSerializer.php-下一朵云
图4 应用补丁
>>本文为下一朵云的原创文章,转载请附上原文出处链接及本声明
>>原文链接地址:Nesting level too deep – recursive dependency? at /var/www/html/lib/private/Log/ExceptionSerializer.php

1 条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注