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

Blank screen when die() in an AbstractExtension #3058

Closed
janhenckens opened this issue Jun 6, 2019 · 5 comments

Comments

Projects
None yet
3 participants
@janhenckens
Copy link

commented Jun 6, 2019

I have a package that wraps larapack/dd in a Twig Extension and I'm having a problem on projects that are using Twig 2.11 (issue on my repo)

Larapack has a 'dump & die' method (dd) and using that results in a blank screen, no matter where in the template the extension gets called.

Further debugging reveals that it is not related to larapack/dd of my extension specifically, any extension with a die() or an exit() in it results in a blank screen.

For reference, this is built as a plugin for craftcms/cms.

This worked on 2.81, but yesterday's Craft update bumped Twig from 2.8.1 to 2.11, which is why the issue shows up now.

Is this an intentional change and if so how can I make this work again? Thanks!

@janhenckens janhenckens changed the title Blank screen for die in an AbstractExtension Blank screen when die() in an AbstractExtension Jun 6, 2019

@fabpot

This comment has been minimized.

Copy link
Contributor

commented Jun 6, 2019

This is indeed "expected" in recent versions of Twig. See #2995 for the PR and #1962 for the reason behind the change.

@fabpot fabpot closed this Jun 6, 2019

@lyrixx

This comment has been minimized.

Copy link
Contributor

commented Jun 6, 2019

@fabpot I noticed that too. I did not take time to report this issue. Actually this make developing twig extension much harder (almost impossible).

I often do that (I just tested it with a fresh symfony 4.3 install):

class FoobarExtension extends AbstractExtension
{
    public function getFilters(): array
    {
        return [
            new TwigFilter('foobar', [$this, 'foobar']),
        ];
    }

    public function foobar($value)
    {
        dump($value);die;
    }
}

Now it display a blank page.

Maybe, we can use the $debug flag to display or not a fatal error.

@fabpot

This comment has been minimized.

Copy link
Contributor

commented Jun 6, 2019

@lyrixx That is an option indeed. In debug mode, don't flush the output. Would you like to work on a PR?

@fabpot fabpot reopened this Jun 6, 2019

@lyrixx

This comment has been minimized.

Copy link
Contributor

commented Jun 6, 2019

Let's go :)

@janhenckens

This comment has been minimized.

Copy link
Author

commented Jun 6, 2019

Thanks for jumping in on this @lyrixx!

@fabpot fabpot closed this Jun 10, 2019

fabpot added a commit that referenced this issue Jun 10, 2019

bug #3059 Don't clear PHP buffer when an error occurs with debug=true…
… (lyrixx)

This PR was squashed before being merged into the 1.x branch (closes #3059).

Discussion
----------

Don't clear PHP buffer when an error occurs with debug=true

fixes #3058

Commits
-------

c910e71 Don't clear PHP buffer when an error occurs with debug=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.