Skip to content

Commit ebee4e7

Browse files
Merge branch 'PHP-8.6'
* PHP-8.6: [`%pS` migration] Use `%pS` in ext/pdo (#23162)
2 parents 754e0b2 + 10e7030 commit ebee4e7

3 files changed

Lines changed: 35 additions & 35 deletions

File tree

‎ext/pdo/pdo_dbh.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, pdo_error_type sqlst
9797
}
9898

9999
if (dbh->error_mode != PDO_ERRMODE_EXCEPTION) {
100-
php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(message));
100+
php_error_docref(NULL, E_WARNING, "%pS", message);
101101
} else {
102102
zval ex, info;
103103
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) /* {{{ */
172172
}
173173

174174
if (dbh->error_mode == PDO_ERRMODE_WARNING) {
175-
php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(message));
175+
php_error_docref(NULL, E_WARNING, "%pS", message);
176176
} else if (EG(exception) == NULL) {
177177
zval ex;
178178
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
233233
if (ce_based_on_driver_name) {
234234
if (!instanceof_function(ce_based_on_called_object, ce_based_on_driver_name)) {
235235
zend_throw_exception_ex(pdo_exception_ce, 0,
236-
"%s::%s() cannot be used for connecting to the \"%s\" driver, "
237-
"either call %s::%s() or PDO::%s() instead",
238-
ZSTR_VAL(called_scope->name),
236+
"%pS::%s() cannot be used for connecting to the \"%s\" driver, "
237+
"either call %pS::%s() or PDO::%s() instead",
238+
called_scope->name,
239239
new_zval_object ? "connect" : "__construct",
240240
driver->driver_name,
241-
ZSTR_VAL(ce_based_on_driver_name->name),
241+
ce_based_on_driver_name->name,
242242
new_zval_object ? "connect" : "__construct",
243243
new_zval_object ? "connect" : "__construct"
244244
);
@@ -252,9 +252,9 @@ static bool create_driver_specific_pdo_object(pdo_driver_t *driver, zend_class_e
252252
return true;
253253
} else {
254254
zend_throw_exception_ex(pdo_exception_ce, 0,
255-
"%s::%s() cannot be used for connecting to an unknown driver, "
255+
"%pS::%s() cannot be used for connecting to an unknown driver, "
256256
"call PDO::%s() instead",
257-
ZSTR_VAL(called_scope->name),
257+
called_scope->name,
258258
new_zval_object ? "connect" : "__construct",
259259
new_zval_object ? "connect" : "__construct"
260260
);
@@ -271,12 +271,12 @@ static bool create_driver_specific_pdo_object(pdo_driver_t *driver, zend_class_e
271271
if (called_scope != pdo_dbh_ce) {
272272
/* A driver-specific implementation is instantiated with a wrong driver class */
273273
zend_throw_exception_ex(pdo_exception_ce, 0,
274-
"%s::%s() cannot be used for connecting to the \"%s\" driver, "
275-
"either call %s::%s() or PDO::%s() instead",
276-
ZSTR_VAL(called_scope->name),
274+
"%pS::%s() cannot be used for connecting to the \"%s\" driver, "
275+
"either call %pS::%s() or PDO::%s() instead",
276+
called_scope->name,
277277
new_zval_object ? "connect" : "__construct",
278278
driver->driver_name,
279-
ZSTR_VAL(ce_based_on_driver_name->name),
279+
ce_based_on_driver_name->name,
280280
new_zval_object ? "connect" : "__construct",
281281
new_zval_object ? "connect" : "__construct"
282282
);

‎ext/pdo/pdo_stmt.c‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define PHP_STMT_GET_OBJ \
3636
pdo_stmt_t *stmt = Z_PDO_STMT_P(ZEND_THIS); \
3737
if (!stmt->dbh) { \
38-
zend_throw_error(NULL, "%s object is uninitialized", ZSTR_VAL(Z_OBJ(EX(This))->ce->name)); \
38+
zend_throw_error(NULL, "%pS object is uninitialized", Z_OBJ(EX(This))->ce->name); \
3939
RETURN_THROWS(); \
4040
} \
4141

@@ -293,7 +293,7 @@ static bool really_register_bound_param(struct pdo_bound_param_data *param, pdo_
293293
/* if you prepare and then execute passing an array of params keyed by names,
294294
* then this will trigger, and we don't want that */
295295
if (param->paramno == -1) {
296-
zend_argument_value_error(1, "must refer to a column present in the result set, \"%s\" given", ZSTR_VAL(param->name));
296+
zend_argument_value_error(1, "must refer to a column present in the result set, \"%pS\" given", param->name);
297297
return false;
298298
}
299299
}
@@ -1208,8 +1208,8 @@ PHP_METHOD(PDOStatement, fetchAll)
12081208
case PDO_FETCH_FUNC: /* Cannot be a default fetch mode */
12091209
if (ZEND_NUM_ARGS() != 2) {
12101210
zend_string *func = get_active_function_or_method_name();
1211-
zend_argument_count_error("%s() expects exactly 2 argument for PDO::FETCH_FUNC, %d given",
1212-
ZSTR_VAL(func), ZEND_NUM_ARGS());
1211+
zend_argument_count_error("%pS() expects exactly 2 argument for PDO::FETCH_FUNC, %d given",
1212+
func, ZEND_NUM_ARGS());
12131213
zend_string_release(func);
12141214
RETURN_THROWS();
12151215
}
@@ -1221,8 +1221,8 @@ PHP_METHOD(PDOStatement, fetchAll)
12211221
case PDO_FETCH_COLUMN:
12221222
if (ZEND_NUM_ARGS() > 2) {
12231223
zend_string *func = get_active_function_or_method_name();
1224-
zend_argument_count_error("%s() expects at most 2 argument for the fetch mode provided, %d given",
1225-
ZSTR_VAL(func), ZEND_NUM_ARGS());
1224+
zend_argument_count_error("%pS() expects at most 2 argument for the fetch mode provided, %d given",
1225+
func, ZEND_NUM_ARGS());
12261226
zend_string_release(func);
12271227
RETURN_THROWS();
12281228
}
@@ -1247,8 +1247,8 @@ PHP_METHOD(PDOStatement, fetchAll)
12471247
/* No support for PDO_FETCH_INTO which takes 2 args??? */
12481248
if (ZEND_NUM_ARGS() > 1) {
12491249
zend_string *func = get_active_function_or_method_name();
1250-
zend_argument_count_error("%s() expects exactly 1 argument for the fetch mode provided, %d given",
1251-
ZSTR_VAL(func), ZEND_NUM_ARGS());
1250+
zend_argument_count_error("%pS() expects exactly 1 argument for the fetch mode provided, %d given",
1251+
func, ZEND_NUM_ARGS());
12521252
zend_string_release(func);
12531253
RETURN_THROWS();
12541254
}
@@ -1665,8 +1665,8 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
16651665
case PDO_FETCH_KEY_PAIR:
16661666
if (variadic_num_args != 0) {
16671667
zend_string *func = get_active_function_or_method_name();
1668-
zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given",
1669-
ZSTR_VAL(func), mode_arg_num, total_num_args);
1668+
zend_argument_count_error("%pS() expects exactly %d arguments for the fetch mode provided, %d given",
1669+
func, mode_arg_num, total_num_args);
16701670
zend_string_release(func);
16711671
return false;
16721672
}
@@ -1675,8 +1675,8 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
16751675
case PDO_FETCH_COLUMN:
16761676
if (variadic_num_args != 1) {
16771677
zend_string *func = get_active_function_or_method_name();
1678-
zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given",
1679-
ZSTR_VAL(func), arg1_arg_num, total_num_args);
1678+
zend_argument_count_error("%pS() expects exactly %d arguments for the fetch mode provided, %d given",
1679+
func, arg1_arg_num, total_num_args);
16801680
zend_string_release(func);
16811681
return false;
16821682
}
@@ -1696,25 +1696,25 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
16961696
if ((flags & PDO_FETCH_CLASSTYPE) == PDO_FETCH_CLASSTYPE) {
16971697
if (variadic_num_args != 0) {
16981698
zend_string *func = get_active_function_or_method_name();
1699-
zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given",
1700-
ZSTR_VAL(func), mode_arg_num, total_num_args);
1699+
zend_argument_count_error("%pS() expects exactly %d arguments for the fetch mode provided, %d given",
1700+
func, mode_arg_num, total_num_args);
17011701
zend_string_release(func);
17021702
return false;
17031703
}
17041704
} else {
17051705
zend_class_entry *cep;
17061706
if (variadic_num_args == 0) {
17071707
zend_string *func = get_active_function_or_method_name();
1708-
zend_argument_count_error("%s() expects at least %d arguments for the fetch mode provided, %d given",
1709-
ZSTR_VAL(func), arg1_arg_num, total_num_args);
1708+
zend_argument_count_error("%pS() expects at least %d arguments for the fetch mode provided, %d given",
1709+
func, arg1_arg_num, total_num_args);
17101710
zend_string_release(func);
17111711
return false;
17121712
}
17131713
/* constructor_arguments can be null/not passed */
17141714
if (variadic_num_args > 2) {
17151715
zend_string *func = get_active_function_or_method_name();
1716-
zend_argument_count_error("%s() expects at most %d arguments for the fetch mode provided, %d given",
1717-
ZSTR_VAL(func), constructor_arg_num, total_num_args);
1716+
zend_argument_count_error("%pS() expects at most %d arguments for the fetch mode provided, %d given",
1717+
func, constructor_arg_num, total_num_args);
17181718
zend_string_release(func);
17191719
return false;
17201720
}
@@ -1749,8 +1749,8 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
17491749
case PDO_FETCH_INTO:
17501750
if (total_num_args != arg1_arg_num) {
17511751
zend_string *func = get_active_function_or_method_name();
1752-
zend_argument_count_error("%s() expects exactly %d arguments for the fetch mode provided, %d given",
1753-
ZSTR_VAL(func), arg1_arg_num, total_num_args);
1752+
zend_argument_count_error("%pS() expects exactly %d arguments for the fetch mode provided, %d given",
1753+
func, arg1_arg_num, total_num_args);
17541754
zend_string_release(func);
17551755
return false;
17561756
}
@@ -2228,7 +2228,7 @@ zend_object_iterator *pdo_stmt_iter_get(zend_class_entry *ce, zval *object, int
22282228

22292229
pdo_stmt_t *stmt = Z_PDO_STMT_P(object);
22302230
if (!stmt->dbh) {
2231-
zend_throw_error(NULL, "%s object is uninitialized", ZSTR_VAL(ce->name));
2231+
zend_throw_error(NULL, "%pS object is uninitialized", ce->name);
22322232
return NULL;
22332233
}
22342234

@@ -2294,7 +2294,7 @@ static zval *row_prop_read(zend_object *object, zend_string *name, int type, voi
22942294
// if (is_numeric) {
22952295
// zend_value_error("Invalid column index");
22962296
// } else {
2297-
// zend_throw_error(NULL, "No column named \"%s\" exists", ZSTR_VAL(name));
2297+
// zend_throw_error(NULL, "No column named \"%pS\" exists", name);
22982298
// }
22992299
//}
23002300
//return &EG(uninitialized_zval);

‎ext/pdo/php_pdo.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static inline void pdo_declare_deprecated_class_constant_long(
9898
#define PDO_CONSTRUCT_CHECK_COND dbh->driver
9999
#define PDO_CONSTRUCT_CHECK_FAIL() \
100100
{ \
101-
zend_throw_error(NULL, "%s object is uninitialized", ZSTR_VAL(Z_OBJ(EX(This))->ce->name)); \
101+
zend_throw_error(NULL, "%pS object is uninitialized", Z_OBJ(EX(This))->ce->name); \
102102
} \
103103

104104
#define PDO_CONSTRUCT_CHECK \

0 commit comments

Comments
 (0)