@@ -95,6 +95,7 @@ PHP_DOM_EXPORT zend_class_entry *dom_namespace_info_class_entry;
95
95
static zend_object_handlers dom_object_handlers ;
96
96
static zend_object_handlers dom_nnodemap_object_handlers ;
97
97
static zend_object_handlers dom_nodelist_object_handlers ;
98
+ static zend_object_handlers dom_unset_children_property_object_handlers ;
98
99
static zend_object_handlers dom_modern_nnodemap_object_handlers ;
99
100
static zend_object_handlers dom_modern_nodelist_object_handlers ;
100
101
static zend_object_handlers dom_html_collection_object_handlers ;
@@ -667,14 +668,35 @@ static zend_object *dom_objects_store_clone_obj(zend_object *zobject) /* {{{ */
667
668
static zend_object * dom_modern_element_clone_obj (zend_object * zobject )
668
669
{
669
670
zend_object * clone = dom_objects_store_clone_obj (zobject );
671
+ dom_object * intern = php_dom_obj_from_obj (clone );
670
672
671
673
/* The $classList property is unique per element, and cached due to its [[SameObject]] requirement.
672
674
* Remove it from the clone so the clone will get a fresh instance upon demand. */
673
- zval * class_list = dom_element_class_list_zval (php_dom_obj_from_obj ( clone ) );
675
+ zval * class_list = dom_element_class_list_zval (intern );
674
676
if (!Z_ISUNDEF_P (class_list )) {
675
677
zval_ptr_dtor (class_list );
676
678
ZVAL_UNDEF (class_list );
677
679
}
680
+ /* Likewise for $children */
681
+ zval * children = dom_parent_node_children (intern );
682
+ if (!Z_ISUNDEF_P (children )) {
683
+ zval_ptr_dtor (children );
684
+ ZVAL_UNDEF (children );
685
+ }
686
+
687
+ return clone ;
688
+ }
689
+
690
+ static zend_object * dom_clone_obj_unset_children_property (zend_object * zobject )
691
+ {
692
+ zend_object * clone = dom_objects_store_clone_obj (zobject );
693
+ dom_object * intern = php_dom_obj_from_obj (clone );
694
+
695
+ zval * children = dom_parent_node_children (intern );
696
+ if (!Z_ISUNDEF_P (children )) {
697
+ zval_ptr_dtor (children );
698
+ ZVAL_UNDEF (children );
699
+ }
678
700
679
701
return clone ;
680
702
}
@@ -776,6 +798,9 @@ PHP_MINIT_FUNCTION(dom)
776
798
memcpy (& dom_modern_element_object_handlers , & dom_object_handlers , sizeof (zend_object_handlers ));
777
799
dom_modern_element_object_handlers .clone_obj = dom_modern_element_clone_obj ;
778
800
801
+ memcpy (& dom_unset_children_property_object_handlers , & dom_object_handlers , sizeof (zend_object_handlers ));
802
+ dom_unset_children_property_object_handlers .clone_obj = dom_clone_obj_unset_children_property ;
803
+
779
804
memcpy (& dom_nnodemap_object_handlers , & dom_object_handlers , sizeof (zend_object_handlers ));
780
805
dom_nnodemap_object_handlers .free_obj = dom_nnodemap_objects_free_storage ;
781
806
dom_nnodemap_object_handlers .read_dimension = dom_nodemap_read_dimension ;
@@ -796,6 +821,8 @@ PHP_MINIT_FUNCTION(dom)
796
821
memcpy (& dom_html_collection_object_handlers , & dom_modern_nodelist_object_handlers , sizeof (zend_object_handlers ));
797
822
dom_html_collection_object_handlers .read_dimension = dom_html_collection_read_dimension ;
798
823
dom_html_collection_object_handlers .has_dimension = dom_html_collection_has_dimension ;
824
+ dom_html_collection_object_handlers .get_gc = dom_html_collection_get_gc ;
825
+ dom_html_collection_object_handlers .clone_obj = NULL ;
799
826
800
827
memcpy (& dom_object_namespace_node_handlers , & dom_object_handlers , sizeof (zend_object_handlers ));
801
828
dom_object_namespace_node_handlers .offset = XtOffsetOf (dom_object_namespace_node , dom .std );
@@ -910,9 +937,10 @@ PHP_MINIT_FUNCTION(dom)
910
937
911
938
dom_modern_documentfragment_class_entry = register_class_Dom_DocumentFragment (dom_modern_node_class_entry , dom_modern_parentnode_class_entry );
912
939
dom_modern_documentfragment_class_entry -> create_object = dom_objects_new ;
913
- dom_modern_documentfragment_class_entry -> default_object_handlers = & dom_object_handlers ;
940
+ dom_modern_documentfragment_class_entry -> default_object_handlers = & dom_unset_children_property_object_handlers ;
914
941
zend_hash_init (& dom_modern_documentfragment_prop_handlers , 0 , NULL , NULL , true);
915
942
943
+ DOM_REGISTER_PROP_HANDLER (& dom_modern_documentfragment_prop_handlers , "children" , dom_parent_node_children_read , NULL );
916
944
DOM_REGISTER_PROP_HANDLER (& dom_modern_documentfragment_prop_handlers , "firstElementChild" , dom_parent_node_first_element_child_read , NULL );
917
945
DOM_REGISTER_PROP_HANDLER (& dom_modern_documentfragment_prop_handlers , "lastElementChild" , dom_parent_node_last_element_child_read , NULL );
918
946
DOM_REGISTER_PROP_HANDLER (& dom_modern_documentfragment_prop_handlers , "childElementCount" , dom_parent_node_child_element_count , NULL );
@@ -921,7 +949,7 @@ PHP_MINIT_FUNCTION(dom)
921
949
zend_hash_add_new_ptr (& classes , dom_modern_documentfragment_class_entry -> name , & dom_modern_documentfragment_prop_handlers );
922
950
923
951
dom_abstract_base_document_class_entry = register_class_Dom_Document (dom_modern_node_class_entry , dom_modern_parentnode_class_entry );
924
- dom_abstract_base_document_class_entry -> default_object_handlers = & dom_object_handlers ;
952
+ dom_abstract_base_document_class_entry -> default_object_handlers = & dom_unset_children_property_object_handlers ;
925
953
zend_hash_init (& dom_abstract_base_document_prop_handlers , 0 , NULL , NULL , true);
926
954
DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "implementation" , dom_modern_document_implementation_read , NULL );
927
955
DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "URL" , dom_document_document_uri_read , dom_document_document_uri_write );
@@ -931,6 +959,7 @@ PHP_MINIT_FUNCTION(dom)
931
959
DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "inputEncoding" , dom_document_encoding_read , dom_html_document_encoding_write );
932
960
DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "doctype" , dom_document_doctype_read , NULL );
933
961
DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "documentElement" , dom_document_document_element_read , NULL );
962
+ DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "children" , dom_parent_node_children_read , NULL );
934
963
DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "firstElementChild" , dom_parent_node_first_element_child_read , NULL );
935
964
DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "lastElementChild" , dom_parent_node_last_element_child_read , NULL );
936
965
DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "childElementCount" , dom_parent_node_child_element_count , NULL );
@@ -1117,6 +1146,7 @@ PHP_MINIT_FUNCTION(dom)
1117
1146
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "className" , dom_element_class_name_read , dom_element_class_name_write );
1118
1147
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "classList" , dom_element_class_list_read , NULL );
1119
1148
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "attributes" , dom_node_attributes_read , NULL );
1149
+ DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "children" , dom_parent_node_children_read , NULL );
1120
1150
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "firstElementChild" , dom_parent_node_first_element_child_read , NULL );
1121
1151
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "lastElementChild" , dom_parent_node_last_element_child_read , NULL );
1122
1152
DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "childElementCount" , dom_parent_node_child_element_count , NULL );
@@ -1533,8 +1563,8 @@ void dom_nnodemap_objects_free_storage(zend_object *object) /* {{{ */
1533
1563
dom_nnodemap_object * objmap = (dom_nnodemap_object * )intern -> ptr ;
1534
1564
1535
1565
if (objmap ) {
1536
- if (objmap -> cached_obj && GC_DELREF ( & objmap -> cached_obj -> std ) == 0 ) {
1537
- zend_objects_store_del (& objmap -> cached_obj -> std );
1566
+ if (objmap -> cached_obj ) {
1567
+ OBJ_RELEASE (& objmap -> cached_obj -> std );
1538
1568
}
1539
1569
if (objmap -> release_local ) {
1540
1570
dom_zend_string_release_from_char_pointer (objmap -> local );
0 commit comments