在未启用error_reporting的情况下,NGINX / PHP7.4-FPM抛出502

昨天我偶然发现了一个奇怪的问题。突然某个特定的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;

“ 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
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

在此先感谢您的帮助!

iCMS 回答:在未启用error_reporting的情况下,NGINX / PHP7.4-FPM抛出502

设置后

fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;

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

本文链接:https://www.f2er.com/2190577.html

大家都在问