1
0
Fork 0

Upgrade to xdebug-handler 2 (#9832)

This adds support for Xdebug3 modes and changes the default behaviour
from always restarting if Xdebug is loaded, to only restarting if Xdebug
is active.

Xdebug is considered active if it is loaded, and for Xdebug3, if it is
running in a mode other than `xdebug.mode=off`.
pull/9911/head
John Stevenson 2021-04-13 08:59:06 +01:00 committed by Jordi Boggiano
parent fee22972ea
commit ce19bcd992
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
6 changed files with 24 additions and 19 deletions

View File

@ -14,7 +14,7 @@ use Composer\XdebugHandler\XdebugHandler;
error_reporting(-1); error_reporting(-1);
// Restart without Xdebug // Restart without Xdebug
$xdebug = new XdebugHandler('Composer', '--ansi'); $xdebug = new XdebugHandler('Composer');
$xdebug->check(); $xdebug->check();
unset($xdebug); unset($xdebug);

View File

@ -27,7 +27,7 @@
"composer/metadata-minifier": "^1.0", "composer/metadata-minifier": "^1.0",
"composer/semver": "^3.0", "composer/semver": "^3.0",
"composer/spdx-licenses": "^1.2", "composer/spdx-licenses": "^1.2",
"composer/xdebug-handler": "^1.1", "composer/xdebug-handler": "^2.0",
"justinrainbow/json-schema": "^5.2.10", "justinrainbow/json-schema": "^5.2.10",
"psr/log": "^1.0", "psr/log": "^1.0",
"seld/jsonlint": "^1.4", "seld/jsonlint": "^1.4",

28
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "2587e14c10bc64959963a6f91f5ada71", "content-hash": "723e5a1bc304dba4f21c6adf2b8f1cb2",
"packages": [ "packages": [
{ {
"name": "composer/ca-bundle", "name": "composer/ca-bundle",
@ -313,16 +313,16 @@
}, },
{ {
"name": "composer/xdebug-handler", "name": "composer/xdebug-handler",
"version": "1.4.6", "version": "2.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/composer/xdebug-handler.git", "url": "https://github.com/composer/xdebug-handler.git",
"reference": "f27e06cd9675801df441b3656569b328e04aa37c" "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/964adcdd3a28bf9ed5d9ac6450064e0d71ed7496",
"reference": "f27e06cd9675801df441b3656569b328e04aa37c", "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -357,7 +357,7 @@
"support": { "support": {
"irc": "irc://irc.freenode.org/composer", "irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/xdebug-handler/issues", "issues": "https://github.com/composer/xdebug-handler/issues",
"source": "https://github.com/composer/xdebug-handler/tree/1.4.6" "source": "https://github.com/composer/xdebug-handler/tree/2.0.1"
}, },
"funding": [ "funding": [
{ {
@ -373,7 +373,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-03-25T17:01:18+00:00" "time": "2021-05-05T19:37:51+00:00"
}, },
{ {
"name": "justinrainbow/json-schema", "name": "justinrainbow/json-schema",
@ -447,16 +447,16 @@
}, },
{ {
"name": "psr/log", "name": "psr/log",
"version": "1.1.3", "version": "1.1.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/log.git", "url": "https://github.com/php-fig/log.git",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" "reference": "d49695b909c3b7628b6289db5479a1c204601f11"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", "reference": "d49695b909c3b7628b6289db5479a1c204601f11",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -480,7 +480,7 @@
"authors": [ "authors": [
{ {
"name": "PHP-FIG", "name": "PHP-FIG",
"homepage": "http://www.php-fig.org/" "homepage": "https://www.php-fig.org/"
} }
], ],
"description": "Common interface for logging libraries", "description": "Common interface for logging libraries",
@ -491,9 +491,9 @@
"psr-3" "psr-3"
], ],
"support": { "support": {
"source": "https://github.com/php-fig/log/tree/1.1.3" "source": "https://github.com/php-fig/log/tree/1.1.4"
}, },
"time": "2020-03-23T09:12:05+00:00" "time": "2021-05-03T11:20:27+00:00"
}, },
{ {
"name": "react/promise", "name": "react/promise",

View File

@ -27,6 +27,8 @@ use Composer\Util\StreamContextFactory;
use Composer\SelfUpdate\Keys; use Composer\SelfUpdate\Keys;
use Composer\SelfUpdate\Versions; use Composer\SelfUpdate\Versions;
use Composer\IO\NullIO; use Composer\IO\NullIO;
use Composer\Package\CompletePackageInterface;
use Composer\XdebugHandler\XdebugHandler;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\ExecutableFinder; use Symfony\Component\Process\ExecutableFinder;
@ -534,7 +536,7 @@ EOT
if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) { if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) {
$warnings['xdebug_profile'] = true; $warnings['xdebug_profile'] = true;
} elseif (extension_loaded('xdebug')) { } elseif (XdebugHandler::isXdebugActive()) {
$warnings['xdebug_loaded'] = true; $warnings['xdebug_loaded'] = true;
} }

View File

@ -33,6 +33,8 @@ use Composer\Util\ErrorHandler;
use Composer\Util\HttpDownloader; use Composer\Util\HttpDownloader;
use Composer\EventDispatcher\ScriptExecutionException; use Composer\EventDispatcher\ScriptExecutionException;
use Composer\Exception\NoSslException; use Composer\Exception\NoSslException;
use Composer\XdebugHandler\XdebugHandler;
use Symfony\Component\Process\Exception\ProcessTimedOutException;
/** /**
* The console application that handles the commands * The console application that handles the commands
@ -236,7 +238,7 @@ class Application extends BaseApplication
$io->writeError('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.</warning>'); $io->writeError('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.</warning>');
} }
if (extension_loaded('xdebug') && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) { if (XdebugHandler::isXdebugActive() && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) {
$io->writeError('<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>'); $io->writeError('<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>');
} }

View File

@ -13,6 +13,7 @@
namespace Composer\Test; namespace Composer\Test;
use Composer\Console\Application; use Composer\Console\Application;
use Composer\XdebugHandler\XdebugHandler;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class ApplicationTest extends TestCase class ApplicationTest extends TestCase
@ -54,7 +55,7 @@ class ApplicationTest extends TestCase
$outputMock->expects($this->at($index++)) $outputMock->expects($this->at($index++))
->method("write"); ->method("write");
if (extension_loaded('xdebug')) { if (XdebugHandler::isXdebugActive()) {
$outputMock->expects($this->at($index++)) $outputMock->expects($this->at($index++))
->method("getVerbosity") ->method("getVerbosity")
->willReturn(OutputInterface::VERBOSITY_NORMAL); ->willReturn(OutputInterface::VERBOSITY_NORMAL);