Skip to content
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

ext/soap: Various refactorings #14579

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

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jun 16, 2024

Cleaning up the extension code and attempting to slightly modernize it.

This PR should be reviewed commit by commit, as they are all independent of each other.

Part of the rationale is to move away from the bailout mechanism and use standard exceptions/errors.

I think the conversions done here are non-problematic, as they indicate programming errors while attempting to create a server or a client, which IMHO should not result in an XML SOAP Fault being returned.

@nielsdos
Copy link
Member

The signature change of __doRequest doesn't seem right due to the one_way behaviour.
See also this btw: https://bugs.php.net/bug.php?id=70462

ext/soap/soap.c Outdated Show resolved Hide resolved
ext/soap/soap.c Outdated
zval *headers = NULL;
zval *output_headers = NULL;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sh|h!zz", &function, &args, &options, &headers, &output_headers) == FAILURE) {
Copy link
Member

@devnexen devnexen Jun 17, 2024

Choose a reason for hiding this comment

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

I do not think the everything needs to use fast ZPP but hot paths like this might benefit it wdyt ? does not need to be in same PR though

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 think it makes sense, I need to double check if we have a fast ZPP check for object_of_class/array/null as it would improve the handlings of the headers arg.

@devnexen
Copy link
Member

Looks ok but definitively needs another pair of eyes, quite some changes.

ext/soap/soap.c Outdated
Comment on lines 717 to 722
if (UNEXPECTED(Z_TYPE_P(faultcode) == IS_NULL)) {
faultcode_val = zend_empty_string;
} else {
ZEND_ASSERT(Z_TYPE_P(faultcode) == IS_STRING);
faultcode_val = Z_STR_P(faultcode);
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: We could inverse the condition here for extra safety:

if (EXPECTED(Z_TYPE_P(faultcode) == IS_STRING)) {
    faultcode_val = Z_STR_P(faultcode);
} else {
    ZEND_ASSERT(Z_TYPE_P(faultcode) == IS_NULL);
    faultcode_val = zend_empty_string;
}

Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

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

The refactoring looks ok to me.

The reason for the error handling change makes sense, but I would like to see other opinions on this.

This is a lot of changes, and the split in commits makes it easier to review, but I think that submitting two separate PRs would have been even better as the changes are not really related (one PR for pure refactoring, and another for the behavior-affecting changes).

…::__constructor()

Use ValueErrors as the conditions checked are programming errors

Also narrow down bailout mechanism use in it as only the call to get_sdl()
requires us to use the bailout mechanism.
…::__constructor()

Use ValueErrors as the conditions checked are programming errors

Also narrow down bailout mechanism use in it as only the call to get_sdl()
requires us to use the bailout mechanism.
@Girgias
Copy link
Member Author

Girgias commented Jun 19, 2024

I have merged the refactoring manually out of the PR, the PR basically only has the bailout conversions and the refactoring of the __toString() method still.

I was planning on doing different PRs, but I was just working on all the things kinda at the same time as the codebase is somewhat convoluted so trying to figure it out took me on a journey.

@Girgias
Copy link
Member Author

Girgias commented Jun 19, 2024

I think the only controversial change is the one in SoapServer, as this changes the behaviour from printing a SOAP Fault XML error to a PHP exception.

The other cases either convert a fatal error to an exception, or convert one exception to another type.

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.

None yet

4 participants