Skip to content

Commit d9e378e

Browse files
committed
Use ZPP callable check for oci_register_taf_callback()
1 parent b856a02 commit d9e378e

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

ext/oci8/oci8.stub.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,8 @@ function ocinewcollection($connection_resource, string $type_name, string $schem
614614

615615
/**
616616
* @param resource $connection_resource
617-
* @param callable|null $function_name
618617
*/
619-
function oci_register_taf_callback($connection_resource, $function_name): bool {}
618+
function oci_register_taf_callback($connection_resource, ?callable $function_name): bool {}
620619

621620
/**
622621
* @param resource $connection_resource
@@ -805,4 +804,4 @@ public function max() {}
805804
* @return bool
806805
*/
807806
public function trim(int $number) {}
808-
}
807+
}

ext/oci8/oci8_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 157a4128645b816f23fb0bcbbb5860362f446cb3 */
2+
* Stub hash: 4a4e86dc175542bbf0bc29c9a957c5dfec834f93 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0)
55
ZEND_ARG_INFO(0, statement_resource)
@@ -433,7 +433,7 @@ ZEND_END_ARG_INFO()
433433

434434
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_register_taf_callback, 0, 2, _IS_BOOL, 0)
435435
ZEND_ARG_INFO(0, connection_resource)
436-
ZEND_ARG_INFO(0, function_name)
436+
ZEND_ARG_TYPE_INFO(0, function_name, IS_CALLABLE, 1)
437437
ZEND_END_ARG_INFO()
438438

439439
#define arginfo_oci_unregister_taf_callback arginfo_oci_rollback

ext/oci8/oci8_interface.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,21 @@ PHP_FUNCTION(oci_register_taf_callback)
4545
{
4646
zval *z_connection;
4747
php_oci_connection *connection;
48-
zval *callback;
49-
zend_string *callback_name;
48+
zend_fcall_info fci;
49+
zend_fcall_info_cache fcc;
50+
zval *callback = NULL;
5051

51-
/* TODO Use ZPP callable */
52-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|z!", &z_connection, &callback) == FAILURE) {
52+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|f!", &z_connection, &fci, &fcc) == FAILURE) {
5353
RETURN_THROWS();
5454
}
5555

56-
if (callback) {
57-
if (!zend_is_callable(callback, 0, 0)) {
58-
callback_name = zend_get_callable_name(callback);
59-
php_error_docref(NULL, E_WARNING, "Function '%s' is not callable", ZSTR_VAL(callback_name));
60-
zend_string_release(callback_name);
61-
RETURN_FALSE;
62-
}
63-
}
64-
6556
PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
6657

58+
/* If callable passed, assign callback zval so that it can be passed to php_oci_register_taf_callback() */
59+
if ZEND_FCI_INITIALIZED(fci) {
60+
callback = &fci.function_name;
61+
}
62+
6763
if (php_oci_register_taf_callback(connection, callback) == 0) {
6864
RETURN_TRUE;
6965
} else {

0 commit comments

Comments
 (0)