Browse Source

Expose oci_unregister_taf_callback()

pull/2648/merge
Christopher Jones 9 years ago
parent
commit
de65a2243f
  1. 3
      NEWS
  2. 8
      ext/oci8/oci8.c
  3. 25
      ext/oci8/oci8_failover.c
  4. 25
      ext/oci8/oci8_interface.c
  5. 22
      ext/oci8/package.xml
  6. 2
      ext/oci8/php_oci8.h
  7. 2
      ext/oci8/php_oci8_int.h
  8. 6
      ext/oci8/tests/driver_name.phpt

3
NEWS

@ -18,6 +18,9 @@ PHP NEWS
. Fixed bug #74968 (PHP crashes when calling mysqli_result::fetch_object with
an abstract class). (Anatol)
- OCI8:
. Expose oci_unregister_taf_callback() (Tianfang Yang)
- SimpleXML:
. Fixed bug #74950 (nullpointer deref in simplexml_element_getDocNamespaces).
(Laruence)

8
ext/oci8/oci8.c

@ -509,6 +509,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_register_taf_callback, 0, 0, 1)
ZEND_ARG_INFO(0, connection_resource)
ZEND_ARG_INFO(0, function_name)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_unregister_taf_callback, 0, 0, 1)
ZEND_ARG_INFO(0, connection_resource)
ZEND_END_ARG_INFO()
/* }}} */
/* {{{ LOB Method arginfo */
@ -707,6 +711,7 @@ PHP_FUNCTION(oci_collection_size);
PHP_FUNCTION(oci_collection_max);
PHP_FUNCTION(oci_collection_trim);
PHP_FUNCTION(oci_register_taf_callback);
PHP_FUNCTION(oci_unregister_taf_callback);
/* }}} */
/* {{{ extension definition structures
@ -790,6 +795,7 @@ static const zend_function_entry php_oci_functions[] = {
PHP_FE(oci_collection_trim, arginfo_oci_collection_trim)
PHP_FE(oci_new_collection, arginfo_oci_new_collection)
PHP_FE(oci_register_taf_callback, arginfo_oci_register_taf_callback)
PHP_FE(oci_unregister_taf_callback, arginfo_oci_unregister_taf_callback)
PHP_FALIAS(oci_free_cursor, oci_free_statement, arginfo_oci_free_statement)
PHP_FALIAS(ocifreecursor, oci_free_statement, arginfo_oci_free_statement)
@ -2702,7 +2708,7 @@ static int php_oci_persistent_helper(zval *zv)
/* Remove TAF callback function as it's bound to current request */
if (connection->used_this_request && !Z_ISUNDEF(connection->taf_callback) && !Z_ISNULL(connection->taf_callback)) {
php_oci_disable_taf_callback(connection);
php_oci_unregister_taf_callback(connection);
}
if (!connection->used_this_request && OCI_G(persistent_timeout) != -1) {

25
ext/oci8/oci8_failover.c

@ -40,29 +40,30 @@
#include "php_oci8.h"
#include "php_oci8_int.h"
/* {{{ callback_fn()
/* {{{ callback_fn()
OCI TAF callback function, calling userspace function */
sb4 callback_fn(OCISvcCtx *svchp, OCIEnv *envhp, php_oci_connection *fo_ctx, ub4 fo_type, ub4 fo_event)
sb4 callback_fn(void *svchp, void *envhp, void *fo_ctx, ub4 fo_type, ub4 fo_event)
{
/* Create zval */
zval retval, params[3];
php_oci_connection *connection = (php_oci_connection*)fo_ctx;
/* Default return value */
sb4 returnValue = 0;
/* Check if userspace callback function was disabled */
if (Z_ISUNDEF(fo_ctx->taf_callback) || Z_ISNULL(fo_ctx->taf_callback)) {
/* Check if userspace callback function was unregistered */
if (Z_ISUNDEF(connection->taf_callback) || Z_ISNULL(connection->taf_callback)) {
return 0;
}
/* Initialize zval */
ZVAL_RES(&params[0], fo_ctx->id);
ZVAL_RES(&params[0], connection->id);
ZVAL_LONG(&params[1], fo_event);
ZVAL_LONG(&params[2], fo_type);
/* Call user function (if possible) */
if (call_user_function(EG(function_table), NULL, &fo_ctx->taf_callback, &retval, 3, params) == FAILURE) {
php_error_docref(NULL, E_WARNING, "Unable to call taf callback function, is it defined?");
if (call_user_function(EG(function_table), NULL, &connection->taf_callback, &retval, 3, params) == FAILURE) {
php_error_docref(NULL, E_WARNING, "Unable to call Oracle TAF callback function");
}
/* Set return value */
@ -83,10 +84,10 @@ sb4 callback_fn(OCISvcCtx *svchp, OCIEnv *envhp, php_oci_connection *fo_ctx, ub4
}
/* }}} */
/* {{{ php_oci_disable_taf_callback()
Disables the userspace callback function for Oracle TAF,
/* {{{ php_oci_unregister_taf_callback()
Unregister the userspace callback function for Oracle TAF,
while keeping the OCI callback alive */
int php_oci_disable_taf_callback(php_oci_connection *connection)
int php_oci_unregister_taf_callback(php_oci_connection *connection)
{
return php_oci_register_taf_callback(connection, NULL);
}
@ -103,9 +104,9 @@ int php_oci_register_taf_callback(php_oci_connection *connection, zval *callback
OCIFocbkStruct failover;
if (!callback) {
/* Disable callback */
/* Unregister callback */
if (Z_ISUNDEF(connection->taf_callback) || Z_ISNULL(connection->taf_callback)) {
return 0; // Nothing to disable
return 0; // Nothing to unregister
}
registered = 1;

25
ext/oci8/oci8_interface.c

@ -75,6 +75,27 @@ PHP_FUNCTION(oci_register_taf_callback)
}
/* }}} */
/* {{{ proto bool oci_unregister_taf_callback( resource connection )
* Unregister a callback function for Oracle Transparent Application Failover (TAF) */
PHP_FUNCTION(oci_unregister_taf_callback)
{
zval *z_connection;
php_oci_connection *connection;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &z_connection) == FAILURE) {
return;
}
PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
if (php_oci_unregister_taf_callback(connection) == 0) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
}
/* }}} */
/* {{{ proto bool oci_define_by_name(resource stmt, string name, mixed &var [, int type])
Define a PHP variable to an Oracle column by name */
/* if you want to define a LOB/CLOB etc make sure you allocate it via OCINewDescriptor BEFORE defining!!! */
@ -1587,8 +1608,8 @@ PHP_FUNCTION(oci_close)
RefCount value by 1 */
zend_list_close(connection->id);
/* Disable Oracle TAF */
php_oci_disable_taf_callback(connection);
/* Unregister Oracle TAF */
php_oci_unregister_taf_callback(connection);
/* ZVAL_NULL(z_connection); */

22
ext/oci8/package.xml

@ -50,8 +50,8 @@ Interoperability Support" (ID 207303.1) for details.
<time>12:00:00</time>
<version>
<release>2.1.6</release>
<api>2.1.6</api>
<release>2.1.7</release>
<api>2.1.7</api>
</version>
<stability>
<release>stable</release>
@ -60,7 +60,7 @@ Interoperability Support" (ID 207303.1) for details.
<license uri="http://www.php.net/license">PHP</license>
<notes>
This version is for PHP 7 only.
Fixed bug #74625 (Integer overflow in oci_bind_array_by_name). (Ingmar Runge)
Added oci_unregister_taf_callback()
</notes>
<contents>
<dir name="/">
@ -470,6 +470,22 @@ Fixed bug #74625 (Integer overflow in oci_bind_array_by_name). (Ingmar Runge)
</extsrcrelease>
<changelog>
<release>
<version>
<release>2.1.6</release>
<api>2.1.6</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>
This version is for PHP 7 only.
Fixed bug #74625 (Integer overflow in oci_bind_array_by_name). (Ingmar Runge)
</notes>
</release>
<release>
<version>
<release>2.1.5</release>

2
ext/oci8/php_oci8.h

@ -43,7 +43,7 @@
*/
#undef PHP_OCI8_VERSION
#endif
#define PHP_OCI8_VERSION "2.1.6"
#define PHP_OCI8_VERSION "2.1.7"
extern zend_module_entry oci8_module_entry;
#define phpext_oci8_ptr &oci8_module_entry

2
ext/oci8/php_oci8_int.h

@ -536,7 +536,7 @@ ZEND_END_MODULE_GLOBALS(oci) /* }}} */
/* {{{ transparent failover related prototypes */
int php_oci_register_taf_callback(php_oci_connection *connection, zval *callback);
int php_oci_disable_taf_callback(php_oci_connection *connection);
int php_oci_unregister_taf_callback(php_oci_connection *connection);
/* }}} */

6
ext/oci8/tests/driver_name.phpt

@ -57,11 +57,11 @@ function get_attr($conn)
?>
--EXPECT--
**Test 1.1 - Default values for the attribute **************
The value of DRIVER_NAME is PHP OCI8 : 2.1.6
The value of DRIVER_NAME is PHP OCI8 : 2.1.7
***Test 1.2 - Get the values from different connections **************
Testing with oci_pconnect()
The value of DRIVER_NAME is PHP OCI8 : 2.1.6
The value of DRIVER_NAME is PHP OCI8 : 2.1.7
Testing with oci_new_connect()
The value of DRIVER_NAME is PHP OCI8 : 2.1.6
The value of DRIVER_NAME is PHP OCI8 : 2.1.7
Done
Loading…
Cancel
Save