MantisBT - Xdebug
View Issue Details
0001586XdebugUsage problems (Wrong Results)public2018-11-12 12:182018-12-03 10:30
LanaZem 
derick 
normalminoralways
assignedopen 
2.6.0 
 
7.1.0-7.1.4
0001586: Error notifier doesn't respect error_reporting level
Xdebug sends error notification even if they are disabled in php.ini
1) Set error_reporting to `E_ALL & ~E_NOTICE`
2) Create a php script:
```
<?php

echo $undefined;
```
3) Make sure that regular execution doesn't generate PHP Notification
4) Start Xdebug debug session
5) Enable notify feature
```
<- feature_set -i 5 -n notify_ok -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" [^] command="feature_set" transaction_id="5" feature="notify_ok" success="1"></response>
```
6) Finish debug session
7) Note that there's a notification in xdebug log:
```
-> <notify xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" [^] name="error"><xdebug:message filename="file:///path/to/project/withNotice.php" [^] lineno="6" type="Notice"><![CDATA[Undefined variable: x]]></xdebug:message></notify>
```
PhpStorm issue: https://youtrack.jetbrains.com/issue/WI-43921 [^]
No tags attached.
log xdebug_with_notify.log (13,202) 2018-11-12 12:18
https://bugs.xdebug.org/file_download.php?file_id=441&type=bug
Issue History
2018-11-12 12:18LanaZemNew Issue
2018-11-12 12:18LanaZemFile Added: xdebug_with_notify.log
2018-12-01 11:28derickNote Added: 0004733
2018-12-02 18:45derickAssigned To => derick
2018-12-02 18:45derickStatusnew => feedback
2018-12-03 10:30LanaZemNote Added: 0004742
2018-12-03 10:30LanaZemStatusfeedback => assigned

Notes
(0004733)
derick   
2018-12-01 11:28   
I saw the issue when you submitted it, but so far I had neglected to reply as I am unsure whether Xdebug is doing anything *wrong* here. I'm going to argue that it doesn't.

As Xdebug is a *debugging* tool, it should provide as much information as it can. When an IDE sets the ``-n notify_ok -v 1`` it indicates that the debug engine may send the IDE notifications. These notifications are not necessarily restricted to ``error`` notifications (https://xdebug.org/docs-dbgp.php#error-notification [^]), but can in the future also include ``breakpoint_resolved`` notifications (these are currently unimplemented in Xdebug today, but part of a future feature, as requested by the PhpStorm team).

The DBGp specification says:

> When a language engine creates a debugging notification, the debugger engine MAY convert this to a DBGp notification.

The language engine (PHP) creates a debugging notice (including formatting, stack traces, etc) regardless of whether PHP outputs it to the screen. The decision to show debugging information is taken much later. This means that leaving many notices unfixed in your PHP script actually creates quite a slow down to begin with (even if Xdebug is not involved at all).

As a debugging notice is created, Xdebug decides to send it over the DBGp connection to the IDE, to point out that there is a mistake in the script. I would say that it should continue to do so.
(0004742)
LanaZem   
2018-12-03 10:30   
Thank you for the answer!
Ok, it make sense.

We'll think how it should be fixed on PhpStorm side. Probably we should show error according to error level but notify user if there are too much hidden notifications and warnings.