提问者:小点点

NGINX/php7.4-fpm抛出502而不启用error_reporting


昨天我偶然发现了一个奇怪的问题。 突然一个特定的PHP脚本不再工作了,它抛出了一个502错误。 当我启用error_reporting时,只显示通知/警告,但页面的其余部分都正确呈现。 当我禁用error_reporting(“e_all”)时; ini_set(“display_errors”,1);,NGINX再次抛出502。

奇怪的是,当我看到下面的通知/警告片段时:

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;

“获取Massnahmen”代码:

    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

提前感谢您的帮助!


共1个答案

匿名用户

设置后

fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;

在我的nginx配置中,问题已经解决。 fastcgi的缓冲区大小似乎不足以响应。 非常感谢你的帮助!