PHP 5.2 出现的Nesting level too deep - recursive dependency问题

Nextcloud升级后问题解决 Nextcloud服务器版本太低了,执行自动升级服务。结果出现问题了。如下: 1、 在数据表 “oc_share” 中无法找到索引 “share_with_index”。 在数据表 “oc_share” 中无法找到索引 “parent_index”。 在数据表 “oc_share” 中无法找到索引 “owner_index”。 在数据表 “oc_share” 中无法找到索引 “initiator_index”。 在数据表 “oc_filecache” 中无法找到索引 “fs_mtime”。 2、 数据库中的 阅读详情
在PHP 5.1下运行很好的PHP,移植到PHP5.2之后出现 Nesting level too deep - recursive dependency的问题。
对PHP我是不懂了,但让其正常运行是我的责任,于是google。
下面是找到的东西

http://www.phpdeveloper.org/news/6691

So, you've just upgraded to PHP 5.2 and all is going well until you come across a page in your application that gives the message "Nesting level too deep - recursive dependency?". With such a vague error message, you might have trouble locating the source of the problem. Thankfully, someone's already been there and figured out the issue - Richard Lord.
I installed PHP 5.2 on one of my testing servers today and a couple of bits of code that previously worked fine in version 5.1.6 threw fatal errors in the new version. The error message was "Nesting level too deep - recursive dependency?" and it took a little time to track down the root of the problem. Here's what I'd done wrong.

Basically, his problem was using the "non-strict" evaluation for checking if two objects were equal to each other (== instead of ===). This compares everything about them, down to the properties - even if they're references to other properties inside of the same class (which is where the problem lies).

So, the fix is simple - === instead of == when comparing those objects. You'll be happier for the change.


 

http://www.bigroom.co.uk/blog/php-nesting-level-too-deep-recursive-dependency/


I installed PHP 5.2 on one of my testing servers today and a couple of bits of code that previously worked fine in version 5.1.6 threw fatal errors in the new version. The error message was “Nesting level too deep - recursive dependency?” and it took a little time to track down the root of the problem. Here’s what I’d done wrong.

In PHP there are two comparison operators, == and ===. It’s generally known that the first is not strict about type but the second is. So, for example

echo ( false == 0 ); // true
echo ( false === 0 ); // false
    - 0 is an integer and false is a boolean

My problem arose from using non-strict typing with objects.

$a = new MyObj();
$b = new MyObj();
if( $a == $b )
…

I hadn’t considered what I was doing with this code. When comparing two objects using the non-strict comparison operator (==) PHP compares all the properties of the objects and if they match the objects are deemed to be equal. If they don’t match they are not equal. In effect, we have a recursive comparison of all the properties of each object, and all their properties, etc. until we reach basic data types like strings and integers.

If, however, we use strict comparison (===), PHP will check whether the two objects are exactly the same object, not just objects with the same properties.

class MyObj
{
    public $p;
}

$a = new MyObj();
$b = new MyObj();
$c = new MyObj();
$a->p = 1;
$b->p = 1;
$c->p = 2;
echo ( $a == $c ); // false
echo ( $a == $b ); // true
echo ( $a === $b ); // false

The problem arises if you have circular references in your objects properties. So, for example

class MyObj
{
    public $p;
}
class OtherObj
{
    public $q;
}

$a = new MyObj();
$b = new OtherObj();
$a->p = $b;
$b->q = $a; // the circular reference: $a->p->p === $a

$c = new MyObj();
$d = new OtherObj();
$c->p = $d;
$d->q = $c;// another circular reference: $c->p->p === $c

echo ( $a == $c ); // Fatal error:
    Nesting level too deep - recursive dependency?

In order to compare $a to $c, PHP must compare their properties. So the logic in PHP goes something like this: $a == $c if $a->p == $c->p if $a->p->p == $c->p->p if $a->p->p->p == $c->p->p->p etc. indefinitely.

PHP 5.1 seemed to smooth over the problem somehow (probably after a certain level of recursion it simply returned false) - and usually it worked out fine. PHP 5.2 correctly produces the fatal error above.

Once you know the problem, the solution is easy - use strict comparison.

echo ( $a === $c ); // false (and no error)

The strict comparison will simply check whether the two objects are at the same location in memory and so doesn’t even look at the values of the properties.

N.B. The same problem can arise when using the negated comparison operators (use !== instead of !=) and when using in_array (use in_array’s third parameter to indicate strict comparison).


总之问题是解决了,是因为语言不规范所致。将==转为===, 将!=转为!==,彻底好了。

51单片机自学笔记(六)数码管动态扫描与消影实战 本文详细解析了51单片机数码管动态扫描原理与视觉暂留效应,通过硬件电路分析和C语言代码实战,重点介绍了三种数码管消影技术(段选清零法、位选屏蔽法、硬件消影法),解决了显示重影问题,并提供了常见问题调试技巧与定时器中断优化方案,帮助开发者掌握稳定的多位数码管显示技术。 阅读详情

