Commit 10e7030db65 for php
commit 10e7030db6529f05ea7f8d933c59d9e35940570b
Author: Daniel Scherzer <daniel.e.scherzer@gmail.com>
Date: Sun Nov 15 09:59:36 2026 -0800
[`%pS` migration] Use `%pS` in ext/pdo (#23162)
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index 9ccaebd5e8b..3ed5693b9f7 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -97,7 +97,7 @@ void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, pdo_error_type sqlst
}
if (dbh->error_mode != PDO_ERRMODE_EXCEPTION) {
- php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(message));
+ php_error_docref(NULL, E_WARNING, "%pS", message);
} else {
zval ex, info;
zend_class_entry *pdo_ex = php_pdo_get_exception();
@@ -172,7 +172,7 @@ PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt) /* {{{ */
}
if (dbh->error_mode == PDO_ERRMODE_WARNING) {
- php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(message));
+ php_error_docref(NULL, E_WARNING, "%pS", message);
} else if (EG(exception) == NULL) {
zval ex;
zend_class_entry *pdo_ex = php_pdo_get_exception();
@@ -233,12 +233,12 @@ static bool create_driver_specific_pdo_object(pdo_driver_t *driver, zend_class_e
if (ce_based_on_driver_name) {
if (!instanceof_function(ce_based_on_called_object, ce_based_on_driver_name)) {
zend_throw_exception_ex(pdo_exception_ce, 0,
- "%s::%s() cannot be used for connecting to the \"%s\" driver, "
- "either call %s::%s() or PDO::%s() instead",
- ZSTR_VAL(called_scope->name),
+ "%pS::%s() cannot be used for connecting to the \"%s\" driver, "
+ "either call %pS::%s() or PDO::%s() instead",
+ called_scope->name,
new_zval_object ? "connect" : "__construct",
driver->driver_name,
- ZSTR_VAL(ce_based_on_driver_name->name),
+ ce_based_on_driver_name->name,
new_zval_object ? "connect" : "__construct",
new_zval_object ? "connect" : "__construct"
);
@@ -252,9 +252,9 @@ static bool create_driver_specific_pdo_object(pdo_driver_t *driver, zend_class_e
return true;
} else {
zend_throw_exception_ex(pdo_exception_ce, 0,
- "%s::%s() cannot be used for connecting to an unknown driver, "
+ "%pS::%s() cannot be used for connecting to an unknown driver, "
"call PDO::%s() instead",
- ZSTR_VAL(called_scope->name),
+ called_scope->name,
new_zval_object ? "connect" : "__construct",
new_zval_object ? "connect" : "__construct"
);
@@ -271,12 +271,12 @@ static bool create_driver_specific_pdo_object(pdo_driver_t *driver, zend_class_e
if (called_scope != pdo_dbh_ce) {
/* A driver-specific implementation is instantiated with a wrong driver class */
zend_throw_exception_ex(pdo_exception_ce, 0,
- "%s::%s() cannot be used for connecting to the \"%s\" driver, "
- "either call %s::%s() or PDO::%s() instead",
- ZSTR_VAL(called_scope->name),
+ "%pS::%s() cannot be used for connecting to the \"%s\" driver, "
+ "either call %pS::%s() or PDO::%s() instead",
+ called_scope->name,
new_zval_object ? "connect" : "__construct",
driver->driver_name,
- ZSTR_VAL(ce_based_on_driver_name->name),
+ ce_based_on_driver_name->name,
new_zval_object ? "connect" : "__construct",
new_zval_object ? "connect" : "__construct"
);
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index 76ef0a0f5c6..e701dff3f0c 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -35,7 +35,7 @@
#define PHP_STMT_GET_OBJ \
pdo_stmt_t *stmt = Z_PDO_STMT_P(ZEND_THIS); \
if (!stmt->dbh) { \
- zend_throw_error(NULL, "%s object is uninitialized", ZSTR_VAL(Z_OBJ(EX(This))->ce->name)); \
+ zend_throw_error(NULL, "%pS object is uninitialized", Z_OBJ(EX(This))->ce->name); \
RETURN_THROWS(); \
} \
@@ -309,7 +309,7 @@ static bool really_register_bound_param(struct pdo_bound_param_data *param, pdo_
/* Should this always be an Error? */
char *tmp;
/* TODO Error? */
- spprintf(&tmp, 0, "Did not find column name '%s' in the defined columns; it will not be bound", ZSTR_VAL(param->name));
+ spprintf(&tmp, 0, "Did not find column name '%pS' in the defined columns; it will not be bound", param->name);
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", tmp);
efree(tmp);
return false;
@@ -1213,8 +1213,8 @@ PHP_METHOD(PDOStatement, fetchAll)
case PDO_FETCH_FUNC: /* Cannot be a default fetch mode */
if (ZEND_NUM_ARGS() != 2) {
zend_string *func = get_active_function_or_method_name();
- zend_argument_count_error("%s() expects exactly 2 argument for PDO::FETCH_FUNC, %d given",
- ZSTR_VAL(func), ZEND_NUM_ARGS());
+ zend_argument_count_error("%pS() expects exactly 2 argument for PDO::FETCH_FUNC, %d given",
+ func, ZEND_NUM_ARGS());
zend_string_release(func);
RETURN_THROWS();
}
@@ -1226,8 +1226,8 @@ PHP_METHOD(PDOStatement, fetchAll)
case PDO_FETCH_COLUMN:
if (ZEND_NUM_ARGS() > 2) {
zend_string *func = get_active_function_or_method_name();
- zend_argument_count_error("%s() expects at most 2 argument for the fetch mode provided, %d given",
- ZSTR_VAL(func), ZEND_NUM_ARGS());
+ zend_argument_count_error("%pS() expects at most 2 argument for the fetch mode provided, %d given",
+ func, ZEND_NUM_ARGS());
zend_string_release(func);
RETURN_THROWS();
}
@@ -1252,8 +1252,8 @@ PHP_METHOD(PDOStatement, fetchAll)
/* No support for PDO_FETCH_INTO which takes 2 args??? */
if (ZEND_NUM_ARGS() > 1) {
zend_string *func = get_active_function_or_method_name();
- zend_argument_count_error("%s() expects exactly 1 argument for the fetch mode provided, %d given",
- ZSTR_VAL(func), ZEND_NUM_ARGS());
+ zend_argument_count_error("%pS() expects exactly 1 argument for the fetch mode provided, %d given",
+ func, ZEND_NUM_ARGS());
zend_string_release(func);
RETURN_THROWS();
}
@@ -1670,8 +1670,8 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
case PDO_FETCH_KEY_PAIR:
if (variadic_num_args != 0) {
zend_string *func = get_active_function_or_method_name();
- zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given",
- ZSTR_VAL(func), mode_arg_num, total_num_args);
+ zend_argument_count_error("%pS() expects exactly %d arguments for the fetch mode provided, %d given",
+ func, mode_arg_num, total_num_args);
zend_string_release(func);
return false;
}
@@ -1680,8 +1680,8 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
case PDO_FETCH_COLUMN:
if (variadic_num_args != 1) {
zend_string *func = get_active_function_or_method_name();
- zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given",
- ZSTR_VAL(func), arg1_arg_num, total_num_args);
+ zend_argument_count_error("%pS() expects exactly %d arguments for the fetch mode provided, %d given",
+ func, arg1_arg_num, total_num_args);
zend_string_release(func);
return false;
}
@@ -1701,8 +1701,8 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
if ((flags & PDO_FETCH_CLASSTYPE) == PDO_FETCH_CLASSTYPE) {
if (variadic_num_args != 0) {
zend_string *func = get_active_function_or_method_name();
- zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given",
- ZSTR_VAL(func), mode_arg_num, total_num_args);
+ zend_argument_count_error("%pS() expects exactly %d arguments for the fetch mode provided, %d given",
+ func, mode_arg_num, total_num_args);
zend_string_release(func);
return false;
}
@@ -1710,16 +1710,16 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
zend_class_entry *cep;
if (variadic_num_args == 0) {
zend_string *func = get_active_function_or_method_name();
- zend_argument_count_error("%s() expects at least %d arguments for the fetch mode provided, %d given",
- ZSTR_VAL(func), arg1_arg_num, total_num_args);
+ zend_argument_count_error("%pS() expects at least %d arguments for the fetch mode provided, %d given",
+ func, arg1_arg_num, total_num_args);
zend_string_release(func);
return false;
}
/* constructor_arguments can be null/not passed */
if (variadic_num_args > 2) {
zend_string *func = get_active_function_or_method_name();
- zend_argument_count_error("%s() expects at most %d arguments for the fetch mode provided, %d given",
- ZSTR_VAL(func), constructor_arg_num, total_num_args);
+ zend_argument_count_error("%pS() expects at most %d arguments for the fetch mode provided, %d given",
+ func, constructor_arg_num, total_num_args);
zend_string_release(func);
return false;
}
@@ -1754,8 +1754,8 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
case PDO_FETCH_INTO:
if (total_num_args != arg1_arg_num) {
zend_string *func = get_active_function_or_method_name();
- zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given",
- ZSTR_VAL(func), arg1_arg_num, total_num_args);
+ zend_argument_count_error("%pS() expects exactly %d arguments for the fetch mode provided, %d given",
+ func, arg1_arg_num, total_num_args);
zend_string_release(func);
return false;
}
@@ -2234,7 +2234,7 @@ zend_object_iterator *pdo_stmt_iter_get(zend_class_entry *ce, zval *object, int
pdo_stmt_t *stmt = Z_PDO_STMT_P(object);
if (!stmt->dbh) {
- zend_throw_error(NULL, "%s object is uninitialized", ZSTR_VAL(ce->name));
+ zend_throw_error(NULL, "%pS object is uninitialized", ce->name);
return NULL;
}
@@ -2300,7 +2300,7 @@ static zval *row_prop_read(zend_object *object, zend_string *name, int type, voi
// if (is_numeric) {
// zend_value_error("Invalid column index");
// } else {
- // zend_throw_error(NULL, "No column named \"%s\" exists", ZSTR_VAL(name));
+ // zend_throw_error(NULL, "No column named \"%pS\" exists", name);
// }
//}
//return &EG(uninitialized_zval);
diff --git a/ext/pdo/php_pdo.h b/ext/pdo/php_pdo.h
index 39443bb35c8..aee43b7a3e1 100644
--- a/ext/pdo/php_pdo.h
+++ b/ext/pdo/php_pdo.h
@@ -98,7 +98,7 @@ static inline void pdo_declare_deprecated_class_constant_long(
#define PDO_CONSTRUCT_CHECK_COND dbh->driver
#define PDO_CONSTRUCT_CHECK_FAIL() \
{ \
- zend_throw_error(NULL, "%s object is uninitialized", ZSTR_VAL(Z_OBJ(EX(This))->ce->name)); \
+ zend_throw_error(NULL, "%pS object is uninitialized", Z_OBJ(EX(This))->ce->name); \
} \
#define PDO_CONSTRUCT_CHECK \