yesterday I stumbled across a weird problem. Suddenly a specific PHP script didn't work anymore, it threw a 502 error. When I enabled error_reporting, only notices / warnings are displayed, but the rest of the page is being rendered correctly. When I disable error_reporting("E_ALL"); ini_set("display_errors", 1);
again, NGINX throws 502 again.
The weird thing is, when I catch the notices / warnings with the following snippet:
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
if ($errno == E_USER_NOTICE){
}
}
set_error_handler("myErrorHandler");
the page renders correctly aswell, obviously without showing the errors.
Debian version: 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64
PHP version: php7.4-fpm
NGINX version: nginx/1.10.3
Could this be a memory issue? Or has someone another explanation, why this is happening?
The code doesn't set the response header since I never set any headers somewhere. I also don't use a error handler, I just activate error_reporting, when something doesn't work. If everything works, I disable display_errors, so then notices / warnings won't be shown.
If I remove the following line of my file, it also works without catching the errors:
$list = $tn->getMassnahmen();
$tn is an instance of my class 'teilnehmer':
$tn = new teilnehmer;
Code of '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' are my clients. Clients can have files added to them (different database table). The error somehow only occurs, if clients have files added. If I comment out the whole section regarding files in my code, the error still occurs. Only the removing of the line $list = $tn->getMassnahmen();
will help. But this line DOES NOT have anything to do with the files in any way. They only use the same class.
The class / instance of 'teilnehmer' ($tn) is being used multiple times before in the code, without any errors.
Error Log:
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
Thanks in advance for your help!