summaryrefslogtreecommitdiff
path: root/ext/mysqli
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mysqli')
-rw-r--r--ext/mysqli/mysqli.c55
-rw-r--r--ext/mysqli/mysqli_api.c12
-rw-r--r--ext/mysqli/mysqli_nonapi.c29
3 files changed, 34 insertions, 62 deletions
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index dc9317d7ee..d49529c35e 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -95,7 +95,7 @@ static int le_pmysqli;
void php_mysqli_dtor_p_elements(void *data)
{
MYSQL *mysql = (MYSQL *) data;
- TSRMLS_FETCH();
+
mysqli_close(mysql, MYSQLI_CLOSE_IMPLICIT);
}
@@ -338,12 +338,12 @@ zval *mysqli_read_property(zval *object, zval *member, int type TSRMLS_DC)
if (member->type != IS_STRING && member->type != IS_UNICODE) {
tmp_member = *member;
zval_copy_ctor(&tmp_member);
- convert_to_text(&tmp_member);
+ convert_to_unicode(&tmp_member);
member = &tmp_member;
}
if (obj->prop_handler != NULL) {
- ret = zend_u_hash_find(obj->prop_handler, ZEND_STR_TYPE, Z_UNIVAL_P(member), Z_UNILEN_P(member)+1, (void **) &hnd);
+ ret = zend_u_hash_find(obj->prop_handler, IS_UNICODE, Z_UNIVAL_P(member), Z_UNILEN_P(member)+1, (void **) &hnd);
}
if (ret == SUCCESS) {
@@ -427,7 +427,7 @@ static int mysqli_object_has_property(zval *object, zval *member, int has_set_ex
if (member->type != IS_STRING && member->type != IS_UNICODE) {
tmp_member = *member;
zval_copy_ctor(&tmp_member);
- convert_to_text(&tmp_member);
+ convert_to_unicode(&tmp_member);
member = &tmp_member;
}
@@ -491,9 +491,7 @@ HashTable * mysqli_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC)
zend_ascii_hash_add(retval, entry->name, entry->name_len + 1, &value, sizeof(zval *), NULL);
}
zend_hash_move_forward_ex(props, &pos);
- if (UG(unicode)) {
- zval_dtor(&member);
- }
+ zval_dtor(&member);
}
*is_temp = 1;
@@ -522,7 +520,7 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_
mysqli_base_class = mysqli_base_class->parent;
}
- zend_u_hash_find(&classes, ZEND_STR_TYPE, mysqli_base_class->name, mysqli_base_class->name_length + 1,
+ zend_u_hash_find(&classes, IS_UNICODE, mysqli_base_class->name, mysqli_base_class->name_length + 1,
(void **) &intern->prop_handler);
zend_object_std_init(&intern->zo, class_type TSRMLS_CC);
@@ -695,7 +693,7 @@ PHP_MINIT_FUNCTION(mysqli)
zend_u_hash_init(&mysqli_driver_properties, 0, NULL, NULL, 1, 1);
MYSQLI_ADD_PROPERTIES(&mysqli_driver_properties, mysqli_driver_property_entries);
MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_driver_property_info_entries);
- zend_u_hash_add(&classes, ZEND_STR_TYPE, ce->name, ce->name_length+1, &mysqli_driver_properties, sizeof(mysqli_driver_properties), NULL);
+ zend_u_hash_add(&classes, IS_UNICODE, ce->name, ce->name_length+1, &mysqli_driver_properties, sizeof(mysqli_driver_properties), NULL);
ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
REGISTER_MYSQLI_CLASS_ENTRY("mysqli", mysqli_link_class_entry, mysqli_link_methods);
@@ -703,7 +701,7 @@ PHP_MINIT_FUNCTION(mysqli)
zend_u_hash_init(&mysqli_link_properties, 0, NULL, NULL, 1, 1);
MYSQLI_ADD_PROPERTIES(&mysqli_link_properties, mysqli_link_property_entries);
MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_link_property_info_entries);
- zend_u_hash_add(&classes, ZEND_STR_TYPE, ce->name, ce->name_length+1, &mysqli_link_properties, sizeof(mysqli_link_properties), NULL);
+ zend_u_hash_add(&classes, IS_UNICODE, ce->name, ce->name_length+1, &mysqli_link_properties, sizeof(mysqli_link_properties), NULL);
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_warning", mysqli_warning_class_entry, mysqli_warning_methods);
ce = mysqli_warning_class_entry;
@@ -711,21 +709,21 @@ PHP_MINIT_FUNCTION(mysqli)
zend_u_hash_init(&mysqli_warning_properties, 0, NULL, NULL, 1, 1);
MYSQLI_ADD_PROPERTIES(&mysqli_warning_properties, mysqli_warning_property_entries);
MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_warning_property_info_entries);
- zend_u_hash_add(&classes, ZEND_STR_TYPE, ce->name, ce->name_length+1, &mysqli_warning_properties, sizeof(mysqli_warning_properties), NULL);
+ zend_u_hash_add(&classes, IS_UNICODE, ce->name, ce->name_length+1, &mysqli_warning_properties, sizeof(mysqli_warning_properties), NULL);
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_result", mysqli_result_class_entry, mysqli_result_methods);
ce = mysqli_result_class_entry;
zend_u_hash_init(&mysqli_result_properties, 0, NULL, NULL, 1, 1);
MYSQLI_ADD_PROPERTIES(&mysqli_result_properties, mysqli_result_property_entries);
MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_result_property_info_entries);
- zend_u_hash_add(&classes, ZEND_STR_TYPE, ce->name, ce->name_length+1, &mysqli_result_properties, sizeof(mysqli_result_properties), NULL);
+ zend_u_hash_add(&classes, IS_UNICODE, ce->name, ce->name_length+1, &mysqli_result_properties, sizeof(mysqli_result_properties), NULL);
REGISTER_MYSQLI_CLASS_ENTRY("mysqli_stmt", mysqli_stmt_class_entry, mysqli_stmt_methods);
ce = mysqli_stmt_class_entry;
zend_u_hash_init(&mysqli_stmt_properties, 0, NULL, NULL, 1, 1);
MYSQLI_ADD_PROPERTIES(&mysqli_stmt_properties, mysqli_stmt_property_entries);
MYSQLI_ADD_PROPERTIES_INFO(ce, mysqli_stmt_property_info_entries);
- zend_u_hash_add(&classes, ZEND_STR_TYPE, ce->name, ce->name_length+1, &mysqli_stmt_properties, sizeof(mysqli_stmt_properties), NULL);
+ zend_u_hash_add(&classes, IS_UNICODE, ce->name, ce->name_length+1, &mysqli_stmt_properties, sizeof(mysqli_stmt_properties), NULL);
/* mysqli_options */
@@ -1218,7 +1216,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
zval *res;
MAKE_STD_ZVAL(res);
- if (UG(unicode) && !IS_BINARY_DATA(fields[i])) {
+ if (!IS_BINARY_DATA(fields[i])) {
UChar *ustr;
int ulen;
@@ -1232,35 +1230,28 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags
add_index_zval(return_value, i, res);
}
if (fetchtype & MYSQLI_ASSOC) {
+ UChar *ustr;
+ int ulen;
+
if (fetchtype & MYSQLI_NUM) {
Z_ADDREF_P(res);
}
- if (UG(unicode)) {
- UChar *ustr;
- int ulen;
- zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, fields[i].name, strlen(fields[i].name) TSRMLS_CC);
- add_u_assoc_zval_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen + 1, res);
- efree(ustr);
- } else {
- add_assoc_zval(return_value, fields[i].name, res);
- }
+ zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, fields[i].name, strlen(fields[i].name) TSRMLS_CC);
+ add_u_assoc_zval_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen + 1, res);
+ efree(ustr);
}
} else {
if (fetchtype & MYSQLI_NUM) {
add_index_null(return_value, i);
}
if (fetchtype & MYSQLI_ASSOC) {
- if (UG(unicode)) {
- UChar *ustr;
- int ulen;
+ UChar *ustr;
+ int ulen;
- zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, fields[i].name, strlen(fields[i].name) TSRMLS_CC);
- add_u_assoc_null(return_value, IS_UNICODE, ZSTR(ustr));
- efree(ustr);
- } else {
- add_assoc_null(return_value, fields[i].name);
- }
+ zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, fields[i].name, strlen(fields[i].name) TSRMLS_CC);
+ add_u_assoc_null(return_value, IS_UNICODE, ZSTR(ustr));
+ efree(ustr);
}
}
}
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 4d37c0c651..2737320f60 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -529,9 +529,7 @@ PHP_FUNCTION(mysqli_change_user)
}
/* Change user resets the charset in the server, change it back */
- if (UG(unicode)) {
- mysql_set_character_set(mysql->mysql, "utf8");
- }
+ mysql_set_character_set(mysql->mysql, "utf8");
RETURN_TRUE;
}
@@ -753,7 +751,7 @@ PHP_FUNCTION(mysqli_stmt_execute)
zval *the_var = copies && copies[i]? copies[i]:stmt->param.vars[i];
switch (stmt->stmt->params[i].buffer_type) {
case MYSQL_TYPE_VAR_STRING:
- if (UG(unicode) && Z_TYPE_P(the_var) == IS_UNICODE) {
+ if (Z_TYPE_P(the_var) == IS_UNICODE) {
if (the_var == stmt->param.vars[i]) {
php_mysqli_stmt_copy_it(&copies, stmt->param.vars[i], stmt->param.var_cnt, i);
the_var = copies[i];
@@ -905,9 +903,7 @@ void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
tmp[10]= '\0';
/* unsigned int > INT_MAX is 10 digits - ALWAYS */
ZVAL_UTF8_STRINGL(stmt->result.vars[i], tmp, 10, 0);
- if (UG(unicode)) {
- efree(tmp);
- }
+ efree(tmp);
break;
}
#endif
@@ -1478,7 +1474,7 @@ PHP_FUNCTION(mysqli_set_local_infile_handler)
MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link", MYSQLI_STATUS_VALID);
- if (UG(unicode) && Z_TYPE_P(callback_func) != IS_ARRAY && Z_TYPE_P(callback_func) != IS_OBJECT) {
+ if (Z_TYPE_P(callback_func) != IS_ARRAY && Z_TYPE_P(callback_func) != IS_OBJECT) {
convert_to_string(callback_func);
}
diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c
index b30957c5a4..1237458d27 100644
--- a/ext/mysqli/mysqli_nonapi.c
+++ b/ext/mysqli/mysqli_nonapi.c
@@ -227,10 +227,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
new_connection = TRUE;
}
- if (UG(unicode)) {
- mysql_options(mysql->mysql, MYSQL_SET_CHARSET_NAME, "utf8");
- }
-
+ mysql_options(mysql->mysql, MYSQL_SET_CHARSET_NAME, "utf8");
#ifdef HAVE_EMBEDDED_MYSQLI
if (hostname_len) {
@@ -260,9 +257,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
}
/* when PHP runs in unicode, set default character set to utf8 */
- if (UG(unicode)) {
- mysql->conv = UG(utf8_conv);
- }
+ mysql->conv = UG(utf8_conv);
/* clear error */
php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql) TSRMLS_CC);
@@ -947,7 +942,7 @@ PHP_FUNCTION(mysqli_set_charset)
/* check unicode modus */
/* todo: we need also to support UCS2. This will not work when using SET NAMES */
- if (UG(unicode) && (csname_len != 4 || strncasecmp(cs_name, "utf8", 4))) {
+ if (csname_len != 4 || strncasecmp(cs_name, "utf8", 4)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Character set %s is not supported when running PHP with unicode.semantics=On.", cs_name);
RETURN_FALSE;
}
@@ -1003,24 +998,14 @@ PHP_FUNCTION(mysqli_get_charset)
state = 1; /* all charsets are compiled in */
#endif
- if (UG(unicode)) {
- add_property_utf8_string(return_value, "charset", (name) ? (char *)name : "", 1);
- add_property_utf8_string(return_value, "collation", (collation) ? (char *)collation : "", 1);
- add_property_utf8_string(return_value, "dir", (dir) ? (char *)dir : "", 1);
- } else {
- add_property_string(return_value, "charset", (name) ? (char *)name : "", 1);
- add_property_string(return_value, "collation",(collation) ? (char *)collation : "", 1);
- add_property_string(return_value, "dir", (dir) ? (char *)dir : "", 1);
- }
+ add_property_utf8_string(return_value, "charset", (name) ? (char *)name : "", 1);
+ add_property_utf8_string(return_value, "collation", (collation) ? (char *)collation : "", 1);
+ add_property_utf8_string(return_value, "dir", (dir) ? (char *)dir : "", 1);
add_property_long(return_value, "min_length", minlength);
add_property_long(return_value, "max_length", maxlength);
add_property_long(return_value, "number", number);
add_property_long(return_value, "state", state);
- if (UG(unicode)) {
- add_property_utf8_string(return_value, "comment", (comment) ? (char *)comment : "", 1);
- } else {
- add_property_string(return_value, "comment", (comment) ? (char *)comment : "", 1);
- }
+ add_property_utf8_string(return_value, "comment", (comment) ? (char *)comment : "", 1);
}
/* }}} */
#endif