Index: /trunk/utils.c
===================================================================
--- /trunk/utils.c	(revision 953)
+++ /trunk/utils.c	(revision 954)
@@ -585,6 +585,8 @@
 	ZEND_24(NOTHING, const) char *filename;
 
+#ifndef ZEND_ENGINE_2_2
 	HashTable orig_included_files;
 	HashTable *tmp_included_files;
+#endif
 
 #ifdef HAVE_XCACHE_CONSTANT
@@ -772,5 +774,7 @@
 	memset(sandbox, 0, sizeof(sandbox[0]));
 
+#ifndef ZEND_ENGINE_2_2
 	memcpy(&OG(included_files), &EG(included_files), sizeof(EG(included_files)));
+#endif
 
 #ifdef HAVE_XCACHE_CONSTANT
@@ -791,7 +795,11 @@
 #endif
 
+#ifndef ZEND_ENGINE_2_2
 	TG(included_files) = &EG(included_files);
-
+#endif
+
+#ifndef ZEND_ENGINE_2_2
 	zend_hash_init_ex(TG(included_files), 5, NULL, NULL, 0, 1);
+#endif
 #ifdef HAVE_XCACHE_CONSTANT
 	h = OG(zend_constants);
@@ -926,6 +934,8 @@
 #endif
 
+#ifndef ZEND_ENGINE_2_2
 	i = 1;
 	zend_hash_add(&OG(included_files), sandbox->filename, strlen(sandbox->filename) + 1, (void *)&i, sizeof(int), NULL);
+#endif
 }
 /* }}} */
@@ -978,8 +988,12 @@
 	zend_hash_destroy(&TG(auto_globals));
 #endif
+#ifndef ZEND_ENGINE_2_2
 	zend_hash_destroy(TG(included_files));
-
+#endif
+
+#ifndef ZEND_ENGINE_2_2
 	/* restore orig here, as EG/CG holded tmp before */
 	memcpy(&EG(included_files), &OG(included_files), sizeof(EG(included_files)));
+#endif
 
 #ifdef XCACHE_ERROR_CACHING
Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 953)
+++ /trunk/xcache.c	(revision 954)
@@ -746,5 +746,5 @@
 /* }}} */
 
-static zend_op_array *xc_entry_install(xc_entry_php_t *entry_php TSRMLS_DC) /* {{{ */
+static zend_op_array *xc_entry_install(xc_entry_php_t *entry_php, zend_file_handle *h TSRMLS_DC) /* {{{ */
 {
 	zend_uint i;
@@ -815,5 +815,10 @@
 
 	i = 1;
+#ifndef ZEND_ENGINE_2_2
 	zend_hash_add(&EG(included_files), entry_php->entry.name.str.val, entry_php->entry.name.str.len+1, (void *)&i, sizeof(int), NULL);
+#endif
+	if (h) {
+		zend_llist_add_element(&CG(open_files), h);
+	}
 
 #ifndef ZEND_ENGINE_2
@@ -1840,5 +1845,5 @@
 }
 /* }}} */
-static zend_op_array *xc_compile_restore(xc_entry_php_t *stored_entry, xc_entry_data_php_t *stored_php TSRMLS_DC) /* {{{ */
+static zend_op_array *xc_compile_restore(xc_entry_php_t *stored_entry, xc_entry_data_php_t *stored_php, zend_file_handle *h TSRMLS_DC) /* {{{ */
 {
 	zend_op_array *op_array;
@@ -1860,5 +1865,5 @@
 	catched = 0;
 	zend_try {
-		op_array = xc_entry_install(&restored_entry TSRMLS_CC);
+		op_array = xc_entry_install(&restored_entry, h TSRMLS_CC);
 	} zend_catch {
 		catched = 1;
@@ -2118,5 +2123,5 @@
 	/* found entry */
 	if (stored_entry && stored_php) {
-		return xc_compile_restore(stored_entry, stored_php TSRMLS_CC);
+		return xc_compile_restore(stored_entry, stored_php, NULL /* h */ TSRMLS_CC);
 	}
 
@@ -2134,5 +2139,5 @@
 	op_array = xc_sandbox(xc_compile_file_sandboxed, (void *) &sandboxed_compiler, h->opened_path ? h->opened_path : h->filename TSRMLS_CC);
 	if (sandboxed_compiler.stored_entry) {
-		return xc_compile_restore(sandboxed_compiler.stored_entry, sandboxed_compiler.stored_php TSRMLS_CC);
+		return xc_compile_restore(sandboxed_compiler.stored_entry, sandboxed_compiler.stored_php, sandboxed_compiler.h TSRMLS_CC);
 	}
 	else {
