Skip to content

Commit 9a55b89

Browse files
committed
pgsqlSetNoticeCallback: cleanup
1 parent 3d4d448 commit 9a55b89

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const char *
105105
static void _pdo_pgsql_notice(void *context, const char *message) /* {{{ */
106106
{
107107
zval zarg;
108-
zend_fcall_info_cache *fc;
109108
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));
109+
zend_fcall_info_cache *fc = ((pdo_pgsql_db_handle *)dbh->driver_data)->notice_callback;
110+
if (fc) {
111+
ZVAL_STRING(&zarg, message);
112112
zend_call_known_fcc(fc, NULL, 1, &zarg, NULL);
113113
zval_ptr_dtor(&zarg);
114114
}
@@ -1242,7 +1242,7 @@ 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
{
@@ -1251,22 +1251,20 @@ PHP_METHOD(PDO_PGSql_Ext, pgsqlSetNoticeCallback)
12511251
zend_fcall_info fci = empty_fcall_info;
12521252
zend_fcall_info_cache fcc = empty_fcall_info_cache;
12531253

1254-
dbh = Z_PDO_DBH_P(getThis());
1254+
dbh = Z_PDO_DBH_P(ZEND_THIS);
12551255
PDO_CONSTRUCT_CHECK;
12561256

12571257
H = (pdo_pgsql_db_handle *)dbh->driver_data;
12581258

12591259
pdo_pgsql_cleanup_notice_callback(H);
12601260
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "F!", &fci, &fcc)) {
1261-
RETURN_FALSE;
1261+
RETURN_THROWS();
12621262
}
12631263

12641264
if (ZEND_FCC_INITIALIZED(fcc)) {
1265-
H->notice_callback = ecalloc(1, sizeof(zend_fcall_info_cache));
1265+
H->notice_callback = emalloc(sizeof(zend_fcall_info_cache));
12661266
zend_fcc_dup(H->notice_callback, &fcc);
12671267
}
1268-
1269-
RETURN_TRUE;
12701268
}
12711269
/* }}} */
12721270

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)