From: Felipe Pena Date: Wed, 25 Mar 2009 12:05:51 +0000 (+0000) Subject: - Fixed some code to be working with unicode X-Git-Tag: php-5.4.0alpha1~191^2~4063 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc61f2e106ee7a2c10764e7e4a727483658e1e98;p=php - Fixed some code to be working with unicode --- diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 4e90eeb1f4..1415929749 100755 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -1033,9 +1033,9 @@ static PHP_METHOD(PDO, errorInfo) array_init(return_value); if (dbh->query_stmt) { - add_next_index_string(return_value, dbh->query_stmt->error_code, 1); + add_next_index_ascii_string(return_value, dbh->query_stmt->error_code, 1); } else { - add_next_index_string(return_value, dbh->error_code, 1); + add_next_index_ascii_string(return_value, dbh->error_code, 1); } if (dbh->methods->fetch_err) { @@ -1265,7 +1265,6 @@ int pdo_hash_methods(pdo_dbh_t *dbh, int kind TSRMLS_DC) const zend_function_entry *funcs; zend_function func; zend_internal_function *ifunc = (zend_internal_function*)&func; - int namelen; char *lc_name; if (!dbh || !dbh->methods || !dbh->methods->get_driver_methods) { @@ -1282,9 +1281,12 @@ int pdo_hash_methods(pdo_dbh_t *dbh, int kind TSRMLS_DC) zend_hash_init_ex(dbh->cls_methods[kind], 8, NULL, NULL, dbh->is_persistent, 0); while (funcs->fname) { + int namelen = strlen(funcs->fname)+1; + ifunc->type = ZEND_INTERNAL_FUNCTION; ifunc->handler = funcs->handler; - pdo_zstr_sval(ifunc->function_name) = (char*)funcs->fname; + ifunc->function_name.u = malloc(UBYTES(namelen)); + u_charsToUChars(funcs->fname, ifunc->function_name.u, namelen); ifunc->scope = dbh->ce; ifunc->prototype = NULL; if (funcs->arg_info) { @@ -1309,10 +1311,9 @@ int pdo_hash_methods(pdo_dbh_t *dbh, int kind TSRMLS_DC) } else { ifunc->fn_flags = ZEND_ACC_PUBLIC; } - namelen = strlen(funcs->fname); lc_name = emalloc(namelen+1); zend_str_tolower_copy(lc_name, funcs->fname, namelen); - zend_hash_add(dbh->cls_methods[kind], lc_name, namelen+1, &func, sizeof(func), NULL); + zend_ascii_hash_add(dbh->cls_methods[kind], lc_name, namelen+1, &func, sizeof(zend_function), NULL); efree(lc_name); funcs++; } @@ -1365,7 +1366,7 @@ static union _zend_function *dbh_method_get( } out: - if (std_object_handlers.get_method) { + if (!fbc && std_object_handlers.get_method) { fbc = std_object_handlers.get_method(object_pp, method_name, method_len TSRMLS_CC); } diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 1d55997765..92e705ca3b 100755 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -1537,12 +1537,12 @@ static PHP_METHOD(PDOStatement, fetchAll) /* no break */ case 2: stmt->fetch.cls.ctor_args = ctor_args; /* we're not going to free these */ - if (Z_TYPE_P(arg2) != IS_STRING) { + if (Z_TYPE_P(arg2) != IS_STRING && Z_TYPE_P(arg2) != IS_UNICODE) { pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "Invalid class name (should be a string)" TSRMLS_CC); error = 1; break; } else { - stmt->fetch.cls.ce = zend_fetch_class(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); + stmt->fetch.cls.ce = zend_u_fetch_class(Z_TYPE_P(arg2), Z_UNIVAL_P(arg2), Z_UNILEN_P(arg2), ZEND_FETCH_CLASS_AUTO TSRMLS_CC); if (!stmt->fetch.cls.ce) { pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not find user-specified class" TSRMLS_CC); error = 1; @@ -2746,9 +2746,11 @@ static int row_call_method( static union _zend_function *row_get_ctor(zval *object TSRMLS_DC) { static zend_internal_function ctor = {0}; + int namelen = sizeof("__construct"); ctor.type = ZEND_INTERNAL_FUNCTION; - pdo_zstr_sval(ctor.function_name) = "__construct"; + ctor.function_name.u = malloc(UBYTES(namelen)); + u_charsToUChars("__construct", ctor.function_name.u, namelen); ctor.scope = pdo_row_ce; ctor.handler = ZEND_FN(dbstmt_constructor);