From d80d918547b676e78ccf096a24069a8b2e5dd96b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 11 Feb 2021 09:40:19 +0100 Subject: [PATCH] Don't throw additional Error in require_once if exception already thrown As pointed out in comments on bug #66216. --- .../require_once_warning_to_exception.phpt | 19 +++++++++++++++++++ Zend/zend_execute.c | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/require_once_warning_to_exception.phpt diff --git a/Zend/tests/require_once_warning_to_exception.phpt b/Zend/tests/require_once_warning_to_exception.phpt new file mode 100644 index 0000000000..d115ac68cc --- /dev/null +++ b/Zend/tests/require_once_warning_to_exception.phpt @@ -0,0 +1,19 @@ +--TEST-- +Promoting require_once warning to exception +--FILE-- +getMessage(), "\n"; +}; + +?> +--EXPECT-- +require_once(does-not-exist.php): Failed to open stream: No such file or directory diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index ca1f88ba55..bc964c1ad1 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -4224,7 +4224,7 @@ static zend_never_inline zend_op_array* ZEND_FASTCALL zend_include_or_eval(zval already_compiled: new_op_array = ZEND_FAKE_OP_ARRAY; } - } else { + } else if (!EG(exception)) { zend_message_dispatcher( (type == ZEND_INCLUDE_ONCE) ? ZMSG_FAILED_INCLUDE_FOPEN : ZMSG_FAILED_REQUIRE_FOPEN, -- 2.50.1