Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/php_pq_callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ void php_pq_callback_dtor(php_pq_callback_t *cb)
cb->recursion = NULL;
}
if (cb->fci.size > 0) {
zend_fcall_info_args_clear(&cb->fci, 1);
ZEND_ASSERT(cb->fci.param_count = 0);
zval_ptr_dtor(&cb->fci.function_name);
if (cb->fci.object) {
zval tmp;

ZVAL_OBJ(&tmp, cb->fci.object);
zval_ptr_dtor(&tmp);
OBJ_RELEASE(cb->fci.object);
}
cb->fci.size = 0;
}
Expand Down
20 changes: 12 additions & 8 deletions src/php_pqconn.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,23 @@ static int apply_notify_listener(zval *p, void *arg)
{
php_pq_callback_t *listener = Z_PTR_P(p);
PGnotify *nfy = arg;
zval zpid, zchannel, zmessage;

ZVAL_LONG(&zpid, nfy->be_pid);
ZVAL_STRING(&zchannel, nfy->relname);
ZVAL_STRING(&zmessage, nfy->extra);
/* Argument 1 is the PID, argument 2 is the channel, and argument 3 is the message */
zval args[3];

zend_fcall_info_argn(&listener->fci, 3, &zchannel, &zmessage, &zpid);
zend_fcall_info_call(&listener->fci, &listener->fcc, NULL, NULL);
zend_fcall_info_args_clear(&listener->fci, 0);
ZVAL_LONG(&args[0], nfy->be_pid);
ZVAL_STRING(&args[1], nfy->relname);
ZVAL_STRING(&args[2], nfy->extra);

listener->fci.param_count = 3;
listener->fci.params = args;
zend_call_function(&listener->fci, &listener->fcc);

listener->fci.param_count = 0;
listener->fci.params = NULL;
zval_ptr_dtor(&zchannel);
zval_ptr_dtor(&zmessage);
zval_ptr_dtor(&zpid);
/* Don't need to free the PID as it is a long */

return ZEND_HASH_APPLY_KEEP;
}
Expand Down
17 changes: 14 additions & 3 deletions src/php_pqconn_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@ static int apply_event(zval *p, void *a)
{
php_pq_callback_t *cb = Z_PTR_P(p);
zval *args = a;
zval rv;

ZEND_ASSERT(args != NULL && Z_TYPE_P(args) == IS_ARRAY);

#if PHP_VERSION_ID >= 80000
cb->fci.named_params = Z_ARRVAL_P(args);
zend_call_function(&cb->fci, &cb->fcc);
cb->fci.named_params = NULL;
#else
zval rv;
ZVAL_NULL(&rv);
zend_fcall_info_args(&cb->fci, args);
zend_fcall_info_call(&cb->fci, &cb->fcc, &rv, NULL);
zend_fcall_info_args_clear(&cb->fci, 0);
zval_ptr_dtor(&rv);
#endif

return ZEND_HASH_APPLY_KEEP;
}
Expand Down Expand Up @@ -138,8 +146,11 @@ static void php_pqconn_event_resultcreate(PGEventResultCreate *event)
zval res;

php_pq_object_to_zval(obj, &res);
zend_fcall_info_argn(&data->obj->intern->onevent.fci, 1, &res);
zend_fcall_info_call(&data->obj->intern->onevent.fci, &data->obj->intern->onevent.fcc, NULL, NULL);
data->obj->intern->onevent.fci.param_count = 1;
data->obj->intern->onevent.fci.params = &res;
zend_call_function(&data->obj->intern->onevent.fci, &data->obj->intern->onevent.fcc);
data->obj->intern->onevent.fci.param_count = 0;
data->obj->intern->onevent.fci.params = NULL;
zval_ptr_dtor(&res);
}

Expand Down
Loading