]> granicus.if.org Git - php/commitdiff
Fixed bug #62294
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 10 Aug 2020 10:54:02 +0000 (12:54 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 10 Aug 2020 10:54:02 +0000 (12:54 +0200)
The primary issue was already resolved in 7c3e487289ec41e560cf7a77e36eb43da2234f33,
but the particular example used in this bug report ran into an
additional issue on PHP 8, because I forgot to drop a number of
zend_bailout calls when switch require failure to throw.

NEWS
Zend/zend_language_scanner.l
ext/opcache/ZendAccelerator.c
sapi/cli/tests/bug62294.inc [new file with mode: 0644]
sapi/cli/tests/bug62294.phpt [new file with mode: 0644]
sapi/phpdbg/phpdbg_list.c

diff --git a/NEWS b/NEWS
index 93a8ecbb93f4ad32ab63e7352938097cc0f68bc1..c890b29c9a276677a06656c9aa37efe6f662b9b9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,8 @@ PHP                                                                        NEWS
     (Nikita)
   . Fixed bug #65275 (Calling exit() in a shutdown function does not change the
     exit value in CLI). (Nikita)
+  . Fixed bug #62294 (register_shutdown_function() does not correctly handle
+    exit code). (Nikita)
 
 - Date:
   . Fixed bug #60302 (DateTime::createFromFormat should new static(), not new
index c5f897419d1953124edebf00e77cc7e84ea9963a..c98c0f8e9bdf28697222c94bfd02e6e1ef1c497c 100644 (file)
@@ -655,7 +655,6 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type)
                if (!EG(exception)) {
                        if (type==ZEND_REQUIRE) {
                                zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
-                               zend_bailout();
                        } else {
                                zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
                        }
index 6f3ff1ceadc5236002f5474bd77a7df9a8a79fa3..a8187f0e905ceb9eb75aa70b14c43685080be96f 100644 (file)
@@ -1716,7 +1716,6 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl
                        if (!EG(exception)) {
                                if (type == ZEND_REQUIRE) {
                                        zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
-                                       zend_bailout();
                                } else {
                                        zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
                                }
@@ -1875,7 +1874,6 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
                        if (!EG(exception)) {
                                if (type == ZEND_REQUIRE) {
                                        zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
-                                       zend_bailout();
                                } else {
                                        zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
                                }
@@ -2032,7 +2030,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
                                if (!EG(exception)) {
                                        if (type == ZEND_REQUIRE) {
                                                zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
-                                               zend_bailout();
                                        } else {
                                                zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
                                        }
@@ -2090,7 +2087,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
                if (!EG(exception)) {
                        if (type == ZEND_REQUIRE) {
                                zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
-                               zend_bailout();
                        } else {
                                zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
                        }
diff --git a/sapi/cli/tests/bug62294.inc b/sapi/cli/tests/bug62294.inc
new file mode 100644 (file)
index 0000000..836fd44
--- /dev/null
@@ -0,0 +1,5 @@
+<?php
+
+register_shutdown_function(function() {
+    require 'path/to/an/unknown/file';
+});
diff --git a/sapi/cli/tests/bug62294.phpt b/sapi/cli/tests/bug62294.phpt
new file mode 100644 (file)
index 0000000..b300729
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #62294: register_shutdown_function() does not handle exit code correctly
+--FILE--
+<?php
+
+$php = getenv('TEST_PHP_EXECUTABLE');
+exec($php . ' ' . __DIR__ . '/bug62294.inc', $output, $exit_status);
+var_dump($exit_status);
+
+?>
+--EXPECT--
+int(255)
index 5c1b950bf65076157a6a0fb014788416e165ec26..d9b2fa00d58d40f5610ad0937431d32ea9041db1 100644 (file)
@@ -242,7 +242,6 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) {
        if (zend_stream_fixup(file, &bufptr, &len) == FAILURE) {
                if (type == ZEND_REQUIRE) {
                        zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file->filename);
-                       zend_bailout();
                } else {
                        zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file->filename);
                }