Merge branch 'PHP-8.1'

* PHP-8.1:
  Stop closing stderr and stdout streams (#8570)
  Revert "XFAIL tests (GH-8588)"
  XFAIL tests (GH-8588)
  Stop closing stderr and stdout streams (#8569)
This commit is contained in:
Arnaud Le Blanc 2022-05-20 13:40:27 +02:00
commit 980385d12d
4 changed files with 32 additions and 9 deletions

View file

@ -536,6 +536,16 @@ static void cli_register_file_handles(bool no_close) /* {{{ */
s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out);
s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err);
/* Release stream resources, but don't free the underlying handles. Othewrise,
* extensions which write to stderr or company during mshutdown/gshutdown
* won't have the expected functionality.
*/
if (no_close) {
if (s_in) s_in->flags |= PHP_STREAM_FLAG_NO_CLOSE;
if (s_out) s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE;
if (s_err) s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE;
}
if (s_in==NULL || s_out==NULL || s_err==NULL) {
if (s_in) php_stream_close(s_in);
if (s_out) php_stream_close(s_out);
@ -543,12 +553,6 @@ static void cli_register_file_handles(bool no_close) /* {{{ */
return;
}
if (no_close) {
s_in->flags |= PHP_STREAM_FLAG_NO_CLOSE;
s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE;
s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE;
}
s_in_process = s_in;
php_stream_to_zval(s_in, &ic.value);
@ -954,7 +958,7 @@ do_repeat:
switch (behavior) {
case PHP_MODE_STANDARD:
if (script_file) {
cli_register_file_handles(/* no_close */ PHP_DEBUG || num_repeats > 1);
cli_register_file_handles(/* no_close */ true);
}
if (interactive) {
@ -989,7 +993,7 @@ do_repeat:
}
break;
case PHP_MODE_CLI_DIRECT:
cli_register_file_handles(/* no_close */ PHP_DEBUG || num_repeats > 1);
cli_register_file_handles(/* no_close */ true);
zend_eval_string_ex(exec_direct, NULL, "Command line code", 1);
break;
@ -1004,7 +1008,7 @@ do_repeat:
file_handle.filename = NULL;
}
cli_register_file_handles(/* no_close */ PHP_DEBUG || num_repeats > 1);
cli_register_file_handles(/* no_close */ true);
if (exec_begin) {
zend_eval_string_ex(exec_begin, NULL, "Command line begin code", 1);