Skip to content

Refactor implementation of DOM nodelists, named maps, and iterators #18892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 21, 2025

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Jun 21, 2025

See individual commits.
This is a prerequisite for the $children property and for #18550

I will follow up with a PR that moves some functions to the right files.

- Use ecalloc() to not miss initializing any field.
- Merge declarations and assignments.
@@ -22,7 +22,7 @@ foreach ($test_values as $value) {
?>
--EXPECTF--
--- -1 ---
string(1) "a"
string(3) "N/A"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactor actually fixed a bug here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not backport this as this is a very invasive fix.

The code was really messy with lots of checks and inconsistencies.
This splits everything up into different functions and now everything is
relayed to a handler vtable.
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can at least somewhat follow the new code compared to the old one.

So if the tests all pass then good for me :D

}

void php_dom_named_node_map_get_named_item_into_zval(dom_nnodemap_object *objmap, const zend_string *named, zval *return_value)
void php_dom_named_node_map_get_named_item_into_zval(dom_nnodemap_object *objmap, const zend_string *named, const char *ns, zval *return_value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense as a follow-up refactoring to have the namespace be a zend_string instead of a char pointer? Got my answer does not make sense as this is just passed down to libxml.

@@ -22,7 +22,7 @@ foreach ($test_values as $value) {
?>
--EXPECTF--
--- -1 ---
string(1) "a"
string(3) "N/A"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not backport this as this is a very invasive fix.

@nielsdos nielsdos merged commit ff0a2cf into php:master Jun 21, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants