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