提问人:Chris 提问时间:6/6/2020 最后编辑:Chris 更新时间:6/6/2020 访问量:370
NGINX / PHP7.4-FPM 在未启用 error_reporting 的情况下抛出 502
NGINX / PHP7.4-FPM throws 502 without error_reporting enabled
问:
昨天我偶然发现了一个奇怪的问题。突然间,一个特定的PHP脚本不再起作用,它抛出了502错误。当我启用error_reporting时,仅显示通知/警告,但页面的其余部分正在正确呈现。当我再次禁用时,NGINX 再次抛出 502。error_reporting("E_ALL"); ini_set("display_errors", 1);
奇怪的是,当我用以下片段捕捉到通知/警告时:
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
if ($errno == E_USER_NOTICE){
}
}
set_error_handler("myErrorHandler");
页面也正确呈现,显然没有显示错误。
Debian 版本:4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64
PHP版本:php7.4-fpm
NGINX 版本:nginx/1.10.3
这可能是内存问题吗?或者有其他人的另一种解释,为什么会这样?
该代码没有设置响应标头,因为我从未在某处设置任何标头。我也不使用错误处理程序,我只是在出现问题不起作用时激活error_reporting。如果一切正常,我会禁用display_errors,因此不会显示通知/警告。
如果我删除文件的以下行,它也可以在不捕获错误的情况下工作:$list = $tn->getMassnahmen();
$tn是我的类“teilnehmer”的一个实例:$tn = new teilnehmer;
'getMassnahmen'代码:
function getMassnahmen()
{
$stmt = $this->db->prepare('SELECT * FROM `massnahmen_txt` ORDER BY `id` ASC');
if ($stmt->execute()) {
while ($row = $stmt->fetch()) {
$result[] = $row;
}
}
return $result;
}
“Teilnehmer”是我的客户。客户端可以向其添加文件(不同的数据库表)。仅当客户端添加了文件时,才会以某种方式发生错误。如果我注释掉代码中有关文件的整个部分,则仍然会发生错误。只有删除线会有所帮助。但是这一行与文件没有任何关系。它们只使用相同的类。$list = $tn->getMassnahmen();
“teilnehmer”($tn)的类/实例在代码中被多次使用,没有任何错误。
错误日志:
Notice: Undefined variable: nocal in /PATH//html/inc/global.inc.php on line 34
Notice: Undefined variable: result in /PATH//html/classes/user.php on line 672
Warning: sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/inc/global.inc.php on line 57
Notice: Undefined variable: newdates in /PATH//html/inc/global.inc.php on line 101
Warning: sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/inc/global.inc.php on line 101
Notice: Undefined variable: list in /PATH//html/inc/global.inc.php on line 113
Notice: Undefined variable: is_index in /PATH//html/inc/global.inc.php on line 120
Notice: Undefined variable: result in /PATH//html/classes/user.php on line 898
Warning: sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/inc/global.inc.php on line 129
Notice: Undefined variable: calendar in /PATH//html/inc/global.inc.php on line 133
Notice: Undefined variable: result in /PATH//html/classes/user.php on line 898
Notice: Undefined variable: result in /PATH//html/classes/mandanten.php on line 48
Warning: sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/inc/global.inc.php on line 144
Notice: Undefined variable: result in /PATH//html/classes/user.php on line 1425
Warning: sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/inc/global.inc.php on line 190
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Warning: array_walk() expects parameter 2 to be a valid callback, class 'user' does not have a method 'htmlspecialcharsArray' in /PATH//html/classes/user.php on line 224
Notice: Undefined index: success in /PATH//html/teilnehmer_edit.php on line 17
Notice: Undefined index: removedfile in /PATH//html/teilnehmer_edit.php on line 21
Notice: Undefined index: successremovelog in /PATH//html/teilnehmer_edit.php on line 26
Notice: Undefined index: fehltag_add in /PATH//html/teilnehmer_edit.php on line 65
Notice: Undefined index: remove_fehltag in /PATH//html/teilnehmer_edit.php on line 142
Notice: Undefined variable: content in /PATH//html/teilnehmer_edit.php on line 248
Notice: Undefined variable: active_fehltage in /PATH//html/teilnehmer_edit.php on line 257
Notice: Undefined variable: kursdata in /PATH//html/teilnehmer_edit.php on line 281
Notice: Undefined variable: statusdata in /PATH//html/teilnehmer_edit.php on line 282
Notice: Undefined variable: tabledata in /PATH//html/classes/template.php on line 134
Notice: Undefined variable: result in /PATH//html/classes/teilnehmer.php on line 606
Warning: sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/teilnehmer_edit.php on line 300
Warning: sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/teilnehmer_edit.php on line 314
Notice: Undefined variable: filelist in /PATH//html/teilnehmer_edit.php on line 387
Notice: Undefined variable: fehlliste in /PATH//html/teilnehmer_edit.php on line 676
Notice: Trying to access array offset on value of type bool in /PATH//html/teilnehmer_edit.php on line 699
Notice: Undefined variable: aglist in /PATH//html/teilnehmer_edit.php on line 740
Notice: Undefined index: name in /PATH//html/teilnehmer_edit.php on line 742
Notice: Undefined index: name in /PATH//html/teilnehmer_edit.php on line 742
Notice: Undefined variable: result in /PATH//html/classes/teilnehmer.php on line 684
Warning: sizeof(): Parameter must be an array or an object that implements Countable in /PATH//html/teilnehmer_edit.php on line 752
Notice: Undefined variable: list1 in /PATH//html/teilnehmer_edit.php on line 776
Notice: Undefined variable: mlist in /PATH//html/teilnehmer_edit.php on line 796
提前感谢您的帮助!
答:
设置后
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
在我的 nginx 配置中,问题已解决。似乎 fastcgi 的缓冲区大小对于响应来说不够大。非常感谢您的帮助!
上一个:如何显示 PHP 错误?
评论
set_time_limit(0)