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

SOAP: Error thrown on wrong parameter #8578

Closed
robertnisipeanu opened this issue May 18, 2022 · 1 comment
Closed

SOAP: Error thrown on wrong parameter #8578

robertnisipeanu opened this issue May 18, 2022 · 1 comment

Comments

@robertnisipeanu
Copy link
Contributor

robertnisipeanu commented May 18, 2022

Description

The following code:

<?php
new \SoapHeader("ns", "name", [], false, "AB");

Resulted in this output:

Fatal error: Uncaught ValueError: SoapHeader::__construct(): Argument #2 ($name) must be longer than 2 characters in /home/user/scripts/code.php:4

But I expected this output instead:

Fatal error: Uncaught ValueError: SoapHeader::__construct(): Argument #5 ($actor) must be longer than 2 characters in /home/user/scripts/code.php:4

2803c8f added a check in file ext/soap/soap.c on the SoapHeader constructor which checks that the length of actor is greater than 2 when it is a string. However, the error is thrown on parameter 2 ($name) instead of being thrown on parameter 5 ($actor):

zend_argument_value_error(2, "must be longer than 2 characters");

Besides the error being thrown on the wrong parameter number, is there a specific reason of adding a minimum length of 2 on the actor string?

PHP Version

PHP 8.0

Operating System

No response

@cmb69
Copy link
Contributor

cmb69 commented May 19, 2022

Ah, good catch. Thank you!

Besides the error being thrown on the wrong parameter number, is there a specific reason of adding a minimum length of 2 on the actor string?

It seems to me that has been inadvertently changed. Prior to PHP 8.0.0, the only requirement was that the actor string is not empty. Maybe @kocsismate remembers if there was a reason to change that? On the other hand, the actor is supposed to be an URI, so even an artificial requirement of more than two characters shouldn't be a problem.

@cmb69 cmb69 self-assigned this May 19, 2022
cmb69 added a commit that referenced this issue May 19, 2022
* PHP-8.0:
  Fix GH-8578: Error on wrong parameter on SoapHeader constructor
@cmb69 cmb69 closed this as completed in 8735ae9 May 19, 2022
cmb69 added a commit that referenced this issue May 19, 2022
* PHP-8.1:
  Fix GH-8578: Error on wrong parameter on SoapHeader constructor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@cmb69 @robertnisipeanu and others