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

PHPCS Move strict_types to seperate lines #61

Merged

Conversation

emteknetnz
Copy link
Member

@emteknetnz emteknetnz commented Aug 4, 2020

Fix up PHPCS errors

This PR, was originally a fix for silverstripe/silverstripe-mfa#378, though have moved logic to https://github.com/silverstripe/silverstripe-mfa/pull/401/files instead

@robbieaverill
Copy link
Contributor

I'm thinking we just remove the strict_types?

Drop the declaration to a new line and PHPCS will be happy. You can also run vendor/bin/phpcbf and provide the module name to fix.

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Aug 4, 2020

You're going to be gobbling up legitimate errors here. I think that the interface should deal with a 500 response, rather than just removing the error in this one place. Other errors thrown (resulting in 500s) are going to have the same problem as described in silverstripe/silverstripe-mfa#378.

@emteknetnz
Copy link
Member Author

@ScopeyNZ

a) What are legitimate errors?
This is catching unhandled expections that are not turned into json (via Result::create()). On a dev environment I guess this isn't great because you get the exception output in the response, I guess getting 'The was an unknown error' back isn't so helpful there. On live though you just get a blank response and a 500 status code, hence the endless spinner.

b) What is "the interface"? (Sorry I'm not too familiar with this module)

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Aug 4, 2020

So the interface would be the thing that dispatches a request, and shows a spinner while it waits for the response. That should be updated to handle 500s. I don't know what the 500 error is here, but you're catching Exception, which is just one step above catching Throwable. The server throws a 500 because something's wrong. That's perfectly fine behaviour. Returning 200 OK - Everything is wrong is not really a good result.

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Aug 4, 2020

I was being a little terse there, it's actually returning a 401, but still "an unknown error occurred" with a 4xx response (client problem) is not really semantically correct. It should be a 5xx response.

@emteknetnz
Copy link
Member Author

emteknetnz commented Aug 5, 2020

@ScopeyNZ OK I think I have a corresponding PR that does this for 429 on the mfa module - silverstripe/silverstripe-mfa#401 - so would it work if we close this PR and update the other PR to handle 500?

@ScopeyNZ
Copy link
Contributor

ScopeyNZ commented Aug 5, 2020

Sound good to me.

In fact, you could probably just fill in the "default" case in that PR with an "unknown error" message.

@emteknetnz
Copy link
Member Author

@ScopeyNZ OK have removed the 500 logic from this PR. I've kept this PR open to just fix up the PHPCS issues

@emteknetnz emteknetnz changed the title FIX Handle exceptions in the verify method PHPCS Move strict_types to seperate lines Aug 5, 2020
@emteknetnz emteknetnz merged commit e4813ad into silverstripe:4.0 Aug 10, 2020
@emteknetnz emteknetnz deleted the pulls/4.0/handle-exception branch August 10, 2020 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants