Skip to content

Commit b44adcd

Browse files
committed
Improve OCI8 NLS env creation error messages (#58925)
1 parent acd96cd commit b44adcd

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

ext/oci8/oci8.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,11 +2901,20 @@ static OCIEnv *php_oci_create_env(ub2 charsetid TSRMLS_DC)
29012901
PHP_OCI_CALL_RETURN(OCI_G(errcode), OCIEnvNlsCreate, (&retenv, OCI_G(events) ? PHP_OCI_INIT_MODE | OCI_EVENTS : PHP_OCI_INIT_MODE, 0, NULL, NULL, NULL, 0, NULL, charsetid, charsetid));
29022902

29032903
if (OCI_G(errcode) != OCI_SUCCESS) {
2904+
sb4 ora_error_code = 0;
2905+
text ora_msg_buf[OCI_ERROR_MAXMSG_SIZE]; /* Use traditional smaller size: non-PL/SQL errors should fit and it keeps the stack smaller */
2906+
29042907
#ifdef HAVE_OCI_INSTANT_CLIENT
29052908
php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCIEnvNlsCreate() failed. There is something wrong with your system - please check that " PHP_OCI8_LIB_PATH_MSG " includes the directory with Oracle Instant Client libraries");
29062909
#else
29072910
php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and " PHP_OCI8_LIB_PATH_MSG " are set and point to the right directories");
29082911
#endif
2912+
if (retenv
2913+
&& OCIErrorGet(retenv, (ub4)1, NULL, &ora_error_code, ora_msg_buf, (ub4)OCI_ERROR_MAXMSG_SIZE, (ub4)OCI_HTYPE_ENV) == OCI_SUCCESS
2914+
&& *ora_msg_buf) {
2915+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ora_msg_buf);
2916+
}
2917+
29092918
return NULL;
29102919
}
29112920
return retenv;

ext/oci8/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
4747
<license uri="http://www.php.net/license">PHP</license>
4848
<notes>
4949
Increased maximum possible Oracle DB error message length
50+
Improve internal initalization failure error messages
5051
</notes>
5152
<contents>
5253
<dir name="/">

0 commit comments

Comments
 (0)