Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Add support for Whoops 2.0 #384

Merged
merged 6 commits into from
Nov 11, 2016
Merged

Add support for Whoops 2.0 #384

merged 6 commits into from
Nov 11, 2016

Conversation

geerteltink
Copy link
Member

@geerteltink geerteltink commented Sep 21, 2016

This PR adds support for Whoops 2.0 as discussed in zendframework/zend-expressive-skeleton#115 and #383.

Falling back to 1.1 is no option since it doesn't support PHP 7.

It's not optimal but it adds support fro 2.0 while maintaining BC.

  • Add whoops 2.0 support
  • Suggest whoops 2.0
  • Fix whoops tests

@geerteltink
Copy link
Member Author

@michaelmoussa Could you review this code please. If this is a valid solution I'll fix the tests too. I don't want to spend time on the tests if the solution isn't good.

Copy link
Contributor

@michaelmoussa michaelmoussa left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me! As a possible enhancement, what do you think of automatically using whichever handler is most appropriate for the Accept header? json for json, xml for xml, plaintext if we're in CLI, or prettypage otherwise?

I don't think that's necessary for this PR, but just a suggestion if you're interested. I think what you have already can be merged just fine once the tests are added.

Thanks

@@ -76,9 +76,18 @@ public function __construct(
*/
protected function handleException($exception, Request $request, Response $response)
{
$this->prepareWhoopsHandler($request);
// Push the whoops handler if any
if (null !== $this->whoopsHandler) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you reverse the order here for the comparison for consistency? I haven't seen the Yoda condition style being used elsewhere in the project.

@geerteltink
Copy link
Member Author

The tests are now compatible for Whoops 1.x and 2.x.

For Expressive version 2 I suggest to drop whoops 1.x support. All Whoops related tests can then be rewritten and properly use the Whoops\RunInterface (this isn't available in Whoops 1.x).

One more thing I discovered: The Zend\Expressive\WhoopsErrorHandler expects as the second parameter the PrettyPageHandler. However there is also a Whoops\Handler\HandlerInterface. This would allow to inject any error handler like the JsonResponseHandler without breaking BC.

@michaelmoussa
Copy link
Contributor

Great! I'll see about merging and doing a patch release early next week, as I won't have access to a computer for a few days... unless @weierophinney or someone else wants to wrap things up.

@michaelmoussa
Copy link
Contributor

@weierophinney this looks good to me, but I noticed that master is way ahead of the latest 1.0.0 tag for this repo. It seems to be mostly documentation and CI related commits, though. Do you see any issue with me merging this PR and releasing 1.0.1? (it's a bug fix and is BC, so I think a patch version is appropriate)

@kynx
Copy link
Contributor

kynx commented Oct 20, 2016

This is working well for me :) Would be good to see it merged.

@weierophinney weierophinney added this to the 1.0.1 milestone Nov 10, 2016
@weierophinney weierophinney self-assigned this Nov 10, 2016
@weierophinney weierophinney merged commit 4e39397 into zendframework:master Nov 11, 2016
weierophinney added a commit that referenced this pull request Nov 11, 2016
Add support for Whoops 2.0

Conflicts:
	src/Container/WhoopsErrorHandlerFactory.php
weierophinney added a commit that referenced this pull request Nov 11, 2016
weierophinney added a commit that referenced this pull request Nov 11, 2016
weierophinney added a commit that referenced this pull request Nov 11, 2016
Forward port #384

Conflicts:
	composer.json
@weierophinney
Copy link
Member

Thanks, @xtreamwayz

@geerteltink geerteltink deleted the hotfix/fix-whoops-2-json-handler branch December 9, 2016 16:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants