Skip to content

Commit b0df768

Browse files
committed
pgsqlSetNoticeCallback: cleanup
1 parent 3d4d448 commit b0df768

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *
104104

105105
static void _pdo_pgsql_notice(void *context, const char *message) /* {{{ */
106106
{
107-
zval zarg;
108-
zend_fcall_info_cache *fc;
109107
pdo_dbh_t * dbh = (pdo_dbh_t *)context;
110-
if ((fc = ((pdo_pgsql_db_handle *)dbh->driver_data)->notice_callback)) {
111-
ZVAL_STRINGL(&zarg, (char *) message, strlen(message));
108+
zend_fcall_info_cache *fc = ((pdo_pgsql_db_handle *)dbh->driver_data)->notice_callback;
109+
if (fc) {
110+
zval zarg;
111+
ZVAL_STRING(&zarg, message);
112112
zend_call_known_fcc(fc, NULL, 1, &zarg, NULL);
113-
zval_ptr_dtor(&zarg);
113+
zval_ptr_dtor_str(&zarg);
114114
}
115115
}
116116
/* }}} */
@@ -1242,31 +1242,27 @@ PHP_METHOD(PDO_PGSql_Ext, pgsqlGetPid)
12421242
}
12431243
/* }}} */
12441244

1245-
/* {{{ proto bool PDO::pgsqlSetNoticeCallback(mixed callback)
1245+
/* {{{ proto void PDO::pgsqlSetNoticeCallback(mixed callback)
12461246
Sets a callback to receive DB notices (after client_min_messages has been set) */
12471247
PHP_METHOD(PDO_PGSql_Ext, pgsqlSetNoticeCallback)
12481248
{
1249-
pdo_dbh_t *dbh;
1250-
pdo_pgsql_db_handle *H;
12511249
zend_fcall_info fci = empty_fcall_info;
12521250
zend_fcall_info_cache fcc = empty_fcall_info_cache;
1251+
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "F!", &fci, &fcc)) {
1252+
RETURN_THROWS();
1253+
}
12531254

1254-
dbh = Z_PDO_DBH_P(getThis());
1255+
pdo_dbh_t *dbh = Z_PDO_DBH_P(ZEND_THIS);
12551256
PDO_CONSTRUCT_CHECK;
12561257

1257-
H = (pdo_pgsql_db_handle *)dbh->driver_data;
1258+
pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
12581259

12591260
pdo_pgsql_cleanup_notice_callback(H);
1260-
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "F!", &fci, &fcc)) {
1261-
RETURN_FALSE;
1262-
}
12631261

12641262
if (ZEND_FCC_INITIALIZED(fcc)) {
1265-
H->notice_callback = ecalloc(1, sizeof(zend_fcall_info_cache));
1263+
H->notice_callback = emalloc(sizeof(zend_fcall_info_cache));
12661264
zend_fcc_dup(H->notice_callback, &fcc);
12671265
}
1268-
1269-
RETURN_TRUE;
12701266
}
12711267
/* }}} */
12721268

ext/pdo_pgsql/pgsql_driver.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ public function pgsqlGetNotify(int $fetchMode = PDO::FETCH_DEFAULT, int $timeout
3535
public function pgsqlGetPid(): int {}
3636

3737
/** @tentative-return-type */
38-
public function pgsqlSetNoticeCallback(?callable $callback): bool {}
38+
public function pgsqlSetNoticeCallback(?callable $callback): void {}
3939
}

ext/pdo_pgsql/pgsql_driver_arginfo.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)