Commit 9ccd4bc7fd4 for php
commit 9ccd4bc7fd4ca2c4761f2a2897d76debfacb4b57
Author: Gina Peter Banyard <girgias@php.net>
Date: Wed Nov 4 14:43:33 2026 +0000
tree: use %pS format specifier rather than %S
Allowing us to use the checked version of the functions.
The only remaining usages of *_unchecked() are for the %H float specifier.
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 5ecee520cd1..62cff0c4466 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4195,9 +4195,9 @@ static zend_string *zend_compile_partial_name(const zend_op_array *declaring_op_
}
}
- zend_string *name = zend_strpprintf_unchecked(
+ zend_string *name = zend_strpprintf(
0,
- "{closure:pfa:%S%S%S%s:%" PRIu32 "}",
+ "{closure:pfa:%pS%pS%pS%s:%" PRIu32 "}",
class,
separator,
function,
@@ -6119,7 +6119,7 @@ static void zend_compile_static_var(zend_ast *ast) /* {{{ */
}
if (zend_hash_exists(CG(active_op_array)->static_variables, var_name)) {
- zend_error_noreturn_unchecked(E_COMPILE_ERROR, "Duplicate declaration of static variable $%S", var_name);
+ zend_error_noreturn(E_COMPILE_ERROR, "Duplicate declaration of static variable $%pS", var_name);
}
zend_eval_const_expr(&ast->child[1]);
@@ -8921,8 +8921,8 @@ static void zend_compile_closure_uses(zend_ast *ast) /* {{{ */
int i;
for (i = 0; i < op_array->last_var; i++) {
if (zend_string_equals(op_array->vars[i], var_name)) {
- zend_error_noreturn_unchecked(E_COMPILE_ERROR,
- "Cannot use lexical variable $%S as a parameter name", var_name);
+ zend_error_noreturn(E_COMPILE_ERROR,
+ "Cannot use lexical variable $%pS as a parameter name", var_name);
}
}
}
@@ -9094,9 +9094,9 @@ static zend_string *zend_begin_func_decl(znode *result, zend_op_array *op_array,
}
}
- unqualified_name = zend_strpprintf_unchecked(
+ unqualified_name = zend_strpprintf(
0,
- "{closure:%S%S%S%s:%" PRIu32 "}",
+ "{closure:%pS%pS%pS%s:%" PRIu32 "}",
class,
separator,
function,
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 885b7672678..ac0e07fba5b 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -4249,7 +4249,7 @@ static zend_never_inline void zend_fetch_this_var(int type OPLINE_DC EXECUTE_DAT
Z_ADDREF_P(result);
} else {
ZVAL_NULL(result);
- zend_error_unchecked(E_WARNING, "Undefined variable $this");
+ zend_error(E_WARNING, "Undefined variable $this");
}
break;
case BP_VAR_IS:
diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c
index f952450cfbb..5ae69daf43a 100644
--- a/ext/opcache/jit/zend_jit_helpers.c
+++ b/ext/opcache/jit/zend_jit_helpers.c
@@ -103,7 +103,7 @@ static ZEND_COLD void ZEND_FASTCALL zend_jit_invalid_method_call(zval *object)
if (Z_TYPE_P(object) == IS_UNDEF && opline->op1_type == IS_CV) {
zend_string *cv = EX(func)->op_array.vars[EX_VAR_TO_NUM(opline->op1.var)];
- zend_error_unchecked(E_WARNING, "Undefined variable $%S", cv);
+ zend_error(E_WARNING, "Undefined variable $%pS", cv);
if (UNEXPECTED(EG(exception) != NULL)) {
return;
}
@@ -429,7 +429,7 @@ static int ZEND_FASTCALL zend_jit_undefined_op_helper(uint32_t var)
const zend_execute_data *execute_data = EG(current_execute_data);
zend_string *cv = EX(func)->op_array.vars[EX_VAR_TO_NUM(var)];
- zend_error_unchecked(E_WARNING, "Undefined variable $%S", cv);
+ zend_error(E_WARNING, "Undefined variable $%pS", cv);
return EG(exception) == NULL;
}
@@ -443,7 +443,7 @@ static int ZEND_FASTCALL zend_jit_undefined_op_helper_write(HashTable *ht, uint3
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE)) {
GC_ADDREF(ht);
}
- zend_error_unchecked(E_WARNING, "Undefined variable $%S", cv);
+ zend_error(E_WARNING, "Undefined variable $%pS", cv);
if (!(GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE) && GC_DELREF(ht) != 1) {
if (!GC_REFCOUNT(ht)) {
zend_array_destroy(ht);
@@ -2677,7 +2677,7 @@ static void ZEND_FASTCALL zend_jit_invalid_property_incdec(zval *container, zend
if (Z_TYPE_P(container) == IS_UNDEF && opline->op1_type == IS_CV) {
zend_string *cv = EX(func)->op_array.vars[EX_VAR_TO_NUM(opline->op1.var)];
- zend_error_unchecked(E_WARNING, "Undefined variable $%S", cv);
+ zend_error(E_WARNING, "Undefined variable $%pS", cv);
}
if (opline->result_type & (IS_VAR|IS_TMP_VAR)) {
ZVAL_UNDEF(EX_VAR(opline->result.var));
diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c
index 1cee1025c60..4a4859ed6af 100644
--- a/ext/opcache/jit/zend_jit_ir.c
+++ b/ext/opcache/jit/zend_jit_ir.c
@@ -4972,7 +4972,7 @@ static int zend_jit_inc_dec(zend_jit_ctx *jit, const zend_op *opline, uint32_t o
if_def = jit_if_not_Z_TYPE(jit, op1_addr, IS_UNDEF);
ir_IF_FALSE_cold(if_def);
- // zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var)));
+ // zend_error(E_WARNING, "Undefined variable $%pS", CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var)));
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(opline->op1.var));
jit_set_Z_TYPE_INFO(jit, op1_def_addr, IS_NULL);
@@ -5930,7 +5930,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit,
if_def = jit_if_not_Z_TYPE(jit, op1_addr, IS_UNDEF);
ir_IF_FALSE_cold(if_def);
- // zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var)));
+ // zend_error(E_WARNING, "Undefined variable $%pS", CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var)));
jit_SET_EX_OPLINE(jit, opline);
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(opline->op1.var));
@@ -5947,7 +5947,7 @@ static int zend_jit_long_math_helper(zend_jit_ctx *jit,
if_def = jit_if_not_Z_TYPE(jit, op2_addr, IS_UNDEF);
ir_IF_FALSE_cold(if_def);
- // zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op2.var)));
+ // zend_error(E_WARNING, "Undefined variable $%pS", CV_DEF_OF(EX_VAR_TO_NUM(opline->op2.var)));
jit_SET_EX_OPLINE(jit, opline);
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(opline->op2.var));
@@ -6351,7 +6351,7 @@ static int zend_jit_simple_assign(zend_jit_ctx *jit,
jit_SET_EX_OPLINE(jit, opline);
ZEND_ASSERT(Z_MODE(val_addr) == IS_MEM_ZVAL);
- // zend_error_unchecked(E_WARNING, "Undefined variable $%S", CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var)));
+ // zend_error(E_WARNING, "Undefined variable $%pS", CV_DEF_OF(EX_VAR_TO_NUM(opline->op1.var)));
ret = ir_CALL_1(IR_I32, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(Z_OFFSET(val_addr)));
if (check_exception) {
diff --git a/main/main.c b/main/main.c
index ee7d1cca69b..a8cdff9ff68 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1242,15 +1242,15 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, int type, const char *forma
}
/* display html formatted or only show the additional links */
if (PG(html_errors)) {
- message = zend_strpprintf_unchecked(0, "%s [<a href='%s%s%s'>%s</a>]: %S", origin, docref_root, docref, docref_target, docref, buffer);
+ message = zend_strpprintf(0, "%s [<a href='%s%s%s'>%s</a>]: %pS", origin, docref_root, docref, docref_target, docref, buffer);
} else {
- message = zend_strpprintf_unchecked(0, "%s [%s%s%s]: %S", origin, docref_root, docref, docref_target, buffer);
+ message = zend_strpprintf(0, "%s [%s%s%s]: %pS", origin, docref_root, docref, docref_target, buffer);
}
if (target) {
efree(target);
}
} else {
- message = zend_strpprintf_unchecked(0, "%s: %S", origin, buffer);
+ message = zend_strpprintf(0, "%s: %pS", origin, buffer);
}
if (replace_origin) {
zend_string_free(replace_origin);
@@ -1461,7 +1461,7 @@ static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename, c
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%" PRIu32 "</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(buf), ZSTR_VAL(error_filename), error_lineno, STR_PRINT(append_string));
zend_string_free(buf);
} else {
- php_printf_unchecked("%s<br />\n<b>%s</b>: %S in <b>%s</b> on line <b>%" PRIu32 "</b><br />%s%s\n%s", STR_PRINT(prepend_string), error_type_str, message, ZSTR_VAL(error_filename), error_lineno, ZSTR_LEN(backtrace) ? "\nStack trace:\n" : "", ZSTR_VAL(backtrace), STR_PRINT(append_string));
+ php_printf("%s<br />\n<b>%s</b>: %pS in <b>%s</b> on line <b>%" PRIu32 "</b><br />%s%s\n%s", STR_PRINT(prepend_string), error_type_str, message, ZSTR_VAL(error_filename), error_lineno, ZSTR_LEN(backtrace) ? "\nStack trace:\n" : "", ZSTR_VAL(backtrace), STR_PRINT(append_string));
}
} else {
/* Write CLI/CGI errors to stderr if display_errors = "stderr" */
@@ -1475,7 +1475,7 @@ static ZEND_COLD void php_error_cb(int orig_type, zend_string *error_filename, c
fflush(stderr);
#endif
} else {
- php_printf_unchecked("%s\n%s: %S in %s on line %" PRIu32 "%s%s\n%s", STR_PRINT(prepend_string), error_type_str, message, ZSTR_VAL(error_filename), error_lineno, ZSTR_LEN(backtrace) ? "\nStack trace:\n" : "", ZSTR_VAL(backtrace), STR_PRINT(append_string));
+ php_printf("%s\n%s: %pS in %s on line %" PRIu32 "%s%s\n%s", STR_PRINT(prepend_string), error_type_str, message, ZSTR_VAL(error_filename), error_lineno, ZSTR_LEN(backtrace) ? "\nStack trace:\n" : "", ZSTR_VAL(backtrace), STR_PRINT(append_string));
}
}
}