[PHP-CVS] [php-src] master: Zend: Use %pS for zend_string in zend_throw_error (#23364)

[email protected] (Arshid via GitHub)
Newsgroups php.cvs
Message-ID <[email protected]>
Author: Arshid (arshidkv12)
Committer: GitHub (web-flow)
Pusher: TimWolla
Date: 2026-08-23T16:08:55+02:00

Commit: https://github.com/php/php-src/commit/46962ddc127336b3fe1c51434619610f60ed8625
Raw diff: https://github.com/php/php-src/commit/46962ddc127336b3fe1c51434619610f60ed8625.diff

Zend: Use %pS for zend_string in zend_throw_error (#23364)

Changed paths:
  M  Zend/zend.c
  M  Zend/zend_partial.c


Diff:

diff --git a/Zend/zend.c b/Zend/zend.c
index 8643c248e6be..1718972e592f 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 ce1604ddc67a..643cc634e7e8 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;
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.