Using Drupal (8.9), PHP (7.2.34) with xdebug, and VSCode (1.50.1) with PHP Debug (1.13.0), the debugger will no longer break on PHP notices and warnings, even if those option checkboxes are set.

The behavior starts as soon as Drupal installs its error handler in Drupal\Core\DrupalKernal::bootEnvironment().

As an example, if I insert strlen();, a function call which triggers a PHP Warning (error type 4), immediately before set_error_handler('_drupal_error_handler');, execution will stop and the VSCode debugger will display the offending line. As soon as the error handler is installed, VSCode will no longer stop.

The same behavior is true of PHP Notices. Execeptions and regular breakpoints work as expected.

Turnning on logging shows that the debugger is sending the command to break on notice and warnings:

> setExceptionBreakpointsRequest
  command: 'setExceptionBreakpoints',
  arguments: { filters: [ 'Notice', 'Warning' ] },
  type: 'request',
  seq: 4

<- setExceptionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 4,
  command: 'setExceptionBreakpoints',
  success: true

... but then there's nothing further in the log about the notice or warning exceptions.

Now I can believe this is simply a limitation of xdebug -- that the use of the drupal error handler (which does NOT return FALSE to trigger default error handling), except that I know that at some very distant time in the past, using different tools, I could break on notices and warnings. For example, using Drupal 6, PHP 5.3, KomodoEdit (unknown version), this used to work.

If anyone is successfully getting the debugger to stop on PHP notices and warnings using tools similar to what I'm using, I'd love some details. I've looked over the xdebug and php configuration settings and I don't see anything that be relevant. Note: I'm not trying to display the warnings/notices -- that is working according to the Drupal configuration. And I'm not trying to halt on warnings/notices. I'm trying to get xdebug to break execution.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.