CakePHP 2 代码在“调试”后无法正常工作已插入
暂时忽略我们需要更新 CakePHP 4 的事实...
去年我已经发生过十几次以下情况。即使代码很完美,它也会拒绝工作,所以我添加了一个“调试”来转储一些信息,然后代码神奇地开始工作。更奇怪的是,如果我删除“调试”,代码将继续工作。
我以为这只是我自己笔记本电脑的一个怪癖,直到一位同事说他在我们的在线开发环境中添加了“调试”,并且他试图解决的问题自行解决了。
最后,今天我试图确定为什么 SQL 密集的代码部分花费的时间远远超过其需要的时间,并且没有返回任何信息。我多次清除缓存,甚至重新启动我的笔记本电脑以获得最大的新鲜度 - 但没有任何帮助。我添加了一堆“调试”并运行了代码几次,然后删除了“调试”,现在代码执行时间只有 1/5,并且正在显示数据,该表有 400 行,每行 12 列,没什么大不了的。
有谁知道为什么添加调试,重新加载页面,然后删除调试,修复以前不起作用的代码?有没有办法从一开始就避免做这种愚蠢的把戏?
Ignore the fact that we need to update CakePHP 4 for a moment...
I've had the following scenario happen a dozen times over the last year. Code will refuse to work even though it's perfect, so I add a 'debug' to dump some information, and the code magically starts working. Even stranger, if I remove the 'debug', the code continues to work.
I thought it was just a quirk of my own laptop until a colleague said he added a 'debug' to our online development environment and the problem he was trying to solve fixed itself.
Finally, today I was trying to determine why a SQL-heavy section of code was taking far longer than it needed to and wasn't returning any info. I cleared by cache several times and even rebooted my laptop for maximum freshness – nothing helped. I added a bunch of 'debugs' and ran the code several times, then removed the 'debugs' and now the code is executing in 1/5th the time and it's displaying the data, which is a table of 400 rows with 12 columns each, nothing big.
Does anybody have any idea why adding a debug, reloading the page, then removing the debug, fixes code that was previously non-functional? Is there a way to prevent having to do this stupid trick in the first place?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论