Skip to content

ext/soap: Refactor userland function calling code #19055

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jul 6, 2025

Commits should be reviewed in order.

This gets rid of some more call_user_function API calls and reduces the amount of string copying.

@Girgias Girgias marked this pull request as ready for review July 6, 2025 17:48
@Girgias Girgias requested a review from nielsdos as a code owner July 6, 2025 17:48
ext/soap/soap.c Outdated
zend_function *header_fn = zend_hash_find_ptr_lc(function_table, Z_STR(h->function_name));
if (UNEXPECTED(header_fn == NULL)) {
if (soap_obj_ce && soap_obj_ce->__call) {
header_fn = zend_get_call_trampoline_func(soap_obj_ce, Z_STR(function_name), false);
Copy link
Member

Choose a reason for hiding this comment

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

When using zend_get_call_trampoline_func you should also release the trampoline function when you're done with it. This usually doesn't cause problems because as long as you're outside of a trampoline call, this function will store the trampoline in EG(trampoline). It should be possible to test this by making a soap call from within a trampoline.

Copy link
Member Author

Choose a reason for hiding this comment

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

I must be honest that I'm not exactly certain how to write a test for SOAP, do I need to "call" the trampoline from the XML?

Copy link
Member

Choose a reason for hiding this comment

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

You'll instantiate a SoapServer class and use setObject with a class that has a __call implementation.
The SoapServer::handle() function should be called from within another class's __call implementation.
That way, there are 2 trampolines active, and so the one invoked in this C code will use a heap-allocated function structure.

Copy link
Member

Choose a reason for hiding this comment

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

That said, I'm starting to wonder whether the manual trampoline handling will make the code more complex than it already was

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