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

Symfony Error Handler broken #109

Closed
2 of 4 tasks
pxlrbt opened this issue May 27, 2021 · 5 comments · Fixed by #122
Closed
2 of 4 tasks

Symfony Error Handler broken #109

pxlrbt opened this issue May 27, 2021 · 5 comments · Fixed by #122

Comments

@pxlrbt
Copy link
Contributor

pxlrbt commented May 27, 2021

Description

The Symfony error handler is never rendering which leads to blank pages on errors when WP_ENV is not set to development

Steps to reproduce

  1. Set WP_ENV to "local"
  2. Trigger an error/exception

Expected behavior: Symfony error page

Actual behavior: Blank page

Reproduces how often: 100%

Versions

2.0.1

@Gandhi11
Copy link

Gandhi11 commented Jun 2, 2021

I have the same problem. You only need to install your composer dependencies without the dev dependencies and you will have the problem.

1 - The error needs to be send() to receive the proper html error code.
In the src/Roots/Acorn/Bootstrap/HandleExceptions.php file, the method ->send() needs to be append after the render in the renderHttpResponse method. Like so.

$this->getExceptionHandler()->render('', $e)->send();

2 - The error is not render properly in the page.
In the /src/Roots/Acorn/Exceptions/Handler.php file, the render need to be echoed.

    public function render($request, Throwable $e)
    {
        try {
            echo app()->environment('development') && class_exists(Whoops::class)
                        ? $this->renderExceptionWithWhoops($e)
                        : $this->renderExceptionWithSymfony($e, app()->environment('development'));
        } catch (Exception $e) {
            echo $this->renderExceptionWithSymfony($e, app()->environment('development'));
        }
    }

@pxlrbt
Copy link
Contributor Author

pxlrbt commented Jun 3, 2021

Hey @Gandhi11,
I already opened a PR here: #110
I only changed what you did in your 2. What's the ->send() for? Will this prevent previous output? I couldn't figure how to prevent that. Maybe you could comment on that PR?

@Gandhi11
Copy link

Gandhi11 commented Jun 3, 2021

If the ->send() is not used. The page still return a valid 200 OK even if there is a server error.

@pxlrbt
Copy link
Contributor Author

pxlrbt commented Jun 3, 2021

That doesn't work for me:

Currently $this->getExceptionHandler()->render('', $e) returns an instance of Whoops/Run - which doens't have a ->send method or string.

With adjustment 2 the return value is void.

@pxlrbt
Copy link
Contributor Author

pxlrbt commented Jun 3, 2021

@Gandhi11
I just looked into this and adjusted my PR so that Acorn/Exceptions/Handler::render returns a Symfony Response. Then ->send can be used on that Response and everything works as expected.

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