简体   繁体   English

如何调试和记录PHP OPcache问题

[英]How To Debug and Log PHP OPcache Issues

I am using WAMP on Windows 10, running PHP 7.2 with Apache 2.4 我在Windows 10上使用WAMP,在Apache 2.4上运行PHP 7.2

When I am turning on OPcache, a page I am loading crashes with the following error in Chrome: 当我打开OPcache时,我加载的页面在Chrome中崩溃并出现以下错误:

ERR_CONNECTION_RESET ERR_CONNECTION_RESET

I checked the php error log and Apache error log and could not find any error reported. 我检查了php错误日志和Apache错误日志,但未找到任何报告的错误。 I tried to disable Xdebug, still same crash and no errors in the logs. 我试图禁用Xdebug,仍然是相同的崩溃,并且在日志中没有错误。 Turning off OPcache or switching to php 7.1 or below resolves the issue. 关闭OPcache或切换到php 7.1或更低版本可以解决问题。

I was looking everywhere for some information on how to debug what causes OPcache to fail (and the reason) as turning it off is not a solution, but couldn't find anything helpful (also checked similar SO questions like this one which also has no resolution), so I am reaching out to the experts here for assistance, which I am sure will also help others. 我到处寻找有关如何调试导致OPcache失败的原因(以及原因)的一些信息,因为关闭它不是一个解决方案,但找不到任何有用的东西(也检查过类似的SO问题,比如这个也没有因此,我正在向专家们寻求帮助,我相信这也将有助于其他人。

Thank you. 谢谢。

PS Note that after a very long manual trial and error I was able to find the file in my php application that was causing OPcache to fail/crash and blacklisted that file in OPcache php.ini configuration (also reducing its size worked fine, so I doubt the problem was the actual code inside), but I am still looking for an easy way to debug such issues without having to go through & check each file on a server. PS注意一个很长的手动试错后,我能找到的文件在我的PHP应用程序,它是造成OPcache失败/崩溃,并列入黑名单在OPcache php.ini配置该文件(也降低了它的大小工作得很好,所以我怀疑问题是内部的实际代码),但我仍然在寻找一种简单的方法来调试这些问题,而无需检查和检查服务器上的每个文件。 I also don't know why it fails, so finding the cause for the failure will help file bug reports to the OPcache developers. 我也不知道它为什么会失败,所以找到失败的原因将有助于向OPcache开发人员提交bug报告。

EDIT: Adding a pastebin link requires code to be added to the question. 编辑:添加pastebin链接需要将代码添加到问题中。 Here is the beginning of the pastebin file: 这是pastebin文件的开头:

<?php

global $_LANGADM;
$_LANGADM = array();

$_LANGADM['AdminAddressesd3b206d196cd6be3a2764c1fb90b200f'] = 'Delete selected';
$_LANGADM['AdminAddressese25f0ecd41211b01c83e5fec41df4fe7'] = 'Delete selected items?';

TL;DR TL; DR

I am looking for: 我在寻找:

1) A way to easily determine that OPcache is the extension that makes a script fail, without having to go through each extension with a manual trial and error (turn them on/off until finding the extension that fails). 1)一种轻松确定OPcache是​​使脚本失败的扩展的方法,无需通过手动试验和错误遍历每个扩展(打开/关闭它们直到找到失败的扩展名)。

2) Easily find a way/log that shows which file and the reason/s it fails when OPcache is enabled. 2)轻松找到一种方式/日志,显示启用OPcache时哪个文件及其失败的原因

In simplest words - how can we know when, where and why OPcache fails when it fails, as without any reports/logs it's like searching for a needle in a haystack, especially when even Xdebug seems to be not logging or outputing anything when OPcache fails, for some reason. 简单来说 - 我们怎么知道OPcache失败时何时,何地以及为什么会失败,因为没有任何报告/日志就像在大海捞针一样,尤其是当OPcache失败时,即使Xdebug似乎没有记录或输出任何内容, 由于某些原因。

Thanks again 再次感谢

1) A way to easily determine that OPcache is the extension that makes a script fail, without having to go through each extension and turn them on/off until finding the extension that fails. 1)一种轻松确定OPcache是​​使脚本失败的扩展的方法,无需通过每个扩展并打开/关闭它们直到找到失败的扩展。

You can add the following to your script to temporarily disable opcache. 您可以将以下内容添加到脚本中以暂时禁用opcache。

ini_set('opcache.enable', 0);

2) Easily find a way/log that shows which file and the reason/s it fails when OPcache is enabled. 2)轻松找到一种方式/日志,显示启用OPcache时哪个文件及其失败的原因。

This is harder without more information about the application you are trying to debug. 如果没有关于您尝试调试的应用程序的更多信息,这将更难。 You can start by ensuring your error display is turned on. 您可以首先确保打开错误显示。

ini_set('display_errors', 1); error_reporting(~0);

However, if that doesn't work I would suggest debugging your application with Xdebug. 但是,如果这不起作用,我建议使用Xdebug调试您的应用程序。

Xdebug's (remote) debugger allows you to examine data structure, interactively walk through your and debug your code (from https://xdebug.org/docs/remote ). Xdebug(远程)调试器允许您检查数据结构,交互式地浏览和调试代码(来自https://xdebug.org/docs/remote )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM