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

  1. Have Xdebug 3 installed and configured
  2. Put a breakpoint in the actual test code of a browser test
  3. Verify that the breakpoint is hit if running the test with XDEBUG_SESSION=1
  4. Now put a breakpoint on a line that is hit during a request that is performed from within the test, for example with drupalGet()
  5. Expect the breakpoint to be hit, but be disappointed
  6. 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

Command icon 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:

Comments

tstoeckler created an issue. See original summary.

mstrelan made their first commit to this issue’s fork.

mstrelan’s picture

Status: Active » Needs review
Related issues: +#3178919: Can't run tests with XDEBUG_CONFIG set to empty string

rosk0’s picture

Status: Needs review » Reviewed & tested by the community

Thanks 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!

  • catch committed 26182e8 on 10.0.x
    Issue #3256356 by mstrelan, tstoeckler: Update browser test Xdebug...
  • catch committed 428d60e on 10.1.x
    Issue #3256356 by mstrelan, tstoeckler: Update browser test Xdebug...

  • catch committed d967979 on 9.5.x
    Issue #3256356 by mstrelan, tstoeckler: Update browser test Xdebug...
catch’s picture

Version: 10.0.x-dev » 9.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 10.1.x, cherry-picked to 10.0.x and 9.5.x, thanks!

Status: Fixed » Closed (fixed)

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