diff --git a/oci_driver.c b/oci_driver.c index 7216fc8..97f0dc5 100644 --- a/oci_driver.c +++ b/oci_driver.c @@ -741,6 +741,9 @@ static int pdo_oci_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{ * H->prefetch = PDO_OCI_PREFETCH_DEFAULT; + /* create the true global environment on first use */ + pdo_oci_init_env(); + /* allocate an environment */ #ifdef HAVE_OCIENVNLSCREATE if (vars[0].optval) { diff --git a/pdo_oci.c b/pdo_oci.c index 49bc846..904848f 100644 --- a/pdo_oci.c +++ b/pdo_oci.c @@ -43,7 +43,7 @@ zend_module_entry pdo_oci_module_entry = { NULL, PHP_MINIT(pdo_oci), PHP_MSHUTDOWN(pdo_oci), - PHP_RINIT(pdo_oci), + NULL, NULL, PHP_MINFO(pdo_oci), PHP_PDO_OCI_VERSION, @@ -101,7 +101,7 @@ PHP_MINIT_FUNCTION(pdo_oci) return FAILURE; } - // Defer OCI init to PHP_RINIT_FUNCTION because with php-fpm, + // Defer OCI init to pdo_oci_init_env() because with php-fpm, // NLS_LANG is not yet available here. #ifdef ZTS @@ -112,8 +112,13 @@ PHP_MINIT_FUNCTION(pdo_oci) } /* }}} */ -/* {{{ PHP_RINIT_FUNCTION */ -PHP_RINIT_FUNCTION(pdo_oci) +/* {{{ pdo_oci_init_env + * Create the true global OCI environment on first use. + * Called from pdo_oci_handle_factory() rather than from MINIT (NLS_LANG is not + * yet available there under php-fpm) or from RINIT (initializing the Oracle + * client library has process-wide side effects, so a process that never opens + * an Oracle connection must not pay for it). */ +void pdo_oci_init_env(void) { if (!pdo_oci_Env) { #ifdef ZTS @@ -126,8 +131,6 @@ PHP_RINIT_FUNCTION(pdo_oci) tsrm_mutex_unlock(pdo_oci_env_mutex); #endif } - - return SUCCESS; } /* }}} */ diff --git a/php_pdo_oci.h b/php_pdo_oci.h index 7a44b67..8e15f0a 100644 --- a/php_pdo_oci.h +++ b/php_pdo_oci.h @@ -29,8 +29,6 @@ extern zend_module_entry pdo_oci_module_entry; PHP_MINIT_FUNCTION(pdo_oci); PHP_MSHUTDOWN_FUNCTION(pdo_oci); -PHP_RINIT_FUNCTION(pdo_oci); -PHP_RSHUTDOWN_FUNCTION(pdo_oci); PHP_MINFO_FUNCTION(pdo_oci); #endif /* PHP_PDO_OCI_H */ diff --git a/php_pdo_oci_int.h b/php_pdo_oci_int.h index dd513ff..04c462d 100644 --- a/php_pdo_oci_int.h +++ b/php_pdo_oci_int.h @@ -91,6 +91,8 @@ extern const ub4 PDO_OCI_INIT_MODE; extern const pdo_driver_t pdo_oci_driver; extern OCIEnv *pdo_oci_Env; +void pdo_oci_init_env(void); + ub4 _oci_error(OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, sword status, int isinit, const char *file, int line); #define oci_init_error(w) _oci_error(H->err, dbh, NULL, w, H->last_err, TRUE, __FILE__, __LINE__) #define oci_drv_error(w) _oci_error(H->err, dbh, NULL, w, H->last_err, FALSE, __FILE__, __LINE__)