Skip to content

Commit c439f1f

Browse files
committed
Fixed bug #62294
The primary issue was already resolved in 7c3e487, 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.
1 parent 7c3e487 commit c439f1f

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ PHP NEWS
1919
(Nikita)
2020
. Fixed bug #65275 (Calling exit() in a shutdown function does not change the
2121
exit value in CLI). (Nikita)
22+
. Fixed bug #62294 (register_shutdown_function() does not correctly handle
23+
exit code). (Nikita)
2224

2325
- Date:
2426
. Fixed bug #60302 (DateTime::createFromFormat should new static(), not new

Zend/zend_language_scanner.l

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type)
655655
if (!EG(exception)) {
656656
if (type==ZEND_REQUIRE) {
657657
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
658-
zend_bailout();
659658
} else {
660659
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
661660
}

ext/opcache/ZendAccelerator.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,6 @@ static zend_persistent_script *opcache_compile_file(zend_file_handle *file_handl
17161716
if (!EG(exception)) {
17171717
if (type == ZEND_REQUIRE) {
17181718
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
1719-
zend_bailout();
17201719
} else {
17211720
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
17221721
}
@@ -1875,7 +1874,6 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
18751874
if (!EG(exception)) {
18761875
if (type == ZEND_REQUIRE) {
18771876
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
1878-
zend_bailout();
18791877
} else {
18801878
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
18811879
}
@@ -2032,7 +2030,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
20322030
if (!EG(exception)) {
20332031
if (type == ZEND_REQUIRE) {
20342032
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
2035-
zend_bailout();
20362033
} else {
20372034
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
20382035
}
@@ -2090,7 +2087,6 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
20902087
if (!EG(exception)) {
20912088
if (type == ZEND_REQUIRE) {
20922089
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
2093-
zend_bailout();
20942090
} else {
20952091
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
20962092
}

sapi/cli/tests/bug62294.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
register_shutdown_function(function() {
4+
require 'path/to/an/unknown/file';
5+
});

sapi/cli/tests/bug62294.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #62294: register_shutdown_function() does not handle exit code correctly
3+
--FILE--
4+
<?php
5+
6+
$php = getenv('TEST_PHP_EXECUTABLE');
7+
exec($php . ' ' . __DIR__ . '/bug62294.inc', $output, $exit_status);
8+
var_dump($exit_status);
9+
10+
?>
11+
--EXPECT--
12+
int(255)

sapi/phpdbg/phpdbg_list.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) {
242242
if (zend_stream_fixup(file, &bufptr, &len) == FAILURE) {
243243
if (type == ZEND_REQUIRE) {
244244
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file->filename);
245-
zend_bailout();
246245
} else {
247246
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file->filename);
248247
}

0 commit comments

Comments
 (0)