相关推荐

保姆级教程:在RK3588 Android12设备树(DTS)中配置MIPI 8 Lane双通道与DSC显示

本文详细介绍了在RK3588 Android12平台上配置MIPI 8 Lane双通道与DSC显示的实战指南。通过设备树(DTS)参数详解、DSC参数计算与PPS配置、双通道同步机制实现等内容,帮助开发者高效完成高分辨率屏幕驱动配置,解决嵌入式显示系统开发中的常见挑战。

weixin_30905133的博客 399

Nesting level too deep - recursive dependency?

php7 使用双向循环链表解决约瑟夫问题时遇到的问题,下面是报错位置的代码: 在StackOverflow上相关问题下面有一个解答是这么描述的: 翻译过来的意思就是: 如果两个对象共享一个属性作为其值,PHP将在这些属性对象之间进行相同的==比较。现在,只要这些属性对象是递归的(例如,自引用对象),比较也会向下递归,直到达到最大嵌套级别 而我的那段代码 循环链表正是 自引用对象 ,所以出现这个问题, 解决方法上面图片也提到了, 就是自引用对象相互比较的时候...

shi588266的博客 626

华硕笔记本全硬盘恢复原厂状态 实机操作,MYASUS IN WINRE恢复,ASUS RECOVERY恢复

本教程的前提的在之前就备份了原厂的RECOVERY分区,RESTORE分区,MYASUS分区 如果这些分区都没有的话那就只能找同型号笔记本的朋友要一份了,或者去售后,告诉他这三个分区都要恢复。一般售后为了节约硬盘空间,不会给你恢复restore分区,这个分区有将近20G。 我机器撒天选2 i7-11800H,3060,32G,512GB,型号FX506HM 这篇教程先说全格式化怎么做,下次有空再说免格式化怎么弄。下面开始。 首先首先你的先做给优盘或者移动硬盘做一个PE。网上做PE启动盘的教程很多,这

JamesCurtis的博客 3万+

kconfig 和 config.in 语法 翻译

内核源码树的目录下都有两个文件Kconfig(2.4版本是Config.in)和Makefile。分布到各目录的 Kconfig构成了一个分布式的内核配置数据库,每个Kconfig分别描述了所属目录源文件相关的内核配置菜单。在内核配置make menuconfig(或xconfig等)时,从Kconfig中读出菜单,用户选择后保存到.config的内核配置文件中。在内核编译时,主 Makefile

瑜伽山神的博客 5388

SpringBoot实战(二十八)集成 Collabora Online 实现在线编辑

SpringBoot实战(二十八)集成 Collabora Online 实现在线编辑

ACGkaka的博客 6984

从零实现Unitree Go2的SLAM建图与导航:手把手集成slam_toolbox和nav2(附Rviz2可视化配置)

本文详细指导如何在Unitree Go2四足机器人上集成slam_toolbox和nav2,实现SLAM建图与导航功能。从ROS2环境配置、雷达数据处理到slam_toolbox参数优化,再到nav2路径规划与Rviz2可视化调试,提供完整解决方案。特别适合机器人开发者快速掌握ROS2导航栈在Unitree Go2上的应用实践。

weixin_33737134的博客 1232

安装install DBD::ODBC时出现循环依赖错误Recursive dependency detected:

安装时出现: Recursive dependency detected:     DBI  => T/TI/TIMB/DBI-1.616.tar.gz  => ExtUtils::MakeMaker  => M/MS/MSCHWERN/ExtUtils-MakeMaker-6.62.tar.gz  => File::Spec  => S/SM/SMUELLER/PathTools-

langmanchangfeng的专栏 2160

复现:Mamba-UNet:降水临近预报的创新解决方案

Mamba-UNet通过其创新的双分支Mamba融合模块、多尺度时空注意力模块和动态分位数加权损失函数,在降水临近预报领域取得了显著的性能提升。它不仅在多种降水场景下表现出色,尤其在预测强降水事件方面展现出了强大的能力。这一创新模型为降水临近预报提供了一种新的解决方案,有望在未来的研究和应用中发挥更大的作用,为应对气候变化带来的挑战提供有力支持。随着技术的不断发展和优化,我们期待Mamba-UNet在更广泛的气象预报任务中发挥更大的价值,为各行各业提供更精准、更可靠的降水预报服务。

hanfeng5268的博客 916

Nesting level too deep

