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.
(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
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);
}
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);
}
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);
}
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);
}
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);
}
--- /dev/null
+<?php
+
+register_shutdown_function(function() {
+ require 'path/to/an/unknown/file';
+});
--- /dev/null
+--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)
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);
}