Index: trunk/xcache.c
===================================================================
--- trunk/xcache.c	(revision 82)
+++ trunk/xcache.c	(revision 86)
@@ -630,8 +630,4 @@
 	}
 
-	if (php_check_open_basedir(filename TSRMLS_CC) != 0) {
-		return NULL;
-	}
-
 	stored_xce = NULL;
 	op_array = NULL;
@@ -693,4 +689,10 @@
 	}
 
+	filename = h->opened_path ? h->opened_path : h->filename;
+	if (xce.name.str.val != filename) {
+		xce.name.str.val = filename;
+		xce.name.str.len = strlen(filename);
+	}
+
 #ifdef HAVE_XCACHE_OPTIMIZER
 	if (XG(optimizer)) {
@@ -780,4 +782,8 @@
 
 restore:
+	if (php_check_open_basedir(stored_xce->name.str.val TSRMLS_CC) != 0) {
+		return NULL;
+	}
+
 #ifdef DEBUG
 	fprintf(stderr, "restoring\n");
