Problem

  • WSOD. No error. Nothing.

Cause

Symfony\Component\HttpKernel\Kernel.php:

    public function init()
    {
        if ($this->debug) {
            ini_set('display_errors', 1);
            error_reporting(-1);

            DebugClassLoader::enable();
            ErrorHandler::register($this->errorReportingLevel);
            if ('cli' !== php_sapi_name()) {
                ExceptionHandler::register();
            }
        } else {
            ini_set('display_errors', 0);
        }
    }

Details

  • index.php calls
    $kernel = new DrupalKernel('prod', FALSE);
    
  • The second argument is $debug, tacked onto $this->debug by the Kernel's constructor.
  • The rest is visible in the pasted snippet above.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Issue summary: View changes

Updated issue summary.

Crell’s picture

I wonder if we shouldn't just modify our error handling to build off of that. I mean, the feature is there, and there's discussion elsewhere of a dev/prod toggle being useful.

sun’s picture

Status: Active » Needs review
FileSize
740 bytes

We can investigate that, but let's implant a stop-gap fix for now.

The $debug FALSE is hard-coded currently, which makes Drupal core development quite problematic.

Crell’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +revisit before beta

Seems like a worthwhile stopgap while we consider how to leverage the dev/prod flag: #1537198: Add a Production/Development Toggle To Core. Marking for later consideration.

sun’s picture

Also, FWIW, without this fix, any call to debug() causes the Kernel to end the request:

kernel-init-debug-errorexception.png

aspilicious’s picture

That last statement is incorrect. I just did a nice debug.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

So... what exactly breaks, and let's get some test coverage for it.

sun’s picture

Status: Needs work » Reviewed & tested by the community

erm. Nothing is broken. But if something is broken, you don't see what's broken.

Dries’s picture

Priority: Critical » Major
Status: Reviewed & tested by the community » Needs work

I'm ok with this stop-gap solution while we figure out a solution. I committed the patch to 8.x.

Sun, do we want to rename this issue?

Fixing this is different from #1537198: Add a Production/Development Toggle To Core, which Larry created in #3.

Setting to 'needs work' to make sure we either rename this issue, or create a follow-up issue.

sun’s picture

Title: Kernel::init() overrides Drupal's error handling configuration » Replace Drupal's error handling with Symfony/HttpKernel's
Category: bug » feature
Priority: Major » Normal
Status: Needs work » Active
Issue tags: -Needs tests, -Regression, -revisit before beta

I guess it's ok-ish to re-purpose this issue, given how short it is.

Note that (I believe) #1537198: Add a Production/Development Toggle To Core is different — the Kernel's $environment parameter seems to be a built-in, free-form environment specifier, which mainly seems to impact configuration (overrides, such as caching).

The $debug parameter is independent from that.

I will definitely say that the Kernel's exception/error handling looks very solid. That ::init() code already reveals that it treats the CLI appropriately and even goes one step further and injects a debug handler into the class loader.
(The latter almost looks like a much better solution than #1632364: Write tests to ensure that all classes in Drupal can actually be found by the autoloader.)

On top of that, it even comes with a "maintenance theme"-alike output handler — e.g., if you enable $debug = TRUE and trigger an exception, then you see a pretty-styled error page in your browser (replacing the entire page output).

However, at the same time,

1) the Boolean TRUE/FALSE flag most likely won't be able to support our granular error handling configuration options (we have 4 different levels of error exposure alone, plus I think some additional settings). Symfony seems to solely rely on PHP ini settings instead (which I guess is just natural for a PHP framework without user-facing administration/configuration UI).

2) the verbose error/exception output is completely verbose (without any attempt to reduce it, like we just recently did in #1158322: Add backtrace to all errors).

3) replacing the entire page output is a bit extreme.

So, I'd totally +1 the idea of migrating to Symfony's error handler, but at the same time, I hope we can retain some "sanity" with regard to our current error handling.

That said, lastly, our error handling also plugs very deeply into the testing framework (e.g., sending HTTP response headers in case of any exceptions/warnings/errors), so as to communicate any otherwise non-trackable failures to web/functional tests; including special handling for debug() E_USER_NOTICEs.

sun’s picture

Issue summary: View changes

Updated issue summary.

Crell’s picture

Issue summary: View changes

It's been 2 years, and our bootstrap pipeline has changed radically. Is this issue still relevant?

dawehner’s picture

While using the symfony error handler code might not be what we want, we could at least think about improving our error handler code even further. It is still kind of a mess,
but at least compared to back then its more failure proven.

webchick’s picture

Version: 8.0.x-dev » 8.1.x-dev

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • Dries committed 9f18d6d on 8.3.x
    - Patch #1722694 by sun: Fixed Kernel::init() overrides Drupal's error...

  • Dries committed 9f18d6d on 8.3.x
    - Patch #1722694 by sun: Fixed Kernel::init() overrides Drupal's error...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • Dries committed 9f18d6d on 8.4.x
    - Patch #1722694 by sun: Fixed Kernel::init() overrides Drupal's error...

  • Dries committed 9f18d6d on 8.4.x
    - Patch #1722694 by sun: Fixed Kernel::init() overrides Drupal's error...

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

AaronMcHale’s picture

I'd really like to see Drupal use Symfony's error/exception handling, it provides a much nicer interface for debugging compared with what comes with Drupal.

#9 by @sun:

1) the Boolean TRUE/FALSE flag most likely won't be able to support our granular error handling configuration options (we have 4 different levels of error exposure alone, plus I think some additional settings). Symfony seems to solely rely on PHP ini settings instead (which I guess is just natural for a PHP framework without user-facing administration/configuration UI).

That might be our only real blocker, and could be addressed by simply initialising the debugger outside of the Symfony Kernel's init function, there's even docs on the Symfony site explaining how to do it, so it's definitely supported.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

bradjones1’s picture

Version: 8.9.x-dev » 9.1.x-dev
Chi’s picture

andypost’s picture

andypost’s picture

AaronMcHale’s picture

It kind of looks like this issue aims to do the same as #3051459: Replace error and exception handlers with implementation from Symfony ErrorHandler component, should either this issue or that issue be closed in favour of the other?

  • Dries committed 9f18d6d on 9.1.x
    - Patch #1722694 by sun: Fixed Kernel::init() overrides Drupal's error...

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Title: Replace Drupal's error handling with Symfony/HttpKernel's » Fixed Kernel::init() overrides Drupal's error handling configuration
Version: 9.4.x-dev » 8.0.x-dev
Category: Feature request » Bug report
Priority: Normal » Major
Status: Active » Fixed

This issue was committed to 8.x and then then re-opened with a new title. It would have been cleaner to close this one and open a new issue to discuss the next step. Anyway, here we are.

Thanks to @AaronMcHale, who found that there is a duplicate issue for the next step, #3051459: Replace error and exception handlers with implementation from Symfony ErrorHandler component where work can continue. So, for this issue I am restoring the meta data to the date it was committed and setting the status to Fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.