Merge branch 'PHP-8.0'

* PHP-8.0:
  Don't throw additional Error in require_once if exception already thrown
This commit is contained in:
Nikita Popov 2021-02-11 09:42:05 +01:00
commit e396506cd6
2 changed files with 20 additions and 1 deletions

View file

@ -0,0 +1,19 @@
--TEST--
Promoting require_once warning to exception
--FILE--
<?php
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new Exception($errstr);
}
set_error_handler("exception_error_handler");
try {
$results = require_once 'does-not-exist.php';
} catch (Exception $e) {
echo $e->getMessage(), "\n";
};
?>
--EXPECT--
require_once(does-not-exist.php): Failed to open stream: No such file or directory

View file

@ -4240,7 +4240,7 @@ static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(zval
already_compiled: already_compiled:
new_op_array = ZEND_FAKE_OP_ARRAY; new_op_array = ZEND_FAKE_OP_ARRAY;
} }
} else { } else if (!EG(exception)) {
zend_message_dispatcher( zend_message_dispatcher(
(type == ZEND_INCLUDE_ONCE) ? (type == ZEND_INCLUDE_ONCE) ?
ZMSG_FAILED_INCLUDE_FOPEN : ZMSG_FAILED_REQUIRE_FOPEN, ZMSG_FAILED_INCLUDE_FOPEN : ZMSG_FAILED_REQUIRE_FOPEN,