Skip to content

Commit 6465f3e

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: XFAIL tests (GH-8588) Stop closing stderr and stdout streams (#8569)
2 parents 9a19505 + f2ac4f2 commit 6465f3e

File tree

7 files changed

+35
-6
lines changed

7 files changed

+35
-6
lines changed

ext/opcache/tests/bug78175_2.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ opcache
1111
<?php
1212
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
1313
?>
14+
--XFAIL--
15+
GH-8588
1416
--FILE--
1517
<?php
1618
var_dump(get_class(Loader::getLoader()));

ext/opcache/tests/bug78376.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ opcache
1111
<?php
1212
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
1313
?>
14+
--XFAIL--
15+
GH-8588
1416
--FILE--
1517
<?php
1618
const CNST = 'bbbb';

ext/opcache/tests/preload_method_static_vars.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ opcache
1111
<?php
1212
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
1313
?>
14+
--XFAIL--
15+
GH-8588
1416
--FILE--
1517
<?php
1618
Foo::test();

ext/opcache/tests/preload_trait_static.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ opcache
1111
<?php
1212
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
1313
?>
14+
--XFAIL--
15+
GH-8588
1416
--FILE--
1517
<?php
1618
$bar = new Bar;

ext/zend_test/test.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ static ZEND_METHOD(ZendTestChildClassWithMethodWithParameterAttribute, override)
460460
PHP_INI_BEGIN()
461461
STD_PHP_INI_BOOLEAN("zend_test.replace_zend_execute_ex", "0", PHP_INI_SYSTEM, OnUpdateBool, replace_zend_execute_ex, zend_zend_test_globals, zend_test_globals)
462462
STD_PHP_INI_BOOLEAN("zend_test.register_passes", "0", PHP_INI_SYSTEM, OnUpdateBool, register_passes, zend_zend_test_globals, zend_test_globals)
463+
STD_PHP_INI_BOOLEAN("zend_test.print_stderr_mshutdown", "0", PHP_INI_SYSTEM, OnUpdateBool, print_stderr_mshutdown, zend_zend_test_globals, zend_test_globals)
463464
PHP_INI_END()
464465

465466
void (*old_zend_execute_ex)(zend_execute_data *execute_data);
@@ -585,6 +586,10 @@ PHP_MSHUTDOWN_FUNCTION(zend_test)
585586

586587
zend_test_observer_shutdown(SHUTDOWN_FUNC_ARGS_PASSTHRU);
587588

589+
if (ZT_G(print_stderr_mshutdown)) {
590+
fprintf(stderr, "[zend-test] MSHUTDOWN\n");
591+
}
592+
588593
return SUCCESS;
589594
}
590595

ext/zend_test/tests/gh8575.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
CLI: stderr is available in mshutdown
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('zend-test')) die('skip zend-test extension required');
6+
if (php_sapi_name() != "cli") die('skip cli test only');
7+
?>
8+
--INI--
9+
zend_test.print_stderr_mshutdown=1
10+
--FILE--
11+
==DONE==
12+
--EXPECTF--
13+
==DONE==
14+
[zend-test] MSHUTDOWN

sapi/cli/php_cli.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -538,19 +538,21 @@ static void cli_register_file_handles(bool no_close) /* {{{ */
538538
s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out);
539539
s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err);
540540

541+
/* Release stream resources, but don't free the underlying handles. Othewrise,
542+
* extensions which write to stderr or company during mshutdown/gshutdown
543+
* won't have the expected functionality.
544+
*/
545+
if (s_in) s_in->flags |= PHP_STREAM_FLAG_NO_CLOSE;
546+
if (s_out) s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE;
547+
if (s_err) s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE;
548+
541549
if (s_in==NULL || s_out==NULL || s_err==NULL) {
542550
if (s_in) php_stream_close(s_in);
543551
if (s_out) php_stream_close(s_out);
544552
if (s_err) php_stream_close(s_err);
545553
return;
546554
}
547555

548-
if (no_close) {
549-
s_in->flags |= PHP_STREAM_FLAG_NO_CLOSE;
550-
s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE;
551-
s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE;
552-
}
553-
554556
s_in_process = s_in;
555557

556558
php_stream_to_zval(s_in, &ic.value);

0 commit comments

Comments
 (0)