@@ -95,6 +95,7 @@ PHP_DOM_EXPORT zend_class_entry *dom_namespace_info_class_entry;
9595static zend_object_handlers dom_object_handlers ;
9696static zend_object_handlers dom_nnodemap_object_handlers ;
9797static zend_object_handlers dom_nodelist_object_handlers ;
98+ static zend_object_handlers dom_unset_children_property_object_handlers ;
9899static zend_object_handlers dom_modern_nnodemap_object_handlers ;
99100static zend_object_handlers dom_modern_nodelist_object_handlers ;
100101static zend_object_handlers dom_html_collection_object_handlers ;
@@ -667,14 +668,35 @@ static zend_object *dom_objects_store_clone_obj(zend_object *zobject) /* {{{ */
667668static zend_object * dom_modern_element_clone_obj (zend_object * zobject )
668669{
669670 zend_object * clone = dom_objects_store_clone_obj (zobject );
671+ dom_object * intern = php_dom_obj_from_obj (clone );
670672
671673 /* The $classList property is unique per element, and cached due to its [[SameObject]] requirement.
672674 * 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 );
674676 if (!Z_ISUNDEF_P (class_list )) {
675677 zval_ptr_dtor (class_list );
676678 ZVAL_UNDEF (class_list );
677679 }
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+ }
678700
679701 return clone ;
680702}
@@ -776,6 +798,9 @@ PHP_MINIT_FUNCTION(dom)
776798 memcpy (& dom_modern_element_object_handlers , & dom_object_handlers , sizeof (zend_object_handlers ));
777799 dom_modern_element_object_handlers .clone_obj = dom_modern_element_clone_obj ;
778800
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+
779804 memcpy (& dom_nnodemap_object_handlers , & dom_object_handlers , sizeof (zend_object_handlers ));
780805 dom_nnodemap_object_handlers .free_obj = dom_nnodemap_objects_free_storage ;
781806 dom_nnodemap_object_handlers .read_dimension = dom_nodemap_read_dimension ;
@@ -796,6 +821,8 @@ PHP_MINIT_FUNCTION(dom)
796821 memcpy (& dom_html_collection_object_handlers , & dom_modern_nodelist_object_handlers , sizeof (zend_object_handlers ));
797822 dom_html_collection_object_handlers .read_dimension = dom_html_collection_read_dimension ;
798823 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 ;
799826
800827 memcpy (& dom_object_namespace_node_handlers , & dom_object_handlers , sizeof (zend_object_handlers ));
801828 dom_object_namespace_node_handlers .offset = XtOffsetOf (dom_object_namespace_node , dom .std );
@@ -910,9 +937,10 @@ PHP_MINIT_FUNCTION(dom)
910937
911938 dom_modern_documentfragment_class_entry = register_class_Dom_DocumentFragment (dom_modern_node_class_entry , dom_modern_parentnode_class_entry );
912939 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 ;
914941 zend_hash_init (& dom_modern_documentfragment_prop_handlers , 0 , NULL , NULL , true);
915942
943+ DOM_REGISTER_PROP_HANDLER (& dom_modern_documentfragment_prop_handlers , "children" , dom_parent_node_children_read , NULL );
916944 DOM_REGISTER_PROP_HANDLER (& dom_modern_documentfragment_prop_handlers , "firstElementChild" , dom_parent_node_first_element_child_read , NULL );
917945 DOM_REGISTER_PROP_HANDLER (& dom_modern_documentfragment_prop_handlers , "lastElementChild" , dom_parent_node_last_element_child_read , NULL );
918946 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)
921949 zend_hash_add_new_ptr (& classes , dom_modern_documentfragment_class_entry -> name , & dom_modern_documentfragment_prop_handlers );
922950
923951 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 ;
925953 zend_hash_init (& dom_abstract_base_document_prop_handlers , 0 , NULL , NULL , true);
926954 DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "implementation" , dom_modern_document_implementation_read , NULL );
927955 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)
931959 DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "inputEncoding" , dom_document_encoding_read , dom_html_document_encoding_write );
932960 DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "doctype" , dom_document_doctype_read , NULL );
933961 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 );
934963 DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "firstElementChild" , dom_parent_node_first_element_child_read , NULL );
935964 DOM_REGISTER_PROP_HANDLER (& dom_abstract_base_document_prop_handlers , "lastElementChild" , dom_parent_node_last_element_child_read , NULL );
936965 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)
11171146 DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "className" , dom_element_class_name_read , dom_element_class_name_write );
11181147 DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "classList" , dom_element_class_list_read , NULL );
11191148 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 );
11201150 DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "firstElementChild" , dom_parent_node_first_element_child_read , NULL );
11211151 DOM_REGISTER_PROP_HANDLER (& dom_modern_element_prop_handlers , "lastElementChild" , dom_parent_node_last_element_child_read , NULL );
11221152 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) /* {{{ */
15331563 dom_nnodemap_object * objmap = (dom_nnodemap_object * )intern -> ptr ;
15341564
15351565 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 );
15381568 }
15391569 if (objmap -> release_local ) {
15401570 dom_zend_string_release_from_char_pointer (objmap -> local );
0 commit comments