Commit 46962ddc127 for php.net
commit 46962ddc127336b3fe1c51434619610f60ed8625
Author: Arshid <arshidkv12@gmail.com>
Date: Sun Aug 23 19:38:55 2026 +0530
Zend: Use %pS for zend_string in zend_throw_error (#23364)
diff --git a/Zend/zend.c b/Zend/zend.c
index 8643c248e6b..1718972e592 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -1830,11 +1830,7 @@ ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const c
//TODO: we can't convert compile-time errors to exceptions yet???
if (EG(current_execute_data) && !CG(in_compilation)) {
- // %S is used for zend_string pointers by smart str printing, but normally
- // is for wide character strings and so compilers complain if this is inline
- // Use "%S" so that the message can contain null bytes.
- const char *format = "%S";
- zend_throw_exception_ex(exception_ce, 0, format, message);
+ zend_throw_exception_ex(exception_ce, 0, "%pS", message);
} else {
zend_error_noreturn(E_ERROR, "%s", ZSTR_VAL(message));
}
diff --git a/Zend/zend_partial.c b/Zend/zend_partial.c
index ce1604ddc67..643cc634e7e 100644
--- a/Zend/zend_partial.c
+++ b/Zend/zend_partial.c
@@ -701,8 +701,7 @@ static zend_op_array *zp_compile(zval *this_ptr, zend_function *function,
zend_op_array *op_array = NULL;
if (UNEXPECTED(function->common.fn_flags2 & ZEND_ACC2_FORBID_DYN_CALLS)) {
- const char *format = "Cannot call %S() dynamically";
- zend_throw_error(NULL, format, function->common.function_name);
+ zend_throw_error(NULL, "Cannot call %pS() dynamically", function->common.function_name);
return NULL;
}