Skip to content

Commit e396506

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Don't throw additional Error in require_once if exception already thrown
2 parents e1fda10 + d80d918 commit e396506

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Promoting require_once warning to exception
3+
--FILE--
4+
<?php
5+
6+
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
7+
throw new Exception($errstr);
8+
}
9+
set_error_handler("exception_error_handler");
10+
11+
try {
12+
$results = require_once 'does-not-exist.php';
13+
} catch (Exception $e) {
14+
echo $e->getMessage(), "\n";
15+
};
16+
17+
?>
18+
--EXPECT--
19+
require_once(does-not-exist.php): Failed to open stream: No such file or directory

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4240,7 +4240,7 @@ static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(zval
42404240
already_compiled:
42414241
new_op_array = ZEND_FAKE_OP_ARRAY;
42424242
}
4243-
} else {
4243+
} else if (!EG(exception)) {
42444244
zend_message_dispatcher(
42454245
(type == ZEND_INCLUDE_ONCE) ?
42464246
ZMSG_FAILED_INCLUDE_FOPEN : ZMSG_FAILED_REQUIRE_FOPEN,

0 commit comments

Comments
 (0)