Commit 9107f06d authored by alexpott's avatar alexpott

Issue #2134259 by tstoeckler: Make the Simpletest XDebug integration work for CLI requests.

parent 3cda8309
......@@ -1132,15 +1132,28 @@ protected function curlExec($curl_options, $redirect = FALSE) {
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)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment