Index: branches/1.2/xcache.c
===================================================================
--- branches/1.2/xcache.c	(revision 406)
+++ branches/1.2/xcache.c	(revision 408)
@@ -98,4 +98,5 @@
 
 static zend_bool xc_initized = 0;
+static zend_compile_file_t *origin_compile_file = NULL;
 static zend_compile_file_t *old_compile_file = NULL;
 static zend_llist_element  *xc_llist_zend_extension = NULL;
@@ -838,4 +839,10 @@
 }
 /* }}} */
+static zend_op_array *xc_check_initial_compile_file(zend_file_handle *h, int type TSRMLS_DC) /* {{{ */
+{
+	XG(initial_compile_file_called) = 1;
+	return origin_compile_file(h, type TSRMLS_CC);
+}
+/* }}} */
 static zend_op_array *xc_compile_file(zend_file_handle *h, int type TSRMLS_DC) /* {{{ */
 {
@@ -941,4 +948,5 @@
 	old_constinfo_cnt  = zend_hash_num_elements(EG(zend_constants));
 
+	XG(initial_compile_file_called) = 0;
 	zend_try {
 		op_array = old_compile_file(h, type TSRMLS_CC);
@@ -954,4 +962,9 @@
 		goto err_oparray;
 	}
+
+	if (!XG(initial_compile_file_called)) {
+		xc_sandbox_free(&sandbox, XC_InstallNoBinding TSRMLS_CC);
+        return op_array;
+    }
 
 	filename = h->opened_path ? h->opened_path : h->filename;
@@ -1125,13 +1138,13 @@
 	if (xc_test && stored_xce) {
 		/* free it, no install. restore now */
-		xc_sandbox_free(&sandbox, 0 TSRMLS_CC);
+		xc_sandbox_free(&sandbox, XC_NoInstall TSRMLS_CC);
 	}
 	else if (!op_array) {
 		/* failed to compile free it, no install */
-		xc_sandbox_free(&sandbox, 0 TSRMLS_CC);
+		xc_sandbox_free(&sandbox, XC_NoInstall TSRMLS_CC);
 	}
 	else {
 		CG(active_op_array) = op_array;
-		xc_sandbox_free(&sandbox, 1 TSRMLS_CC);
+		xc_sandbox_free(&sandbox, XC_Install TSRMLS_CC);
 	}
 
@@ -1378,4 +1391,9 @@
 		zend_compile_file = old_compile_file;
 		old_compile_file = NULL;
+	}
+
+	if (origin_compile_file) {
+		zend_compile_file = origin_compile_file;
+		origin_compile_file = NULL;
 	}
 
@@ -2746,5 +2764,5 @@
 #endif
 /* }}} */
-static startup_func_t xc_last_ext_startup = NULL;
+static startup_func_t xc_last_ext_startup;
 static int xc_zend_startup_last(zend_extension *extension) /* {{{ */
 {
@@ -2767,4 +2785,10 @@
 {
 	xc_zend_extension_gotup = 1;
+
+	if (!origin_compile_file) {
+		origin_compile_file = zend_compile_file;
+		zend_compile_file = xc_check_initial_compile_file;
+	}
+
 	if (zend_llist_count(&zend_extensions) > 1) {
 		zend_llist_position lpos;
