Index: /trunk/xcache-test.ini
===================================================================
--- /trunk/xcache-test.ini	(revision 869)
+++ /trunk/xcache-test.ini	(revision 870)
@@ -8,5 +8,6 @@
 zend_extension=./modules/xcache.so
 xcache.cacher = On
-xcache.test=1
+xcache.test = 1
+xcache.stat = 1
 xcache.experimental = On
 xcache.size = 16M
Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 869)
+++ /trunk/xcache.c	(revision 870)
@@ -897,4 +897,16 @@
 
 #undef X_FREE
+}
+/* }}} */
+static char *xc_expand_url(const char *filepath, char *real_path TSRMLS_DC) /* {{{ */
+{
+	if (strstr(filepath, "://") != NULL) {
+		size_t filepath_len = strlen(filepath);
+		size_t copy_len = filepath_len > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : filepath_len;
+		memcpy(real_path, filepath, filepath_len);
+		real_path[copy_len] = '\0';
+		return real_path;
+	}
+	return expand_filepath(filepath, real_path TSRMLS_CC);
 }
 /* }}} */
@@ -980,5 +992,5 @@
 	xc_compiler_t *compiler = entry_find_include_path_data->compiler;
 
-	compiler->new_entry.entry.name.str.val = expand_filepath(filepath, compiler->opened_path_buffer TSRMLS_CC);
+	compiler->new_entry.entry.name.str.val = xc_expand_url(filepath, compiler->opened_path_buffer TSRMLS_CC);
 	compiler->new_entry.entry.name.str.len = strlen(compiler->new_entry.entry.name.str.val);
 
@@ -1018,5 +1030,5 @@
 		}
 
-		compiler->opened_path = expand_filepath(SG(request_info).path_translated, compiler->opened_path_buffer TSRMLS_CC);
+		compiler->opened_path = xc_expand_url(SG(request_info).path_translated, compiler->opened_path_buffer TSRMLS_CC);
 		return SUCCESS;
 	}
@@ -1027,5 +1039,5 @@
 			return FAILURE;
 		}
-		compiler->opened_path = expand_filepath(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);
+		compiler->opened_path = xc_expand_url(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);
 		return SUCCESS;
 	}
@@ -1045,8 +1057,37 @@
 		}
 
-		compiler->opened_path = expand_filepath(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);
+		compiler->opened_path = xc_expand_url(compiler->filename, compiler->opened_path_buffer TSRMLS_CC);
 		return SUCCESS;
 	}
 
+	return FAILURE;
+}
+/* }}} */
+static int xc_entry_php_resolve_opened_path(xc_compiler_t *compiler, struct stat *statbuf TSRMLS_DC) /* {{{ */
+{
+	if (xc_entry_php_quick_resolve_opened_path(compiler, statbuf TSRMLS_CC) == SUCCESS) {
+		/* opened_path resolved */
+		return SUCCESS;
+	}
+	/* fall back to real stat call */
+	else {
+#ifdef ZEND_ENGINE_2_3
+		char *opened_path = php_resolve_path(compiler->filename, compiler->filename_len, PG(include_path));
+		if (opened_path) {
+			strcpy(compiler->opened_path_buffer, opened_path);
+			efree(opened_path);
+			compiler->opened_path = compiler->opened_path_buffer;
+			if (!statbuf || VCWD_STAT(compiler->filename, statbuf) == 0) {
+				return SUCCESS;
+			}
+		}
+#else
+		char path_buffer[MAXPATHLEN];
+		if (xc_include_path_stat(compiler->filename, path_buffer, statbuf TSRMLS_CC) == SUCCESS) {
+			compiler->opened_path = xc_expand_url(path_buffer, compiler->opened_path_buffer TSRMLS_CC);
+			return SUCCESS;
+		}
+#endif
+	}
 	return FAILURE;
 }
@@ -1058,10 +1099,13 @@
 		time_t delta;
 
-		if (xc_entry_php_quick_resolve_opened_path(compiler, &buf TSRMLS_CC) != SUCCESS) {
-			char path_buffer[MAXPATHLEN];
-			if (xc_include_path_stat(compiler->filename, path_buffer, &buf TSRMLS_CC) != SUCCESS) {
+		if (compiler->opened_path) {
+			if (VCWD_STAT(compiler->opened_path, &buf) != 0) {
 				return FAILURE;
 			}
-			compiler->opened_path = expand_filepath(path_buffer, compiler->opened_path_buffer TSRMLS_CC);
+		}
+		else {
+			if (xc_entry_php_resolve_opened_path(compiler, &buf TSRMLS_CC) != SUCCESS) {
+				return FAILURE;
+			}
 		}
 
@@ -1098,5 +1142,5 @@
 			)
 		{
-			const char *filename_end = compiler->filename + strlen(compiler->filename);
+			const char *filename_end = compiler->filename + compiler->filename_len;
 			const char *basename = filename_end - 1;
 
@@ -1858,22 +1902,10 @@
 	ENTER_LOCK_EX(cache) {
 		if (!compiler->opened_path && xc_entry_find_include_path_dmz(compiler, compiler->filename, &stored_entry TSRMLS_CC) == SUCCESS) {
-			compiler->opened_path = compiler->opened_path_buffer;
+			compiler->opened_path = compiler->new_entry.entry.name.str.val;
 		}
 		else {
-			if (!compiler->opened_path) {
-				if (xc_entry_php_quick_resolve_opened_path(compiler, NULL TSRMLS_CC) == SUCCESS) {
-					/* opened_path resolved */
-				}
-				/* fall back to real stat call */
-				else {
-					char path_buffer[MAXPATHLEN];
-					if (xc_include_path_stat(compiler->filename, path_buffer, &statbuf TSRMLS_CC) == SUCCESS) {
-						compiler->opened_path = expand_filepath(path_buffer, compiler->opened_path_buffer TSRMLS_CC);
-					}
-					else {
-						gaveup = 1;
-						break;
-					}
-				}
+			if (!compiler->opened_path && xc_entry_php_resolve_opened_path(compiler, NULL TSRMLS_CC) != SUCCESS) {
+				gaveup = 1;
+				break;
 			}
 
@@ -2050,5 +2082,12 @@
 	 || !h->filename
 	 || !SG(request_info).path_translated
-	 || strstr(h->filename, "://") != NULL) {
+	 || strstr(h->filename, "://") != NULL
+#ifdef ZEND_ENGINE_2_3
+	 /* supported by php_resolve_path */
+	 || !XG(stat) && strstr(PG(include_path), "://") != NULL
+#else
+	 || strstr(PG(include_path), "://") != NULL
+#endif
+	 ) {
 		op_array = old_compile_file(h, type TSRMLS_CC);
 		TRACE("%s", "cacher not enabled");
@@ -2059,4 +2098,5 @@
 	compiler.opened_path = h->opened_path;
 	compiler.filename = compiler.opened_path ? compiler.opened_path : h->filename;
+	compiler.filename_len = strlen(compiler.filename);
 	if (xc_entry_php_init_key(&compiler TSRMLS_CC) != SUCCESS) {
 		TRACE("failed to init key for %s", compiler.filename);
Index: /trunk/xcache.h
===================================================================
--- /trunk/xcache.h	(revision 869)
+++ /trunk/xcache.h	(revision 870)
@@ -465,4 +465,5 @@
 typedef struct xc_compiler_t { /* {{{ */
 	const char *filename;
+	size_t filename_len;
 	const char *opened_path;
 	char opened_path_buffer[MAXPATHLEN];
