summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2013-11-16 23:30:41 (GMT)
committerAlex Pott2013-11-16 23:30:41 (GMT)
commit9107f06db39ca50759b37fa0c142a1e0b3c48911 (patch)
treec7d90d9aea9e8431d41d13a4d015b3455ee62ec6
parent3cda8309b003472797244805d3451f0605bbca4e (diff)
Issue #2134259 by tstoeckler: Make the Simpletest XDebug integration work for CLI requests.
-rw-r--r--core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php21
1 files changed, 17 insertions, 4 deletions
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index e418284..284df1d 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -1132,15 +1132,28 @@ abstract class WebTestBase extends TestBase {
if (!empty($this->curlCookies)) {
$cookies = $this->curlCookies;
}
- // In order to debug webtests you need to either set a cookie or have the
- // xdebug session in the URL. If the developer listens to connection on the
- // parent site, by default the cookie is not forwarded to the client side,
- // so you can't debug actual running code. In order to make debuggers work
+ // In order to debug web tests you need to either set a cookie, have the
+ // Xdebug session in the URL or set an environment variable in case of CLI
+ // requests. If the developer listens to connection on the parent site, by
+ // default the cookie is not forwarded to the client side, so you cannot
+ // debug the code running on the child site. In order to make debuggers work
// this bit of information is forwarded. Make sure that the debugger listens
// to at least three external connections.
if (isset($_COOKIE['XDEBUG_SESSION'])) {
$cookies[] = 'XDEBUG_SESSION=' . $_COOKIE['XDEBUG_SESSION'];
}
+ // For CLI requests, the information is stored in $_SERVER.
+ if (isset($_SERVER['XDEBUG_CONFIG'])) {
+ // $_SERVER['XDEBUG_CONFIG'] has the form "key1=value1 key2=value2 ...".
+ $pairs = explode(' ', $_SERVER['XDEBUG_CONFIG']);
+ foreach ($pairs as $pair) {
+ list($key, $value) = explode('=', $pair);
+ // Account for key-value pairs being separated by multiple spaces.
+ if (trim($key, ' ') == 'idekey') {
+ $cookies[] = 'XDEBUG_SESSION=' . trim($value, ' ');
+ }
+ }
+ }
// Merge additional cookies in.
if (!empty($cookies)) {