Skip to content

Commit 4c171ed

Browse files
committed
Fix bug #81591: ignore_repeated_errors broken
We should suppress the error if the message is the same, not if it's different. Apparently we had no test coverage for these options.
1 parent 462271c commit 4c171ed

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- Core:
66
. Fixed bug #81582 (Stringable not implicitly declared if __toString() came
77
from a trait). (Nikita)
8+
. Fixed bug #81591 (Fatal Error not properly logged in particular cases).
9+
(Nikita)
810

911
- GD:
1012
. Fixed bug #71316 (libpng warning from imagecreatefromstring). (cmb)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Test ignore_repeated_errors ini setting
3+
--INI--
4+
ignore_repeated_errors=1
5+
--FILE--
6+
<?php
7+
8+
// Not a repeated error due to different variables names.
9+
$u1 + $u2;
10+
11+
// Repeated error.
12+
$u + $u;
13+
14+
// Not a repeated error, because the line is different.
15+
$u + 1;
16+
17+
?>
18+
--EXPECTF--
19+
Warning: Undefined variable $u1 in %s on line %d
20+
21+
Warning: Undefined variable $u2 in %s on line %d
22+
23+
Warning: Undefined variable $u in %s on line %d
24+
25+
Warning: Undefined variable $u in %s on line %d
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Test ignore_repeated_source ini setting
3+
--INI--
4+
ignore_repeated_errors=1
5+
ignore_repeated_source=1
6+
--FILE--
7+
<?php
8+
9+
// Not a repeated error due to different variables names.
10+
$u1 + $u2;
11+
12+
// Repeated error.
13+
$u + $u;
14+
15+
// Also a repeated error, because we're ignoring the different source.
16+
$u + 1;
17+
18+
?>
19+
--EXPECTF--
20+
Warning: Undefined variable $u1 in %s on line %d
21+
22+
Warning: Undefined variable $u2 in %s on line %d
23+
24+
Warning: Undefined variable $u in %s on line %d

main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ static ZEND_COLD void php_error_cb(int orig_type, const char *error_filename, co
12161216
if (PG(ignore_repeated_errors) && PG(last_error_message)) {
12171217
/* no check for PG(last_error_file) is needed since it cannot
12181218
* be NULL if PG(last_error_message) is not NULL */
1219-
if (zend_string_equals(PG(last_error_message), message)
1219+
if (!zend_string_equals(PG(last_error_message), message)
12201220
|| (!PG(ignore_repeated_source)
12211221
&& ((PG(last_error_lineno) != (int)error_lineno)
12221222
|| strcmp(PG(last_error_file), error_filename)))) {

0 commit comments

Comments
 (0)