cvs: php-src /ext/oci8 oci8.c /ext/oci8/tests error1.phpt

From: Date: Thu, 23 Nov 2006 16:08:41 +0000
Subject: cvs: php-src /ext/oci8 oci8.c /ext/oci8/tests error1.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-41703@lists.php.net to get a copy of this message
tony2001 Thu Nov 23 16:08:41 2006 UTC Modified files: /php-src/ext/oci8 oci8.c /php-src/ext/oci8/tests error1.phpt Log: fix error messages in Unicode mode when global error handle is used http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8.c?r1=1.324&r2=1.325&diff_format=u Index: php-src/ext/oci8/oci8.c diff -u php-src/ext/oci8/oci8.c:1.324 php-src/ext/oci8/oci8.c:1.325 --- php-src/ext/oci8/oci8.c:1.324 Fri Nov 10 16:56:19 2006 +++ php-src/ext/oci8/oci8.c Thu Nov 23 16:08:41 2006 @@ -26,7 +26,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: oci8.c,v 1.324 2006/11/10 16:56:19 tony2001 Exp $ */ +/* $Id: oci8.c,v 1.325 2006/11/23 16:08:41 tony2001 Exp $ */ /* TODO * * file://localhost/www/docs/oci10/ociaahan.htm#423823 - implement lob_empty() with OCI_ATTR_LOBEMPTY @@ -670,7 +670,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "OCI8 Support", "enabled"); php_info_print_table_row(2, "Version", "1.2.2"); - php_info_print_table_row(2, "Revision", "$Revision: 1.324 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.325 $"); sprintf(buf, "%ld", OCI_G(num_persistent)); php_info_print_table_row(2, "Active Persistent Connections", buf); @@ -906,29 +906,48 @@ 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; http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/error1.phpt?r1=1.7&r2=1.8&diff_format=u Index: php-src/ext/oci8/tests/error1.phpt diff -u php-src/ext/oci8/tests/error1.phpt:1.7 php-src/ext/oci8/tests/error1.phpt:1.8 --- php-src/ext/oci8/tests/error1.phpt:1.7 Fri Nov 10 16:56:19 2006 +++ php-src/ext/oci8/tests/error1.phpt Thu Nov 23 16:08:41 2006 @@ -25,3 +25,17 @@ 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

« previous php.cvs (#41703) next »