Index: /trunk/processor/hashtable.m4
===================================================================
--- /trunk/processor/hashtable.m4	(revision 195)
+++ /trunk/processor/hashtable.m4	(revision 196)
@@ -1,3 +1,3 @@
-dnl DEF_HASH_TABLE_FUNC(1:name, 2:datatype [, 3:dataname])
+dnl DEF_HASH_TABLE_FUNC(1:name, 2:datatype [, 3:dataname] [, 4:check_function])
 define(`DEF_HASH_TABLE_FUNC', `
 	DEF_STRUCT_P_FUNC(`HashTable', `$1', `
@@ -94,4 +94,13 @@
 
 		for (b = src->pListHead; b != NULL; b = b->pListNext) {
+			ifelse(`$4', `', `', `
+				pushdef(`BUCKET', `b')
+				if ($4 == ZEND_HASH_APPLY_REMOVE) {
+					IFCOPY(`dst->nNumOfElements --;')
+					continue;
+				}
+				popdef(`BUCKET')
+		  ')
+		  
 			IFCALCCOPY(`bucketsize = BUCKET_SIZE(b);')
 			ALLOC(pnew, char, bucketsize, , Bucket)
Index: /trunk/processor/head.m4
===================================================================
--- /trunk/processor/head.m4	(revision 195)
+++ /trunk/processor/head.m4	(revision 196)
@@ -247,4 +247,51 @@
 }
 /* }}} */
+static int xc_hash_static_member_check(xc_processor_t *processor, Bucket *b TSRMLS_DC) /* {{{ */
+{
+	zend_class_entry *src = processor->active_class_entry_src;
+	if (src->parent) {
+		zval **srczv;
+		if (zend_hash_quick_find(CE_STATIC_MEMBERS(src), b->arKey, b->nKeyLength, b->h, (void **) &srczv) == SUCCESS) {
+			zval **zv = (zval **) b->pData;
+			if (*srczv == *zv) {
+				return ZEND_HASH_APPLY_REMOVE;
+			}
+		}
+	}
+	return ZEND_HASH_APPLY_KEEP;
+}
+/* }}} */
+/* fix static members on restore */
+static void inherit_static_prop(zval **p) /* {{{ */
+{
+	(*p)->refcount++;
+	(*p)->is_ref = 1;
+}
+/* }}} */
+static void xc_fix_static_members(xc_processor_t *processor, zend_class_entry *dst TSRMLS_DC) /* {{{ */
+{
+	zend_class_entry *parent_ce = dst->parent;
+	if (parent_ce->type != dst->type) {
+		/* User class extends internal class */
+		zend_update_class_constants(parent_ce  TSRMLS_CC);
+		zend_hash_merge(&dst->default_static_members, CE_STATIC_MEMBERS(parent_ce), (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0);
+	}
+	else {
+		zend_hash_merge(&dst->default_static_members, &parent_ce->default_static_members, (void (*)(void *)) inherit_static_prop, NULL, sizeof(zval *), 0);
+	}
+
+	/*
+	HashPosition pos;
+	HashTable *pmembers = CE_STATIC_MEMBERS(dst->parent);
+	zval **zv;
+	for (zend_hash_internal_pointer_reset_ex(pmembers, &pos);
+			zend_hash_get_current_data_ex(pmembers, (void **) &zv, &pos) == SUCCESS;
+			zend_hash_move_forward_ex(pmembers, &pos)) {
+			if (zend_hash_quick_find(parent->static_members, p->arKey, p->nKeyLength, p->h, &pprop.ptr) == SUCCESS) {
+			}
+	}
+	*/
+}
+/* }}} */
 #endif
 /* {{{ call op_array ctor handler */
Index: /trunk/processor/processor.m4
===================================================================
--- /trunk/processor/processor.m4	(revision 195)
+++ /trunk/processor/processor.m4	(revision 196)
@@ -65,4 +65,5 @@
 dnl }}}
 DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr',           `zval_ptr')
+DEF_HASH_TABLE_FUNC(`HashTable_zval_ptr_static_member_check',  `zval_ptr', , `xc_hash_static_member_check(processor, BUCKET TSRMLS_CC)')
 #ifdef HAVE_XCACHE_CONSTANT
 DEF_HASH_TABLE_FUNC(`HashTable_zend_constant',      `zend_constant')
@@ -297,9 +298,10 @@
 	STRUCT(HashTable, properties_info, HashTable_zend_property_info)
 #	ifdef ZEND_ENGINE_2_1
-	STRUCT(HashTable, default_static_members, HashTable_zval_ptr)
+	STRUCT(HashTable, default_static_members, IFSTORE(HashTable_zval_ptr_static_member_check, HashTable_zval_ptr))
 	IFCOPY(`dst->static_members = &dst->default_static_members;')
+	IFRESTORE(`if (dst->parent) xc_fix_static_members(processor, dst TSRMLS_CC);')
 	DONE(static_members)
 #	else
-	STRUCT_P(HashTable, static_members, HashTable_zval_ptr)
+	STRUCT_P(HashTable, static_members, IFSTORE(HashTable_zval_ptr_static_member_check, HashTable_zval_ptr))
 #	endif
 	STRUCT(HashTable, constants_table, HashTable_zval_ptr)
Index: /trunk/xcache.c
===================================================================
--- /trunk/xcache.c	(revision 195)
+++ /trunk/xcache.c	(revision 196)
@@ -2462,5 +2462,5 @@
 static startup_func_t xc_last_ext_startup;
 static zend_llist_element *xc_llist_element;
-static xc_ptr_compare_func(void *p1, void *p2) /* {{{ */
+static int xc_ptr_compare_func(void *p1, void *p2) /* {{{ */
 {
 	return p1 == p2;
