Skip to content

Commit dd578f7

Browse files
committed
Boolify PDO quoter handler
1 parent df21438 commit dd578f7

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

ext/pdo/pdo_stmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2018,7 +2018,7 @@ PHP_METHOD(PDOStatement, getIterator)
20182018
/* {{{ overloaded handlers for PDOStatement class */
20192019
static zval *dbstmt_prop_write(zend_object *object, zend_string *name, zval *value, void **cache_slot)
20202020
{
2021-
if (zend_string_equals_literal(name, "queryString")) {
2021+
if (strcmp(ZSTR_VAL(name), "queryString") == 0) {
20222022
zend_throw_error(NULL, "Property queryString is read only");
20232023
return value;
20242024
} else {

ext/pdo/php_pdo_driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ typedef int (*pdo_dbh_prepare_func)(pdo_dbh_t *dbh, zend_string *sql, pdo_stmt_t
235235
typedef zend_long (*pdo_dbh_do_func)(pdo_dbh_t *dbh, const char *sql, size_t sql_len);
236236

237237
/* quote a string */
238-
typedef int (*pdo_dbh_quote_func)(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype);
238+
typedef bool (*pdo_dbh_quote_func)(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype);
239239

240240
/* transaction related (beingTransaction(), commit, rollBack, inTransaction)
241241
* return true in case of success, false otherwise */

ext/pdo_dblib/dblib_driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_l
145145
return DBCOUNT(H->link);
146146
}
147147

148-
static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype)
148+
static bool dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype)
149149
{
150150
pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data;
151151
zend_bool use_national_character_set = 0;
@@ -192,7 +192,7 @@ static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unqu
192192

193193
*q = 0;
194194

195-
return 1;
195+
return true;
196196
}
197197

198198
static bool pdo_dblib_transaction_cmd(const char *cmd, pdo_dbh_t *dbh)

ext/pdo_firebird/firebird_driver.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ static zend_long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sq
651651
/* }}} */
652652

653653
/* called by the PDO SQL parser to add quotes to values that are copied into SQL */
654-
static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, /* {{{ */
654+
static bool firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, /* {{{ */
655655
char **quoted, size_t *quotedlen, enum pdo_param_type paramtype)
656656
{
657657
int qcount = 0;
@@ -662,7 +662,7 @@ static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t u
662662
*quotedlen = 2;
663663
*quoted = emalloc(*quotedlen+1);
664664
strcpy(*quoted, "''");
665-
return 1;
665+
return true;
666666
}
667667

668668
/* Firebird only requires single quotes to be doubled if string lengths are used */
@@ -686,7 +686,7 @@ static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t u
686686
(*quoted)[*quotedlen-1] = '\'';
687687
(*quoted)[*quotedlen] = '\0';
688688

689-
return 1;
689+
return true;
690690
}
691691
/* }}} */
692692

ext/pdo_mysql/mysql_driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static char *pdo_mysql_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t *
302302
#endif
303303

304304
/* {{{ mysql_handle_quoter */
305-
static int mysql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype )
305+
static bool mysql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype )
306306
{
307307
pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
308308
zend_bool use_national_character_set = 0;
@@ -336,7 +336,7 @@ static int mysql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unqu
336336
(*quoted)[++*quotedlen] = '\'';
337337
(*quoted)[++*quotedlen] = '\0';
338338
PDO_DBG_INF_FMT("quoted=%.*s", (int)*quotedlen, *quoted);
339-
PDO_DBG_RETURN(1);
339+
PDO_DBG_RETURN(true);
340340
}
341341
/* }}} */
342342

ext/pdo_oci/oci_driver.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ static zend_long oci_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_len
354354
}
355355
/* }}} */
356356

357-
static int oci_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype ) /* {{{ */
357+
static bool oci_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype ) /* {{{ */
358358
{
359359
int qcount = 0;
360360
char const *cu, *l, *r;
@@ -364,7 +364,7 @@ static int oci_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquot
364364
*quotedlen = 2;
365365
*quoted = emalloc(*quotedlen+1);
366366
strcpy(*quoted, "''");
367-
return 1;
367+
return true;
368368
}
369369

370370
/* count single quotes */
@@ -387,7 +387,7 @@ static int oci_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquot
387387
(*quoted)[*quotedlen-1] = '\'';
388388
(*quoted)[*quotedlen] = '\0';
389389

390-
return 1;
390+
return true;
391391
}
392392
/* }}} */
393393

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static zend_long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, size_t sql_l
319319
return ret;
320320
}
321321

322-
static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype)
322+
static bool pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype)
323323
{
324324
unsigned char *escaped;
325325
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
@@ -345,7 +345,7 @@ static int pgsql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unqu
345345
(*quoted)[*quotedlen + 2] = '\0';
346346
*quotedlen += 2;
347347
}
348-
return 1;
348+
return true;
349349
}
350350

351351
static char *pdo_pgsql_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t *len)

ext/pdo_sqlite/sqlite_driver.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,12 @@ static char *pdo_sqlite_last_insert_id(pdo_dbh_t *dbh, const char *name, size_t
230230
}
231231

232232
/* NB: doesn't handle binary strings... use prepared stmts for that */
233-
static int sqlite_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype )
233+
static bool sqlite_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unquotedlen, char **quoted, size_t *quotedlen, enum pdo_param_type paramtype )
234234
{
235235
*quoted = safe_emalloc(2, unquotedlen, 3);
236236
sqlite3_snprintf(2*unquotedlen + 3, *quoted, "'%q'", unquoted);
237237
*quotedlen = strlen(*quoted);
238-
return 1;
238+
return true;
239239
}
240240

241241
static bool sqlite_handle_begin(pdo_dbh_t *dbh)

0 commit comments

Comments
 (0)