Updated: Comment #0

Problem/Motivation

In WebTestBase::curlExec() we copy the XDEBUG cookie from the parent request to the child request.

This does not work for CLI requests, however, because in that case the XDEBUG information is not stored in $_COOKIE, but in $_SERVER.

Proposed resolution

Check for $_SERVER['XDEBUG_CONFIG'] and if that is present, turn that into an XDebug cookie on the child site.

Remaining tasks

The current patch assumes a very specific format of the XDEBUG_CONFIG key. It is the most common format, but I'm not sure how safe that assumption is. The alternative would be to somehow parse the config. I didn't look up the format of the config, so I don't know how hard that would be.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This really helps on some of the more complication test problems! Thank you

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.86 KB
1.76 KB

Except that I not only managed to mess up the simplest of patches, but also diverted @dawehner's attention with the substr() thing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Ha, but I still trust you.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -1132,15 +1132,22 @@ protected function curlExec($curl_options, $redirect = FALSE) {
+      $cookies[] = 'XDEBUG_SESSION=' . substr($_SERVER['XDEBUG_CONFIG'], 7);

This is brittle. Looking at http://xdebug.org/docs/remote a possible value is XDEBUG_CONFIG="idekey=session_name remote_host=localhost profiler_enable=1" and this would totally break this.

dawehner’s picture

So, do we really have to pull out the idekey from the string?

tstoeckler’s picture

Here's a patch that does that. I thought of the possibility of multiple spaces, is there anything else we need to consider? Per your link, @alexpott, I think we're covered:

You can also configure the xdebug.remote_host, xdebug.remote_port, xdebug.remote_mode and xdebug.remote_handler in this same environment variable as long as you separate the values by a space

I didn't yet test this. I suppose we could even write automated tests for this...

Edit: If I end my questions with question marks, people might understand me...

tstoeckler’s picture

Status: Needs work » Needs review
FileSize
1.13 KB
2.01 KB

#fail

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

This worked fine with Drupal\views_ui\Tests\ViewsUITourTest and getting a breakpoint in some actual form. Thank you!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 9107f06 and pushed to 8.x. Thanks!

yched’s picture

Minor, but would be cleaner to trim just once here:
list($key, $value) = explode('=', trim($pair));

Status: Fixed » Closed (fixed)

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

chx’s picture

Version: 8.x-dev » 7.x-dev
Status: Closed (fixed) » Patch (to be ported)
Darren Oh’s picture

Status: Patch (to be ported) » Needs review
FileSize
2.74 KB

Status: Needs review » Needs work

The last submitted patch, 13: simpletest-xdebug-2134259-12.patch, failed testing.

basic’s picture

Hi there,

#13 was causing the testbot servers to fail, and I had to force a cancel on the test. Please do not re-test the patch above.

Thanks!

The last submitted patch, 13: simpletest-xdebug-2134259-12.patch, failed testing.

tstoeckler’s picture

Assigned: tstoeckler » Unassigned
dawehner’s picture

@basic
Do you understand why?

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 13: simpletest-xdebug-2134259-12.patch, failed testing.

basic’s picture

I don't know, but the patch was causing issues on the testbots. This could be due to an invalid patch. It could be '+ $request = \Drupal::request();' ? Should that be escaped like it is?

Darren Oh’s picture

Status: Needs work » Needs review

The test was failing because I included some Drupal 8 code in the Drupal 7 patch. There was nothing in the Drupal 8 code that needed to be ported to Drupal 7. The original patch in #6 is fine.

Darren Oh’s picture

FileSize
2.63 KB
Darren Oh’s picture

Status: Needs review » Reviewed & tested by the community
tstoeckler’s picture

Status: Reviewed & tested by the community » Needs review

Please don't RTBC your own patch. It looks OK from a cursory glance but the code is slightly different in D7, so someone will have to take a deeper look and also take this for a test run.

  • alexpott committed 9107f06 on 8.3.x
    Issue #2134259 by tstoeckler: Make the Simpletest XDebug integration...

  • alexpott committed 9107f06 on 8.3.x
    Issue #2134259 by tstoeckler: Make the Simpletest XDebug integration...

  • alexpott committed 9107f06 on 8.4.x
    Issue #2134259 by tstoeckler: Make the Simpletest XDebug integration...

  • alexpott committed 9107f06 on 8.4.x
    Issue #2134259 by tstoeckler: Make the Simpletest XDebug integration...