在用PHP模拟循环链表结构时,给初始化的链表插入一个元素没有问题,但是用for循环插入10个元素,居然报出了如下错误: Fatal error: Nesting level too deep - recursive dependency 1 function append($data) { 2 $link = $this->header; 3 ...

aochuang7039的博客 355

大数据领域数据采集的人工智能辅助技术

在大数据时代,“数据是石油”的隐喻早已深入人心,但采集高质量数据的过程却像“在大海里捞针”——数据源分散如繁星、格式杂乱如碎片、质量参差不齐如泥沙,传统采集方法(写死的脚本、固定的ETL流程)早已力不从心。这篇文章将带你走进AI辅助数据采集的世界:我们会用“智能捕鱼船”的比喻拆解AI如何解决传统采集的痛点,深入解析“数据源自动发现”“自适应数据解析”“实时质量管控”等核心技术的原理,用代码示例还原AI采集的真实流程,最后探讨多模态采集、联邦学习等未来趋势。

小程序开发 2356

Windows配置CA证书颁发机构+NPS-DCServer

Windows配置证书颁发机构+NPS-DCServer

新时代先锋的博客 3万+

论文阅读Recursive Deep Models

http://nlp.stanford.edu/~socherr/EMNLP2013_RNTN.pdf Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank 递归的深度模型在情感语料库的语义组合上的应用 本文主要提出了一个递归神经张量网络(Recursive Neural

周周的专栏 2115

vue - 网站接入微信扫码登录功能详细教程,完整详细流程及完整功能示例源代码(附常见问题的解决方案与二维码样式修改方案)

vue.js项目植入微信登录,vue网页项目怎么做微信扫码登录,VUE项目中的微信扫码登录,VUE中最简单的js调用微信扫一扫功能,vue:如何设计网页的微信扫码登录功能,微信扫码功能官方文档,通过vue方式实现二维码扫码功能,vue调用微信扫码,vue H5 调用微信扫描二维码,Vue前端实现微信扫码登录,vue-wxlogin 微信授权登录组件,网站引入的微信登录框如何修改宽高或其他样式,wxlogin 组件插件怎么改变宽高,vue-wxlogin组件怎么自定义样式,微信网页授权,vue调用微信JSDK

✅ 精选推荐文章 6367

【安装】wsl ubuntu虚拟机编译rv1109大坑踩雷(建议使用vmware创建虚拟机)

wsl ubuntu编译sdk

kk的博客 1190

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

Fatal error: Maximum function nesting level of '100' reached, aborting!

今天访问PHP网站如下以下错误:  Fatal error: Maximum function nesting level of '100' reached, aborting! 原因分析: 这个问题是由于你启用了xdebug,而xdebug默认设置了函数最大嵌套数为100 解决办法: 找到php.ini文件,找到xdebug

chenhualeguan的专栏 2051

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

Kconfig配置文件

内核源码树的目录下都有两个文件Kconfig和Makefile。分布到各目录的Kconfig文件构成了一个分布式的内核配置数据库,每个Kconfig文件分别描述了所属目录源文档相关的内核配置菜单。在内核配置make menuconfig(或xconfig等)时,从Kconfig中读出来菜单,用户选择后保存到.config这个内核配置文档中。在内核编译时,主目录中的Makefile调用这个.config文件,就知道了用户的选择。 Kconfig对应着内核的配置菜单。如果想添加新的驱动到内核的源码中,就需要修改

weixin_45145710的博客 2683

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

【PHP报错集锦】 Maximum function nesting level of ‘256‘ reached, aborting!

author:咔咔 wechat:fangkangfk 遇到这个问题,什么事都不需要干,也不是什么深奥的bug,看看自己的代码调用,调用出错跟死循环

咔咔博客 1万+

Avoid nesting too deeply and return early避免嵌套太深应尽早返回

当某个变量与多个值进行比较的时候 不要用多个if else 判断是否相等 将多个值放在数组里,然后用PHP函数in_array(mixed $needle,array $haystack),检查数组$haystack里是否存在某个值$needle 总之这个例子就是要让嵌套达到最小 转载于:https://www.cnblogs.com/guoyinglichong/p/7519841.h...

weixin_34209406的博客 238

rcov "stack level too deep" 问题的解决

rcov 引起的 rexml/formatters/pretty.rb raise "stack level too deep" 这个问题google已有不少资料,初步的解决方案就是rexml/formatters/pretty.rb 130行改为 place = string.rindex(' ', width) || width 或者 place = string.rindex(' ', ...

scorpioleon的专栏 1024

Error #include nested too deeply

出现 Error #include nested too deeply 原因是: 头文件相互包含。 例如,一个工程中bsp.h 包含 LocDongle.h, LocDongle.h又包含bsp.h, 编译时就会报Error #include nested too deeply 。 解决办法: 1、将两个头文件共用的那一部分抽出来单独建一个头文件。 2、加预处理#ifndef.

ysdaniel的专栏 3万+
上一篇: 配置apache和mysql到多用户状态
下一篇: 免费打印pdf文件
DigBug
博客等级 码龄20年 15粉丝 19原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值