summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2020-07-20 17:34:57 +0100
committerChristopher Jones <sixd@php.net>2020-07-22 17:29:30 +1000
commit7a3375a08cc2433ab868d4e083efe6d1b72bcca3 (patch)
tree67961d2030081fd64d8f5a5124e384ec7b6a8e2d
parent0d146cb3eba487c4e1d4b554072c30cc4d394cd8 (diff)
downloadphp-git-7a3375a08cc2433ab868d4e083efe6d1b72bcca3.tar.gz
Use ZPP callable check for oci_register_taf_callback()
-rw-r--r--ext/oci8/oci8.stub.php5
-rw-r--r--ext/oci8/oci8_arginfo.h4
-rw-r--r--ext/oci8/oci8_interface.c22
3 files changed, 13 insertions, 18 deletions
diff --git a/ext/oci8/oci8.stub.php b/ext/oci8/oci8.stub.php
index cf870f8acb..d53caed69b 100644
--- a/ext/oci8/oci8.stub.php
+++ b/ext/oci8/oci8.stub.php
@@ -614,9 +614,8 @@ function ocinewcollection($connection_resource, string $type_name, string $schem
/**
* @param resource $connection_resource
- * @param callable|null $function_name
*/
-function oci_register_taf_callback($connection_resource, $function_name): bool {}
+function oci_register_taf_callback($connection_resource, ?callable $function_name): bool {}
/**
* @param resource $connection_resource
@@ -805,4 +804,4 @@ class OCI_Collection {
* @return bool
*/
public function trim(int $number) {}
-} \ No newline at end of file
+}
diff --git a/ext/oci8/oci8_arginfo.h b/ext/oci8/oci8_arginfo.h
index 90aee86841..c82656f205 100644
--- a/ext/oci8/oci8_arginfo.h
+++ b/ext/oci8/oci8_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 157a4128645b816f23fb0bcbbb5860362f446cb3 */
+ * Stub hash: 4a4e86dc175542bbf0bc29c9a957c5dfec834f93 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0)
ZEND_ARG_INFO(0, statement_resource)
@@ -433,7 +433,7 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_register_taf_callback, 0, 2, _IS_BOOL, 0)
ZEND_ARG_INFO(0, connection_resource)
- ZEND_ARG_INFO(0, function_name)
+ ZEND_ARG_TYPE_INFO(0, function_name, IS_CALLABLE, 1)
ZEND_END_ARG_INFO()
#define arginfo_oci_unregister_taf_callback arginfo_oci_rollback
diff --git a/ext/oci8/oci8_interface.c b/ext/oci8/oci8_interface.c
index 689ac1c2e0..2ecf1d4bc4 100644
--- a/ext/oci8/oci8_interface.c
+++ b/ext/oci8/oci8_interface.c
@@ -45,25 +45,21 @@ PHP_FUNCTION(oci_register_taf_callback)
{
zval *z_connection;
php_oci_connection *connection;
- zval *callback;
- zend_string *callback_name;
+ zend_fcall_info fci;
+ zend_fcall_info_cache fcc;
+ zval *callback = NULL;
- /* TODO Use ZPP callable */
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|z!", &z_connection, &callback) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|f!", &z_connection, &fci, &fcc) == FAILURE) {
RETURN_THROWS();
}
- if (callback) {
- if (!zend_is_callable(callback, 0, 0)) {
- callback_name = zend_get_callable_name(callback);
- php_error_docref(NULL, E_WARNING, "Function '%s' is not callable", ZSTR_VAL(callback_name));
- zend_string_release(callback_name);
- RETURN_FALSE;
- }
- }
-
PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
+ /* If callable passed, assign callback zval so that it can be passed to php_oci_register_taf_callback() */
+ if (ZEND_FCI_INITIALIZED(fci)) {
+ callback = &fci.function_name;
+ }
+
if (php_oci_register_taf_callback(connection, callback) == 0) {
RETURN_TRUE;
} else {