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

Issue with serialization SoapFault #1431

Closed
yethee opened this issue Jan 31, 2020 · 5 comments
Closed

Issue with serialization SoapFault #1431

yethee opened this issue Jan 31, 2020 · 5 comments
Labels
Milestone

Comments

@yethee
Copy link

yethee commented Jan 31, 2020

Monolog version: 2.0.2

Occurs an error during serialization SoapFault, when property details has value of complex type.

Error(code: 0): Object of class stdClass could not be converted to string at /app/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php:184

An example of SoapFault:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Body>
    <SOAP-ENV:Fault>
      <faultcode>SOAP-ENV:Client</faultcode>
      <faultstring>Недостаточно баллов</faultstring>
      <detail>
        <ns3:FaultResponse xmlns:ns3="http://api.direct.yandex.com/v5/general">
          <requestId>2577205305276726399</requestId>
          <errorCode>152</errorCode>
          <errorDetail>Недостаточно баллов для выполнения операции</errorDetail>
        </ns3:FaultResponse>
      </detail>
     </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Commit 633bcd5 not fixes issue in this case, because reset() returns stdClass{requestId, errorCode, errorDetail}.

@yethee yethee added the Bug label Jan 31, 2020
@covobo
Copy link

covobo commented Feb 21, 2020

I have the same problem

@neclimdul
Copy link
Contributor

I was having the same problem but then as soon as I started trying to fix it my soap resource fixed itself and I couldn't dig in.

I think the description of the problem with the assumptions in using reset are accurate though.

I was going to play with refactoring the if/ternary logic out and letting var_export or print_r just dump what ever was given. Replacing it with something like:

            if (isset($e->detail)) {
                if  (is_string($e->detail)) {
                    $str .= ' detail: ' . $e->detail;
                }
                elseif (is_object($e->detail) || is_array($e->detail)) {
                    $str .= ' detail: ' . var_export($e->detail, true);
                }
            }

@covobo
Copy link

covobo commented Mar 25, 2020

The problem here is that php claims detail property as string (you can look at the __construct method https://www.php.net/manual/en/class.soapfault.php ), but in fact it's not only string.

So if it mixed property we have to use some kind of serialization, var_export looks nice.

I use json_encode as ad-hoc solution, I think it is more friendly for logging systems.

@Seldaek Seldaek modified the milestones: 2.x, 1.x May 11, 2020
@Seldaek
Copy link
Owner

Seldaek commented May 11, 2020

Refs #1391

@Seldaek
Copy link
Owner

Seldaek commented May 21, 2020

Fixed by #1462

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants