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
3 changes: 3 additions & 0 deletions oci_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 9 additions & 6 deletions pdo_oci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -126,8 +131,6 @@ PHP_RINIT_FUNCTION(pdo_oci)
tsrm_mutex_unlock(pdo_oci_env_mutex);
#endif
}

return SUCCESS;
}
/* }}} */

Expand Down
2 changes: 0 additions & 2 deletions php_pdo_oci.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 2 additions & 0 deletions php_pdo_oci_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down