Index: trunk/xcache.c
===================================================================
--- trunk/xcache.c	(revision 862)
+++ trunk/xcache.c	(revision 864)
@@ -199,4 +199,24 @@
 			}
 #endif
+
+#ifdef IS_UNICODE
+			if (entry1->name_type == IS_UNICODE) {
+				assert(IS_ABSOLUTE_PATH(entry1->name.ustr.val, entry1->name.ustr.len));
+			}
+			else
+#endif
+			{
+				assert(IS_ABSOLUTE_PATH(entry1->name.str.val, entry1->name.str.len));
+			}
+
+#ifdef IS_UNICODE
+			if (entry2->name_type == IS_UNICODE) {
+				assert(IS_ABSOLUTE_PATH(entry2->name.ustr.val, entry2->name.ustr.len));
+			}
+			else
+#endif
+			{
+				assert(IS_ABSOLUTE_PATH(entry2->name.str.val, entry2->name.str.len));
+			}
 			/* fall */
 
@@ -204,5 +224,8 @@
 			do {
 #ifdef IS_UNICODE
-				if (entry1->name_type == IS_UNICODE) {
+				if (entry1->name_type != entry2->name_type) {
+					return 0;
+				}
+				else if (entry1->name_type == IS_UNICODE) {
 					if (entry1->name.ustr.len != entry2->name.ustr.len) {
 						return 0;
@@ -210,9 +233,12 @@
 					return memcmp(entry1->name.ustr.val, entry2->name.ustr.val, (entry1->name.ustr.len + 1) * sizeof(UChar)) == 0;
 				}
-#endif
-				if (entry1->name.str.len != entry2->name.str.len) {
-					return 0;
+				else
+#endif
+				{
+					if (entry1->name.str.len != entry2->name.str.len) {
+						return 0;
+					}
+					return memcmp(entry1->name.str.val, entry2->name.str.val, entry1->name.str.len + 1) == 0;
 				}
-				return memcmp(entry1->name.str.val, entry2->name.str.val, entry1->name.str.len + 1) == 0;
 
 			} while(0);
@@ -973,14 +999,13 @@
 /* }}} */
 
-static int xc_entry_init_key_php(xc_compiler_t *compiler TSRMLS_DC) /* {{{ */
-{
-	if (!compiler->filename || !SG(request_info).path_translated) {
-		return FAILURE;
-	}
-
-	if (strstr(compiler->filename, "://") != NULL) {
-		return FAILURE;
-	}
-
+static int xc_entry_php_resolve_opened_path(xc_compiler_t *compiler TSRMLS_DC) /* {{{ */
+{
+	assert(!compiler->opened_path);
+	compiler->opened_path = expand_filepath(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);
+	return SUCCESS;
+}
+/* }}} */
+static int xc_entry_php_init_key(xc_compiler_t *compiler TSRMLS_DC) /* {{{ */
+{
 	if (XG(stat)) {
 		struct stat buf, *pbuf;
@@ -1049,5 +1074,10 @@
 		compiler->new_entry.file_inode   = 0;
 #endif
-		compiler->opened_path = expand_filepath(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);
+	}
+
+	if (!compiler->new_entry.file_inode) {
+		if (!compiler->opened_path) {
+			xc_entry_php_resolve_opened_path(compiler TSRMLS_CC);
+		}
 	}
 
@@ -1094,5 +1124,5 @@
 }
 /* }}} */
-static int xc_entry_init_key_php_md5(xc_cache_t *cache, xc_compiler_t *compiler TSRMLS_DC) /* {{{ */
+static int xc_entry_data_php_init_md5(xc_cache_t *cache, xc_compiler_t *compiler TSRMLS_DC) /* {{{ */
 {
 	unsigned char   buf[1024];
@@ -1134,5 +1164,5 @@
 }
 /* }}} */
-static void xc_entry_init_key_php_entry(xc_entry_php_t *entry_php, const char *filepath TSRMLS_DC) /* {{{*/
+static void xc_entry_php_init(xc_entry_php_t *entry_php, const char *filepath TSRMLS_DC) /* {{{*/
 {
 	entry_php->filepath     = ZEND_24((char *), NOTHING) filepath;
@@ -1635,5 +1665,5 @@
 		unsigned int i;
 
-		xc_entry_init_key_php_entry(&compiler->new_entry, zend_get_compiled_filename(TSRMLS_C) TSRMLS_CC);
+		xc_entry_php_init(&compiler->new_entry, zend_get_compiled_filename(TSRMLS_C) TSRMLS_CC);
 		memset(&const_usage, 0, sizeof(const_usage));
 
@@ -1825,5 +1855,5 @@
 		TRACE("miss entry %d:%s", compiler->new_entry.file_inode, compiler->new_entry.entry.name.str.val);
 
-		if (xc_entry_init_key_php_md5(cache, compiler TSRMLS_CC) != SUCCESS) {
+		if (xc_entry_data_php_init_md5(cache, compiler TSRMLS_CC) != SUCCESS) {
 			gaveup = 1;
 			break;
@@ -1832,12 +1862,11 @@
 		stored_php = xc_php_find_dmz(cache, &compiler->new_php TSRMLS_CC);
 
-		/* miss but compiling */
 		if (stored_php) {
 			compiler->new_entry.php = stored_php;
 			xc_php_addref_dmz(stored_php);
 			if (!compiler->opened_path) {
-				compiler->opened_path = expand_filepath(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);
-			}
-			xc_entry_init_key_php_entry(&compiler->new_entry, compiler->opened_path TSRMLS_CC);
+				xc_entry_php_resolve_opened_path(compiler TSRMLS_CC);
+			}
+			xc_entry_php_init(&compiler->new_entry, compiler->opened_path TSRMLS_CC);
 			stored_entry = xc_entry_php_store_dmz(cache, compiler->entry_hash.entryslotid, &compiler->new_entry TSRMLS_CC);
 			TRACE(" cached %d:%s, holding", compiler->new_entry.file_inode, stored_entry->entry.name.str.val);
@@ -1978,5 +2007,9 @@
 
 	TRACE("xc_compile_file: type=%d name=%s", h->type, h->filename ? h->filename : "NULL");
-	if (!XG(cacher)) {
+
+	if (!XG(cacher)
+	 || !h->filename
+	 || !SG(request_info).path_translated
+	 || strstr(h->filename, "://") != NULL) {
 		op_array = old_compile_file(h, type TSRMLS_CC);
 		TRACE("%s", "cacher not enabled");
@@ -1987,5 +2020,5 @@
 	compiler.opened_path = h->opened_path;
 	compiler.filename = compiler.opened_path ? compiler.opened_path : h->filename;
-	if (xc_entry_init_key_php(&compiler TSRMLS_CC) != SUCCESS) {
+	if (xc_entry_php_init_key(&compiler TSRMLS_CC) != SUCCESS) {
 		TRACE("failed to init key for %s", compiler.filename);
 		return old_compile_file(h, type TSRMLS_CC);
@@ -2631,9 +2664,16 @@
 	xc_hash_value_t hv;
 
+	switch (name->type) {
 #ifdef IS_UNICODE
-	convert_to_unicode(name);
+		case IS_UNICODE:
+		case IS_STRING:
+#endif
+		default:
+#ifdef IS_UNICODE
+			convert_to_unicode(name);
 #else
-	convert_to_string(name);
-#endif
+			convert_to_string(name);
+#endif
+	}
 
 #ifdef IS_UNICODE
