1
0
mirror of https://github.com/php/php-src.git synced 2026-03-28 18:22:42 +01:00

fix error messages in Unicode mode when global error handle is used

This commit is contained in:
Antony Dovgal
2006-11-23 16:08:41 +00:00
parent afd25b61a4
commit 577d3dec4c
2 changed files with 50 additions and 17 deletions

View File

@@ -906,29 +906,48 @@ sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC)
sb4 php_oci_fetch_errmsg(OCIError *error_handle, text **error_buf TSRMLS_DC)
{
sb4 error_code = 0;
text tmp_buf[PHP_OCI_ERRBUF_LEN];
text err_buf[PHP_OCI_ERRBUF_LEN];
tmp_buf[0] = '\0';
err_buf[0] = '\0';
memset(err_buf, 0, sizeof(err_buf));
PHP_OCI_CALL(OCIErrorGet, (error_handle, (ub4)1, NULL, &error_code, err_buf, (ub4)PHP_OCI_ERRBUF_LEN, (ub4)OCI_HTYPE_ERROR));
memset(tmp_buf, 0, sizeof(tmp_buf));
PHP_OCI_CALL(OCIErrorGet, (error_handle, (ub4)1, NULL, &error_code, tmp_buf, (ub4)PHP_OCI_ERRBUF_LEN, (ub4)OCI_HTYPE_ERROR));
if (error_code) {
int tmp_buf_len;
if (UG(unicode)) {
tmp_buf_len = u_strlen((UChar *)tmp_buf);
if (tmp_buf_len && tmp_buf[UBYTES(tmp_buf_len - 1)] == '\n') {
tmp_buf[UBYTES(tmp_buf_len - 1)] = '\0';
int err_buf_len;
if (UG(unicode) && error_handle == OCI_G(err)) {
/* global err handle is not Unicode aware */
UChar *tmp_buf;
int tmp_buf_len;
err_buf_len = strlen(err_buf);
if (err_buf_len && err_buf[err_buf_len - 1] == '\n') {
err_buf[err_buf_len - 1] = '\0';
err_buf_len--;
}
if (zend_string_to_unicode(UG(ascii_conv), &tmp_buf, &tmp_buf_len, err_buf, err_buf_len TSRMLS_CC) == SUCCESS) {
*error_buf = (text *)eustrndup(tmp_buf, tmp_buf_len);
efree(tmp_buf);
}
} else {
tmp_buf_len = strlen(tmp_buf);
if (tmp_buf_len && tmp_buf[tmp_buf_len - 1] == '\n') {
tmp_buf[tmp_buf_len - 1] = '\0';
if (UG(unicode)) {
err_buf_len = u_strlen((UChar *)err_buf);
if (err_buf_len && err_buf[UBYTES(err_buf_len - 1)] == '\n') { /* UTODO */
err_buf[UBYTES(err_buf_len - 1)] = '\0';
}
} else {
err_buf_len = strlen(err_buf);
if (err_buf_len && err_buf[err_buf_len - 1] == '\n') {
err_buf[err_buf_len - 1] = '\0';
}
}
if (err_buf_len && error_buf) {
*error_buf = estrndup(err_buf, TEXT_BYTES(err_buf_len));
}
}
if (tmp_buf_len && error_buf) {
*error_buf = estrndup(tmp_buf, TEXT_BYTES(tmp_buf_len));
}
}
return error_code;

View File

@@ -25,3 +25,17 @@ array(4) {
string(0) ""
}
Done
--UEXPECTF--
Warning: oci_connect(): ORA-12154: TNS:could not resolve %s in %s on line %d
bool(false)
array(4) {
["code"]=>
int(12154)
["message"]=>
unicode(45) "ORA-12154: TNS:could not resolve %s"
["offset"]=>
int(0)
["sqltext"]=>
unicode(0) ""
}
Done