[php-src] PHP-8.6: [`%pS` migration] Use `%pS` in ext/standard/head.c

From: Date: Sun, 01 Nov 2026 20:32:08 +0000
Subject: [php-src] PHP-8.6: [`%pS` migration] Use `%pS` in ext/standard/head.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143181@lists.php.net to get a copy of this message
Author: Daniel Scherzer (DanielEScherzer) Date: 2026-11-01T12:30:51-08:00 Commit: https://github.com/php/php-src/commit/8b9336375801fb86e3ad1a0a6ef1f431f26bdb62 Raw diff: https://github.com/php/php-src/commit/8b9336375801fb86e3ad1a0a6ef1f431f26bdb62.diff [%pS migration] Use %pS in ext/standard/head.c In addition to the fixes within the head.c file, support for error strings with null bytes was added to zend_value_error(). Changed paths: M Zend/zend.c M ext/standard/head.c M ext/standard/tests/file/fscanf_error.phpt Diff: diff --git a/Zend/zend.c b/Zend/zend.c index e9ec8e0e61f6..ad08fe1a630d 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1900,12 +1900,11 @@ ZEND_API ZEND_COLD void zend_argument_count_error(const char *format, ...) /* {{ ZEND_API ZEND_COLD void zend_value_error(const char *format, ...) /* {{{ */ { va_list va; - char *message = NULL; va_start(va, format); - zend_vspprintf(&message, 0, format, va); - zend_throw_exception(zend_ce_value_error, message, 0); - efree(message); + zend_string *message = zend_vstrpprintf(0, format, va); + zend_throw_exception_ex(zend_ce_value_error, 0, "%pS", message); + zend_string_release(message); va_end(va); } /* }}} */ diff --git a/ext/standard/head.c b/ext/standard/head.c index ba97a215427f..2d7197488a81 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -247,7 +247,7 @@ static zend_result php_head_parse_cookie_options_array(HashTable *options, zend_ } else if (zend_string_equals_literal_ci(key, "partitioned")) { *partitioned = zend_is_true(value); } else { - zend_value_error("%s(): option \"%s\" is invalid", get_active_function_name(), ZSTR_VAL(key)); + zend_value_error("%s(): option \"%pS\" is invalid", get_active_function_name(), key); return FAILURE; } } ZEND_HASH_FOREACH_END(); diff --git a/ext/standard/tests/file/fscanf_error.phpt b/ext/standard/tests/file/fscanf_error.phpt index fe30b36b4a53..cd88f576f646 100644 --- a/ext/standard/tests/file/fscanf_error.phpt +++ b/ext/standard/tests/file/fscanf_error.phpt @@ -55,14 +55,14 @@ $file_path = __DIR__; $filename = "$file_path/fscanf_error.tmp"; unlink($filename); ?> ---EXPECT-- +--EXPECTF-- *** Testing fscanf() for error conditions *** TypeError: fscanf(): supplied resource is not a valid File-Handle resource ValueError: Different numbers of variable names and field specifiers array(0) { } -ValueError: Bad scan conversion character " -ValueError: Bad scan conversion character " +ValueError: Bad scan conversion character "%0" +ValueError: Bad scan conversion character "%0" ValueError: Bad scan conversion character "." ValueError: Bad scan conversion character "m"

« previous php.cvs (#143181) next »