From 7c3dfbb84581e82bd89886f3752b0c21ac0f47c1 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 8 Jul 2022 13:56:17 +0100 Subject: [PATCH 1/3] intl extension, build fix for icu >= 69.x release. ubrk/ucnv_safeClone had been deprecated in favor of ubrk/ucnv_clone which does not use user provided stacks but remain thread safe. --- NEWS | 3 +++ ext/intl/converter/converter.c | 8 ++++++++ ext/intl/grapheme/grapheme_util.c | 8 +++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index dcebfea1533..5742b778f07 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,9 @@ PHP NEWS . Fixed bug GH-8848 (imagecopyresized() error refers to the wrong argument). (cmb) +- Intl: + . Fixed build for ICU 69.x and onwards. (David Carlier) + - OPcache: . Fixed bug GH-8847 (PHP hanging infinitly at 100% cpu when check php syntaxe of a valid file). (Dmitry) diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index 697ebcda0b7..82cf7150d69 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -933,10 +933,18 @@ static zend_object *php_converter_clone_object(zend_object *object) { intl_errors_reset(&oldobj->error); +#if U_ICU_VERSION_MAJOR_NUM > 70 + objval->src = ucnv_clone(oldobj->src, &error); +#else objval->src = ucnv_safeClone(oldobj->src, NULL, NULL, &error); +#endif if (U_SUCCESS(error)) { error = U_ZERO_ERROR; +#if U_ICU_VERSION_MAJOR_NUM > 70 + objval->dest = ucnv_clone(oldobj->dest, &error); +#else objval->dest = ucnv_safeClone(oldobj->dest, NULL, NULL, &error); +#endif } if (U_FAILURE(error)) { zend_string *err_msg; diff --git a/ext/intl/grapheme/grapheme_util.c b/ext/intl/grapheme/grapheme_util.c index 23d48973df3..17a896aa46e 100644 --- a/ext/intl/grapheme/grapheme_util.c +++ b/ext/intl/grapheme/grapheme_util.c @@ -373,8 +373,6 @@ grapheme_strrpos_ascii(char *haystack, size_t haystack_len, char *needle, size_t /* {{{ grapheme_get_break_iterator: get a clone of the global character break iterator */ UBreakIterator* grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status ) { - int32_t buffer_size; - UBreakIterator *global_break_iterator = INTL_G( grapheme_iterator ); if ( NULL == global_break_iterator ) { @@ -388,8 +386,12 @@ UBreakIterator* grapheme_get_break_iterator(void *stack_buffer, UErrorCode *stat INTL_G(grapheme_iterator) = global_break_iterator; } - buffer_size = U_BRK_SAFECLONE_BUFFERSIZE; +#if U_ICU_VERSION_MAJOR_NUM >= 69 + return ubrk_clone(global_break_iterator, status); +#else + int32_t buffer_size = U_BRK_SAFECLONE_BUFFERSIZE; return ubrk_safeClone(global_break_iterator, stack_buffer, &buffer_size, status); +#endif } /* }}} */ From 2dbde18b29d540cff7915ff8fed070eb85d1646f Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Sat, 9 Jul 2022 22:58:02 +0200 Subject: [PATCH 2/3] Fix GH-8952: std streams can not be deliberately closed (#8953) --- sapi/cli/php_cli.c | 14 ++++----- sapi/cli/tests/gh8827-001.phpt | 38 +++++++++++++++++++++++ sapi/cli/tests/gh8827-002.phpt | 47 ++++++++++++++++++++++++++++ sapi/cli/tests/gh8827-003.phpt | 57 ++++++++++++++++++++++++++++++++++ 4 files changed, 148 insertions(+), 8 deletions(-) create mode 100644 sapi/cli/tests/gh8827-001.phpt create mode 100644 sapi/cli/tests/gh8827-002.phpt create mode 100644 sapi/cli/tests/gh8827-003.phpt diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 47241f8af4e..0ad53e813c9 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -538,14 +538,6 @@ 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 (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); @@ -553,6 +545,12 @@ 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); diff --git a/sapi/cli/tests/gh8827-001.phpt b/sapi/cli/tests/gh8827-001.phpt new file mode 100644 index 00000000000..fab7b02d9e9 --- /dev/null +++ b/sapi/cli/tests/gh8827-001.phpt @@ -0,0 +1,38 @@ +--TEST-- +std handles can be deliberately closed 001 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +STDIN: +bool(false) +STDERR: +bool(false) +STDOUT: diff --git a/sapi/cli/tests/gh8827-002.phpt b/sapi/cli/tests/gh8827-002.phpt new file mode 100644 index 00000000000..d039896cb1c --- /dev/null +++ b/sapi/cli/tests/gh8827-002.phpt @@ -0,0 +1,47 @@ +--TEST-- +std handles can be deliberately closed 002 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +STDIN: +bool(false) +STDERR: +bool(false) +STDOUT: +bool(false) diff --git a/sapi/cli/tests/gh8827-003.phpt b/sapi/cli/tests/gh8827-003.phpt new file mode 100644 index 00000000000..8c1fc49141f --- /dev/null +++ b/sapi/cli/tests/gh8827-003.phpt @@ -0,0 +1,57 @@ +--TEST-- +std handles can be deliberately closed 003 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +stdoutFile: +Goes to stdoutFile +Also goes to stdoutFile +stderrFile: +Goes to stderrFile From d86141a89195557595aed5654eaa6debe89dc3bd Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Sat, 9 Jul 2022 23:00:52 +0200 Subject: [PATCH 3/3] [ci skip] NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 56fadbef473..f9964e5344a 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.1.9 +- CLI: + . Fixed GH-8952 (Intentionally closing std handles no longer possible). + (Arnaud, cmb) + - Date: . Fixed bug #80047 (DatePeriod doesn't warn with custom DateTimeImmutable). (Derick)