Problem/Motivation
\Drupal\Tests\XdebugRequestTrait::extractCookiesFromRequest() provides Xdebug integration including setting the Xdebug cookie correctly for CLI test-runs. This is based on setting the XDEBUG_CONFIG variable (to something like XDEBUG_CONFIG="idekey=foo") which is what was needed to activate Xdebug on the CLI anyway previously. With Xdebug 3, however, one can set the XDEBUG_SESSION variable directly, similarly to how this works for browser requests (i.e. something loke XDEBUG_SESSION=1). Our Xdebug integration does not pick this up, however, so when working with Xdebug 3 the "old-style" XDEBUG_CONFIG needs to be added as well to make the integration work.
Steps to reproduce
- Have Xdebug 3 installed and configured
- Put a breakpoint in the actual test code of a browser test
- Verify that the breakpoint is hit if running the test with
XDEBUG_SESSION=1 - Now put a breakpoint on a line that is hit during a request that is performed from within the test, for example with
drupalGet() - Expect the breakpoint to be hit, but be disappointed
- Add
XDEBUG_CONFIG="idekey=1"to the command-line invocation to verify that that does in fact make the runtime breakpoint work
Proposed resolution
Change \Drupal\Tests\XdebugRequestTrait::extractCookiesFromRequest() to support a XDEBUG_SESSION variable in the server variables in addition to the cookies.
Presumably the support for XDEBUG_CONFIG should be kept until Xdebug 2 is no longer supported.
Remaining tasks
User interface changes
-
API changes
-
Data model changes
-
Release notes snippet
Issue fork drupal-3256356
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3256356-update-browser-test
changes, plain diff MR !2480
Comments
Comment #3
mstrelan commentedComment #5
rosk0Thanks for the patch Michael!
This missing XDebug 3 CLI handling is exactly why I wasn't able to debug that JSONAPI test failure today!
Can we please have this committed ASAP!
Comment #8
catchCommitted/pushed to 10.1.x, cherry-picked to 10.0.x and 9.5.x, thanks!