summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-05-29 17:27:51 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-06-05 09:46:39 +0200
commite949f306be9e7d54a700cccd5b9af9711615b43f (patch)
tree7b2d1e8b616edfd87e18538769f862ade8a58cdf
parent4ce47709c748f912849fac2b0c157a3274e27197 (diff)
downloadphp-git-e949f306be9e7d54a700cccd5b9af9711615b43f.tar.gz
Fixed bug #72089: Throw Error on require failure
It should be noted that we still throw the usual fopen warnings, but the final fatal error becomes an Error exception. Combine with @ to suppress FS warnings. Closes GH-5641.
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/include_stat_is_quiet.phpt5
-rw-r--r--main/main.c2
-rw-r--r--tests/lang/bug35176.phpt5
4 files changed, 11 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index e5fd10ddc1..f43f320b25 100644
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,8 @@ PHP NEWS
. Fixed bug #79467 (data:// wrappers are writable). (cmb)
. Implemented FR #47074 (phpinfo() reports "On" as 1 for the some
extensions). (cmb)
+ . Implemented FR #72089 (require() throws fatal error instead of exception).
+ (Nikita)
- BZ2:
. Fixed bug #71263 (fread() does not report bzip2.decompress errors). (cmb)
diff --git a/Zend/tests/include_stat_is_quiet.phpt b/Zend/tests/include_stat_is_quiet.phpt
index 932885bd66..ef8240f9ca 100644
--- a/Zend/tests/include_stat_is_quiet.phpt
+++ b/Zend/tests/include_stat_is_quiet.phpt
@@ -27,4 +27,7 @@ try {
--EXPECTF--
Warning: require_once(doesnt_exist.php): Failed to open stream: No such file or directory in %s on line %d
-Fatal error: require_once(): Failed opening required 'doesnt_exist.php' (include_path='test://foo:test://bar') in %s on line %d
+Fatal error: Uncaught Error: Failed opening required 'doesnt_exist.php' (include_path='test://foo:test://bar') in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %s on line %d
diff --git a/main/main.c b/main/main.c
index 1cb78dbc0f..7549de3d54 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1618,7 +1618,7 @@ static ZEND_COLD void php_message_handler_for_zend(zend_long message, const void
php_error_docref("function.include", E_WARNING, "Failed opening '%s' for inclusion (include_path='%s')", php_strip_url_passwd((char *) data), STR_PRINT(PG(include_path)));
break;
case ZMSG_FAILED_REQUIRE_FOPEN:
- php_error_docref("function.require", E_COMPILE_ERROR, "Failed opening required '%s' (include_path='%s')", php_strip_url_passwd((char *) data), STR_PRINT(PG(include_path)));
+ zend_throw_error(NULL, "Failed opening required '%s' (include_path='%s')", php_strip_url_passwd((char *) data), STR_PRINT(PG(include_path)));
break;
case ZMSG_FAILED_HIGHLIGHT_FOPEN:
php_error_docref(NULL, E_WARNING, "Failed opening '%s' for highlighting", php_strip_url_passwd((char *) data));
diff --git a/tests/lang/bug35176.phpt b/tests/lang/bug35176.phpt
index cbba52055d..c573c9c9de 100644
--- a/tests/lang/bug35176.phpt
+++ b/tests/lang/bug35176.phpt
@@ -12,4 +12,7 @@ require_once('nonexisiting.php');
<br />
<b>Warning</b>: require_once(nonexisiting.php) [<a href='/function.require-once.html'>function.require-once.html</a>]: Failed to open stream: No such file or directory in <b>%sbug35176.php</b> on line <b>2</b><br />
<br />
-<b>Fatal error</b>: require_once() [<a href='/function.require.html'>function.require.html</a>]: Failed opening required 'nonexisiting.php' (%s) in <b>%sbug35176.php</b> on line <b>2</b><br />
+<b>Fatal error</b>: Uncaught Error: Failed opening required 'nonexisiting.php' (include_path='%s') in %s:%d
+Stack trace:
+#0 {main}
+ thrown in <b>%sbug35176.php</b> on line <b>2</b><br />