Index: zend_operators.c
===================================================================
RCS file: /repository/ZendEngine2/zend_operators.c,v
retrieving revision 1.261
diff -u -r1.261 zend_operators.c
--- zend_operators.c	16 Dec 2006 00:21:41 -0000	1.261
+++ zend_operators.c	19 Dec 2006 12:17:59 -0000
@@ -356,7 +356,10 @@
 
 ZEND_API int convert_to_long(zval *op)
 {
-	return convert_to_long_base(op, 10);
+	if (Z_TYPE_P(op) != IS_LONG) {
+		return convert_to_long_base(op, 10);
+	}
+	return SUCCESS;
 }
 
 
@@ -1672,17 +1675,27 @@
 ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
 {
 	zval op1_copy, op2_copy;
-	int use_copy1, use_copy2;
+	int use_copy1 = 0, use_copy2 = 0;
 	zend_uchar result_type;
 
-	if (Z_TYPE_P(op1) == IS_UNICODE || Z_TYPE_P(op2) == IS_UNICODE) {
-		zend_make_unicode_zval(op1, &op1_copy, &use_copy1);
-		zend_make_unicode_zval(op2, &op2_copy, &use_copy2);
+	if (Z_TYPE_P(op1) == IS_UNICODE) {
+		if (Z_TYPE_P(op2) != IS_UNICODE) {
+			zend_make_unicode_zval(op2, &op2_copy, &use_copy2);
+		}
+		result_type = IS_UNICODE;
+	} else if (Z_TYPE_P(op2) == IS_UNICODE) {
+		if (Z_TYPE_P(op1) != IS_UNICODE) {
+			zend_make_unicode_zval(op1, &op1_copy, &use_copy1);
+		}
 		result_type = IS_UNICODE;
 	} else {
+		if (Z_TYPE_P(op1) != IS_STRING) {
+			zend_make_string_zval(op1, &op1_copy, &use_copy1);
+		}
+		if (Z_TYPE_P(op2) != IS_STRING) {
+			zend_make_string_zval(op2, &op2_copy, &use_copy2);
+		}
 		result_type = IS_STRING;
-		zend_make_string_zval(op1, &op1_copy, &use_copy1);
-		zend_make_string_zval(op2, &op2_copy, &use_copy2);
 	}
 
 	if (use_copy1) {
@@ -1713,7 +1726,7 @@
 			memcpy(Z_STRVAL_P(result), Z_STRVAL_P(op1), Z_STRLEN_P(op1));
 			memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
 			Z_STRVAL_P(result)[Z_STRLEN_P(result)] = 0;
-			Z_TYPE_P(result) = result_type;
+			Z_TYPE_P(result) = IS_STRING;
 		}
 	}
 	if (use_copy1) {
@@ -1729,11 +1742,15 @@
 ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
 {
 	zval op1_copy, op2_copy;
-	int use_copy1, use_copy2;
+	int use_copy1 = 0, use_copy2 = 0;
 
 	if (UG(unicode)) {
-		zend_make_unicode_zval(op1, &op1_copy, &use_copy1);
-		zend_make_unicode_zval(op2, &op2_copy, &use_copy2);
+		if (Z_TYPE_P(op1) != IS_UNICODE) {
+			zend_make_unicode_zval(op1, &op1_copy, &use_copy1);
+		}
+		if (Z_TYPE_P(op2) != IS_UNICODE) {
+			zend_make_unicode_zval(op2, &op2_copy, &use_copy2);
+		}
 	} else {
 		zend_make_printable_zval(op1, &op1_copy, &use_copy1);
 		zend_make_printable_zval(op2, &op2_copy, &use_copy2);
@@ -1765,11 +1782,15 @@
 ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
 {
 	zval op1_copy, op2_copy;
-	int use_copy1, use_copy2;
+	int use_copy1 = 0, use_copy2 = 0;
 
 	if (UG(unicode)) {
-		zend_make_unicode_zval(op1, &op1_copy, &use_copy1);
-		zend_make_unicode_zval(op2, &op2_copy, &use_copy2);
+		if (Z_TYPE_P(op1) != IS_UNICODE) {
+			zend_make_unicode_zval(op1, &op1_copy, &use_copy1);
+		}
+		if (Z_TYPE_P(op2) != IS_UNICODE) {
+			zend_make_unicode_zval(op2, &op2_copy, &use_copy2);
+		}
 	} else {
 		zend_make_printable_zval(op1, &op1_copy, &use_copy1);
 		zend_make_printable_zval(op2, &op2_copy, &use_copy2);
@@ -2667,12 +2688,14 @@
 	zval s1_copy, s2_copy;
 	int use_copy1 = 0, use_copy2 = 0;
 
-	if (Z_TYPE_P(s1) != IS_UNICODE || Z_TYPE_P(s2) != IS_UNICODE) {
+	if (Z_TYPE_P(s1) != IS_UNICODE) {
 		zend_make_unicode_zval(s1, &s1_copy, &use_copy1);
-		zend_make_unicode_zval(s2, &s2_copy, &use_copy2);
 		if (use_copy1) {
 			s1 = &s1_copy;
 		}
+	}
+	if (Z_TYPE_P(s2) != IS_UNICODE) {
+		zend_make_unicode_zval(s2, &s2_copy, &use_copy2);
 		if (use_copy2) {
 			s2 = &s2_copy;
 		}
Index: zend_operators.h
===================================================================
RCS file: /repository/ZendEngine2/zend_operators.h,v
retrieving revision 1.115
diff -u -r1.115 zend_operators.h
--- zend_operators.h	16 Dec 2006 00:21:41 -0000	1.115
+++ zend_operators.h	19 Dec 2006 12:07:59 -0000
@@ -267,10 +267,12 @@
 ZEND_API void multi_convert_to_string_ex(int argc, ...);
 ZEND_API int add_char_to_string(zval *result, zval *op1, zval *op2);
 ZEND_API int add_string_to_string(zval *result, zval *op1, zval *op2);
-#define convert_to_string(op)		     	 _convert_to_string((op) ZEND_FILE_LINE_CC)
-#define convert_to_string_with_converter(op, conv) _convert_to_string_with_converter((op), (conv) TSRMLS_CC ZEND_FILE_LINE_CC)
-#define convert_to_unicode(op)               _convert_to_unicode((op) TSRMLS_CC ZEND_FILE_LINE_CC)
-#define convert_to_unicode_with_converter(op, conv) _convert_to_unicode_with_converter((op), (conv) TSRMLS_CC ZEND_FILE_LINE_CC)
+#define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); }
+#define convert_to_string_with_converter(op, conv) \
+	if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string_with_converter((op), (conv) TSRMLS_CC ZEND_FILE_LINE_CC); }
+#define convert_to_unicode(op) if (Z_TYPE_P(op) != IS_UNICODE) { _convert_to_unicode((op) TSRMLS_CC ZEND_FILE_LINE_CC); }
+#define convert_to_unicode_with_converter(op, conv) \
+	if (Z_TYPE_P(op) != IS_UNICODE) { _convert_to_unicode_with_converter((op), (conv) TSRMLS_CC ZEND_FILE_LINE_CC); }
 #define convert_to_text(op) (UG(unicode)?convert_to_unicode(op):convert_to_string(op))
 
 ZEND_API double zend_string_to_double(const char *number, zend_uint length);
Index: ext/standard/basic_functions.c
===================================================================
RCS file: /repository/php-src/ext/standard/basic_functions.c,v
retrieving revision 1.832
diff -u -r1.832 basic_functions.c
--- ext/standard/basic_functions.c	12 Dec 2006 18:24:16 -0000	1.832
+++ ext/standard/basic_functions.c	13 Dec 2006 12:27:58 -0000
@@ -4655,13 +4655,13 @@
 			}
 		} else {
 			/* other strings */
-			if(zend_hash_find(HASH_OF(return_value), optname, strlen(optname)+1, (void **)&args) != FAILURE) {
+			if(zend_hash_find(HASH_OF(return_value), optname, optname_len + 1, (void **)&args) != FAILURE) {
 				if(Z_TYPE_PP(args) != IS_ARRAY) {
 					convert_to_array_ex(args);
 				}
 				zend_hash_next_index_insert(HASH_OF(*args),  (void *)&val, sizeof(zval *), NULL);
 			} else {
-				zend_hash_add(HASH_OF(return_value), optname, strlen(optname)+1, (void *)&val, sizeof(zval *), NULL);
+				zend_hash_add(HASH_OF(return_value), optname, optname_len + 1, (void *)&val, sizeof(zval *), NULL);
 			}
 		}
 	}
Index: ext/wddx/wddx.c
===================================================================
RCS file: /repository/php-src/ext/wddx/wddx.c,v
retrieving revision 1.140
diff -u -r1.140 wddx.c
--- ext/wddx/wddx.c	8 Oct 2006 13:34:24 -0000	1.140
+++ ext/wddx/wddx.c	13 Dec 2006 12:30:28 -0000
@@ -975,10 +975,11 @@
 						add_property_zval(ent2->data, ent1->varname, ent1->data);
 						EG(scope) = old_scope;
 					} else {
-						long l;  
+						long l;
 						double d;
+						int varname_len = strlen(ent1->varname);
 				
-						switch (is_numeric_string(ent1->varname, strlen(ent1->varname), &l, &d, 0)) {
+						switch (is_numeric_string(ent1->varname, varname_len, &l, &d, 0)) {
 							case IS_DOUBLE:
 								if (d > INT_MAX) {
 									goto bigint;
@@ -989,7 +990,7 @@
 								break;
 							default:
 bigint:
-								zend_hash_update(target_hash,ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);
+								zend_hash_update(target_hash,ent1->varname, varname_len + 1, &ent1->data, sizeof(zval *), NULL);
 						}
 					}
 					efree(ent1->varname);
